Merge pull request #6629 from timsly/manpage-artifact
Add Manpage artifact
This commit is contained in:
commit
e6cfb4a3c2
@ -2,6 +2,7 @@
|
||||
|
||||
require "cask/artifact/app"
|
||||
require "cask/artifact/artifact" # generic 'artifact' stanza
|
||||
require "cask/artifact/audio_unit_plugin"
|
||||
require "cask/artifact/binary"
|
||||
require "cask/artifact/colorpicker"
|
||||
require "cask/artifact/dictionary"
|
||||
@ -9,7 +10,7 @@ require "cask/artifact/font"
|
||||
require "cask/artifact/input_method"
|
||||
require "cask/artifact/installer"
|
||||
require "cask/artifact/internet_plugin"
|
||||
require "cask/artifact/audio_unit_plugin"
|
||||
require "cask/artifact/manpage"
|
||||
require "cask/artifact/vst_plugin"
|
||||
require "cask/artifact/vst3_plugin"
|
||||
require "cask/artifact/pkg"
|
||||
|
||||
@ -71,6 +71,7 @@ module Cask
|
||||
# targets are created prior to linking.
|
||||
Pkg,
|
||||
Binary,
|
||||
Manpage,
|
||||
PostflightBlock,
|
||||
Zap,
|
||||
].each_with_index.flat_map { |classes, i| [*classes].map { |c| [c, i] } }.to_h
|
||||
|
||||
29
Library/Homebrew/cask/artifact/manpage.rb
Normal file
29
Library/Homebrew/cask/artifact/manpage.rb
Normal file
@ -0,0 +1,29 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/artifact/symlinked"
|
||||
|
||||
module Cask
|
||||
module Artifact
|
||||
class Manpage < Symlinked
|
||||
attr_reader :section
|
||||
|
||||
def self.from_args(cask, source)
|
||||
section = source.to_s[/\.([1-8]|n|l)$/, 1]
|
||||
|
||||
raise CaskInvalidError, "'#{source}' is not a valid man page name" unless section
|
||||
|
||||
new(cask, source, section)
|
||||
end
|
||||
|
||||
def initialize(cask, source, section)
|
||||
@section = section
|
||||
|
||||
super(cask, source)
|
||||
end
|
||||
|
||||
def resolve_target(target)
|
||||
config.manpagedir.join("man#{section}", target)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -93,6 +93,10 @@ module Cask
|
||||
@binarydir ||= HOMEBREW_PREFIX/"bin"
|
||||
end
|
||||
|
||||
def manpagedir
|
||||
@manpagedir ||= HOMEBREW_PREFIX/"share/man"
|
||||
end
|
||||
|
||||
DEFAULT_DIRS.keys.each do |dir|
|
||||
define_method(dir) do
|
||||
explicit.fetch(dir, env.fetch(dir, default.fetch(dir)))
|
||||
|
||||
@ -35,6 +35,7 @@ module Cask
|
||||
Artifact::Font,
|
||||
Artifact::InputMethod,
|
||||
Artifact::InternetPlugin,
|
||||
Artifact::Manpage,
|
||||
Artifact::Pkg,
|
||||
Artifact::Prefpane,
|
||||
Artifact::Qlplugin,
|
||||
|
||||
@ -19,6 +19,7 @@ module RuboCop
|
||||
:pkg,
|
||||
:installer,
|
||||
:binary,
|
||||
:manpage,
|
||||
:colorpicker,
|
||||
:dictionary,
|
||||
:font,
|
||||
|
||||
40
Library/Homebrew/test/cask/artifact/manpage_spec.rb
Normal file
40
Library/Homebrew/test/cask/artifact/manpage_spec.rb
Normal file
@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
describe Cask::Artifact::Manpage, :cask do
|
||||
let(:cask) { Cask::CaskLoader.load(cask_path(cask_token)) }
|
||||
|
||||
context "without section" do
|
||||
let(:cask_token) { "invalid/invalid-manpage-no-section" }
|
||||
|
||||
it "fails to load a cask without section" do
|
||||
expect { cask }.to raise_error(Cask::CaskInvalidError, /is not a valid man page name/)
|
||||
end
|
||||
end
|
||||
|
||||
context "with install" do
|
||||
let(:install_phase) {
|
||||
lambda do
|
||||
cask.artifacts.select { |a| a.is_a?(described_class) }.each do |artifact|
|
||||
artifact.install_phase(command: NeverSudoSystemCommand, force: false)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
let(:source_path) { cask.staged_path.join("manpage.1") }
|
||||
let(:target_path) { cask.config.manpagedir.join("man1/manpage.1") }
|
||||
|
||||
before do
|
||||
InstallHelper.install_without_artifacts(cask)
|
||||
end
|
||||
|
||||
context "with autodetected section" do
|
||||
let(:cask_token) { "with-autodetected-manpage-section" }
|
||||
|
||||
it "links the manpage to the proper directory" do
|
||||
install_phase.call
|
||||
|
||||
expect(File).to be_identical target_path, source_path
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
BIN
Library/Homebrew/test/support/fixtures/cask/AppWithManpage.zip
Normal file
BIN
Library/Homebrew/test/support/fixtures/cask/AppWithManpage.zip
Normal file
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
cask 'invalid-manpage-no-section' do
|
||||
version '1.2.3'
|
||||
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
|
||||
|
||||
url "file://#{TEST_FIXTURE_DIR}/cask/AppWithManpage.zip"
|
||||
homepage 'https://brew.sh/with-generic-artifact'
|
||||
|
||||
manpage 'manpage'
|
||||
end
|
||||
@ -0,0 +1,9 @@
|
||||
cask 'with-autodetected-manpage-section' do
|
||||
version '1.2.3'
|
||||
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
|
||||
|
||||
url "file://#{TEST_FIXTURE_DIR}/cask/AppWithManpage.zip"
|
||||
homepage 'https://brew.sh/with-autodetected-manpage-section'
|
||||
|
||||
manpage 'manpage.1'
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user