Feedbacks

This commit is contained in:
Tim Masliuchenko 2019-10-23 16:28:00 +03:00
parent 3ef5e06943
commit 22d821323c
6 changed files with 15 additions and 59 deletions

View File

@ -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"
@ -23,7 +24,6 @@ require "cask/artifact/stage_only"
require "cask/artifact/suite"
require "cask/artifact/uninstall"
require "cask/artifact/zap"
require "cask/artifact/manpage"
module Cask
module Artifact

View File

@ -1,50 +1,28 @@
# frozen_string_literal: true
require "cask/artifact/moved"
require "extend/hash_validator"
using HashValidator
require "cask/artifact/symlinked"
module Cask
module Artifact
class Manpage < Moved
def self.from_args(cask, *args)
source_string, section_hash = args
section = nil
if section_hash
raise CaskInvalidError unless section_hash.respond_to?(:keys)
section_hash.assert_valid_keys!(:section)
section = section_hash[:section]
else
section = source_string.split(".").last
end
class Manpage < Symlinked
def self.from_args(cask, source)
section = source.split(".").last
raise CaskInvalidError, "section should be a positive number" unless section.to_i.positive?
section_hash ||= {}
new(cask, source)
end
new(cask, source_string, **section_hash)
def initialize(cask, source)
super
end
def resolve_target(_target)
config.manpagedir.join("man#{section}", target_name)
end
def initialize(cask, source, section: nil)
@source_section = section
super(cask, source)
end
def extension
@source.extname.downcase[1..-1].to_s
end
def section
(@source_section || extension).to_i
@source.extname.downcase[1..-1].to_s.to_i
end
def target_name

View File

@ -35,6 +35,7 @@ module Cask
Artifact::Font,
Artifact::InputMethod,
Artifact::InternetPlugin,
Artifact::Manpage,
Artifact::Pkg,
Artifact::Prefpane,
Artifact::Qlplugin,
@ -46,7 +47,6 @@ module Cask
Artifact::Vst3Plugin,
Artifact::Uninstall,
Artifact::Zap,
Artifact::Manpage,
].freeze
ACTIVATABLE_ARTIFACT_CLASSES = (ORDINARY_ARTIFACT_CLASSES - [Artifact::StageOnly]).freeze

View File

@ -19,6 +19,7 @@ module RuboCop
:pkg,
:installer,
:binary,
:manpage,
:colorpicker,
:dictionary,
:font,
@ -32,7 +33,6 @@ module RuboCop
:vst_plugin,
:artifact,
:stage_only,
:manpage,
],
[:preflight],
[:postflight],

View File

@ -33,23 +33,10 @@ describe Cask::Artifact::Manpage, :cask do
let(:cask_token) { "with-autodetected-manpage-section" }
let(:expected_section) { 1 }
it "moves the manpage to the proper directory" do
it "links the manpage to the proper directory" do
install_phase.call
expect(target_path).to exist
expect(source_path).not_to exist
end
end
context "with explicit section" do
let(:cask_token) { "with-explicit-manpage-section" }
let(:expected_section) { 3 }
it "moves the manpage to the proper directory" do
install_phase.call
expect(target_path).to exist
expect(source_path).not_to exist
expect(File).to be_identical target_path, source_path
end
end
end

View File

@ -1,9 +0,0 @@
cask 'with-explicit-manpage-section' do
version '1.2.3'
sha256 '67cdb8a02803ef37fdbf7e0be205863172e41a561ca446cd84f0d7ab35a99d94'
url "file://#{TEST_FIXTURE_DIR}/cask/AppWithManpage.zip"
homepage 'https://brew.sh/with-explicit-manpage-section'
manpage 'manpage.1', section: 3
end