From 22d821323cff738fd8fc331c49c0408dd22c9e28 Mon Sep 17 00:00:00 2001 From: Tim Masliuchenko Date: Wed, 23 Oct 2019 16:28:00 +0300 Subject: [PATCH] Feedbacks --- Library/Homebrew/cask/artifact.rb | 4 +- Library/Homebrew/cask/artifact/manpage.rb | 40 +++++-------------- Library/Homebrew/cask/dsl.rb | 2 +- .../rubocops/cask/constants/stanza.rb | 2 +- .../test/cask/artifact/manpage_spec.rb | 17 +------- .../Casks/with-explicit-manpage-section.rb | 9 ----- 6 files changed, 15 insertions(+), 59 deletions(-) delete mode 100644 Library/Homebrew/test/support/fixtures/cask/Casks/with-explicit-manpage-section.rb diff --git a/Library/Homebrew/cask/artifact.rb b/Library/Homebrew/cask/artifact.rb index 278d0c4442..07d8925155 100644 --- a/Library/Homebrew/cask/artifact.rb +++ b/Library/Homebrew/cask/artifact.rb @@ -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 diff --git a/Library/Homebrew/cask/artifact/manpage.rb b/Library/Homebrew/cask/artifact/manpage.rb index d7957c625d..6938f6035d 100644 --- a/Library/Homebrew/cask/artifact/manpage.rb +++ b/Library/Homebrew/cask/artifact/manpage.rb @@ -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 diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 9e6c2a29eb..5090744e73 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -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 diff --git a/Library/Homebrew/rubocops/cask/constants/stanza.rb b/Library/Homebrew/rubocops/cask/constants/stanza.rb index 3684eef095..33bdb1f034 100644 --- a/Library/Homebrew/rubocops/cask/constants/stanza.rb +++ b/Library/Homebrew/rubocops/cask/constants/stanza.rb @@ -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], diff --git a/Library/Homebrew/test/cask/artifact/manpage_spec.rb b/Library/Homebrew/test/cask/artifact/manpage_spec.rb index e4e0a8d04e..b1813dfa7f 100644 --- a/Library/Homebrew/test/cask/artifact/manpage_spec.rb +++ b/Library/Homebrew/test/cask/artifact/manpage_spec.rb @@ -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 diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-explicit-manpage-section.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-explicit-manpage-section.rb deleted file mode 100644 index ce01e051a5..0000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-explicit-manpage-section.rb +++ /dev/null @@ -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