diff --git a/Library/Homebrew/cask/lib/hbc/audit.rb b/Library/Homebrew/cask/lib/hbc/audit.rb index 476f2aec05..533ede70d9 100644 --- a/Library/Homebrew/cask/lib/hbc/audit.rb +++ b/Library/Homebrew/cask/lib/hbc/audit.rb @@ -50,7 +50,6 @@ module Hbc %i{version sha256 url homepage}.each do |sym| add_error "a #{sym} stanza is required" unless cask.send(sym) end - add_error "a license stanza is required (:unknown is OK)" unless cask.license add_error "at least one name stanza is required" if cask.name.empty? # TODO: specific DSL knowledge should not be spread around in various files like this # TODO: nested_container should not still be a pseudo-artifact at this point diff --git a/Library/Homebrew/cask/lib/hbc/cask.rb b/Library/Homebrew/cask/lib/hbc/cask.rb index 1e2056efc7..b66f16a8ef 100644 --- a/Library/Homebrew/cask/lib/hbc/cask.rb +++ b/Library/Homebrew/cask/lib/hbc/cask.rb @@ -102,7 +102,6 @@ module Hbc :url, :appcast, :version, - :license, :sha256, :artifacts, :caveats, diff --git a/Library/Homebrew/cask/lib/hbc/dsl.rb b/Library/Homebrew/cask/lib/hbc/dsl.rb index 8e0a7715af..f074830cb3 100644 --- a/Library/Homebrew/cask/lib/hbc/dsl.rb +++ b/Library/Homebrew/cask/lib/hbc/dsl.rb @@ -9,7 +9,6 @@ require "hbc/dsl/container" require "hbc/dsl/depends_on" require "hbc/dsl/gpg" require "hbc/dsl/installer" -require "hbc/dsl/license" require "hbc/dsl/postflight" require "hbc/dsl/preflight" require "hbc/dsl/stanza_proxy" @@ -66,7 +65,6 @@ module Hbc :gpg, :homepage, :language, - :license, :name, :sha256, :staged_path, @@ -206,16 +204,6 @@ module Hbc @sha256 ||= arg end - def license(arg = nil) - return @license if arg.nil? - assert_only_one_stanza_allowed :license, !arg.nil? - @license ||= begin - DSL::License.new(arg) unless arg.nil? - rescue StandardError => e - raise CaskInvalidError.new(token, e) - end - end - # depends_on uses a load method so that multiple stanzas can be merged def depends_on(*args) return @depends_on if args.empty? diff --git a/Library/Homebrew/cask/lib/hbc/dsl/license.rb b/Library/Homebrew/cask/lib/hbc/dsl/license.rb deleted file mode 100644 index affbc08f51..0000000000 --- a/Library/Homebrew/cask/lib/hbc/dsl/license.rb +++ /dev/null @@ -1,70 +0,0 @@ -module Hbc - class DSL - class License - # a generic category can always be given as a license, so - # category names should be given as both key and value - VALID_LICENSES = { - # license category - unknown: :unknown, - - other: :other, - - closed: :closed, - commercial: :closed, - gratis: :closed, - freemium: :closed, - - oss: :oss, - affero: :oss, - apache: :oss, - arphic: :oss, - artistic: :oss, - bsd: :oss, - cc: :oss, - eclipse: :oss, - gpl: :oss, - isc: :oss, - lppl: :oss, - ncsa: :oss, - mit: :oss, - mpl: :oss, - ofl: :oss, - public_domain: :oss, - ubuntu_font: :oss, - x11: :oss, - }.freeze - - DEFAULT_LICENSE = :unknown - DEFAULT_CATEGORY = VALID_LICENSES[DEFAULT_LICENSE] - - attr_reader :value - - def self.check_constants - categories = Set.new(VALID_LICENSES.values) - categories.each do |cat| - next if VALID_LICENSES.key?(cat) - raise "license category is not a value: '#{@cat.inspect}'" - end - end - - def self.category(license) - VALID_LICENSES.fetch(license, DEFAULT_CATEGORY) - end - - def initialize(arg) - @value = arg - @value = DEFAULT_LICENSE if @value.nil? - return if VALID_LICENSES.key?(@value) - raise "invalid license value: '#{@value.inspect}'" - end - - def category - self.class.category(@value) - end - - def to_s - @value.inspect - end - end - end -end diff --git a/Library/Homebrew/cask/spec/cask/audit_spec.rb b/Library/Homebrew/cask/spec/cask/audit_spec.rb index 87758a1af8..7094ea3a89 100644 --- a/Library/Homebrew/cask/spec/cask/audit_spec.rb +++ b/Library/Homebrew/cask/spec/cask/audit_spec.rb @@ -52,7 +52,7 @@ describe Hbc::Audit do subject { audit.run! } describe "required stanzas" do - %w[version sha256 url name homepage license].each do |stanza| + %w[version sha256 url name homepage].each do |stanza| context "when missing #{stanza}" do let(:cask_token) { "missing-#{stanza}" } it { is_expected.to fail_with(%r{#{stanza} stanza is required}) } diff --git a/Library/Homebrew/cask/spec/support/Casks/missing-license.rb b/Library/Homebrew/cask/spec/support/Casks/missing-license.rb deleted file mode 100644 index 30f3791c77..0000000000 --- a/Library/Homebrew/cask/spec/support/Casks/missing-license.rb +++ /dev/null @@ -1,5 +0,0 @@ -test_cask 'missing-license' do - version '1.2.3' - - url 'http://localhost/something.dmg' -end diff --git a/Library/Homebrew/cask/test/cask/cli/create_test.rb b/Library/Homebrew/cask/test/cask/cli/create_test.rb index efca1a5064..06c2d203c5 100644 --- a/Library/Homebrew/cask/test/cask/cli/create_test.rb +++ b/Library/Homebrew/cask/test/cask/cli/create_test.rb @@ -49,7 +49,6 @@ describe Hbc::CLI::Create do url 'https://' name '' homepage '' - license :unknown # TODO: change license and remove this comment; ':unknown' is a machine-generated placeholder app '' end diff --git a/Library/Homebrew/cask/test/cask/dsl_test.rb b/Library/Homebrew/cask/test/cask/dsl_test.rb index 053eae1e1d..d3361080b1 100644 --- a/Library/Homebrew/cask/test/cask/dsl_test.rb +++ b/Library/Homebrew/cask/test/cask/dsl_test.rb @@ -406,31 +406,6 @@ describe Hbc::DSL do end end - describe "license stanza" do - it "allows the license to be specified" do - cask = Hbc.load("with-license") - cask.license.value.must_equal :gpl - end - - it "the license has a category" do - cask = Hbc.load("with-license") - cask.license.category.must_equal :oss - end - - it "prevents defining multiple license stanzas" do - err = lambda { - Hbc.load("invalid/invalid-license-multiple") - }.must_raise(Hbc::CaskInvalidError) - err.message.must_include "'license' stanza may only appear once" - end - - it "refuses to load on invalid license value" do - lambda { - Hbc.load("invalid/invalid-license-value") - }.must_raise(Hbc::CaskInvalidError) - end - end - describe "installer stanza" do it "allows installer script to be specified" do cask = Hbc.load("with-installer-script") diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-license-multiple.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-license-multiple.rb deleted file mode 100644 index 706b9490b9..0000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-license-multiple.rb +++ /dev/null @@ -1,11 +0,0 @@ -test_cask 'invalid-license-multiple' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url TestHelper.local_binary_url('transmission-2.61.dmg') - homepage 'http://example.com/invalid-license-multiple' - license :gpl - license :gpl - - app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-license-value.rb b/Library/Homebrew/cask/test/support/Casks/invalid/invalid-license-value.rb deleted file mode 100644 index dbc36e5810..0000000000 --- a/Library/Homebrew/cask/test/support/Casks/invalid/invalid-license-value.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'invalid-license-value' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url TestHelper.local_binary_url('transmission-2.61.dmg') - homepage 'http://example.com/invalid-license-value' - license :no_such_license - - app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-license.rb b/Library/Homebrew/cask/test/support/Casks/with-license.rb deleted file mode 100644 index 6a85c8e319..0000000000 --- a/Library/Homebrew/cask/test/support/Casks/with-license.rb +++ /dev/null @@ -1,10 +0,0 @@ -test_cask 'with-license' do - version '2.61' - sha256 'e44ffa103fbf83f55c8d0b1bea309a43b2880798dae8620b1ee8da5e1095ec68' - - url TestHelper.local_binary_url('transmission-2.61.dmg') - homepage 'http://example.com/with-license' - license :gpl - - app 'Transmission.app' -end diff --git a/Library/Homebrew/cask/test/support/Casks/with-suite.rb b/Library/Homebrew/cask/test/support/Casks/with-suite.rb index dbaaaea679..e92b224253 100644 --- a/Library/Homebrew/cask/test/support/Casks/with-suite.rb +++ b/Library/Homebrew/cask/test/support/Casks/with-suite.rb @@ -5,7 +5,6 @@ test_cask 'with-suite' do url TestHelper.local_binary_url('caffeine-suite.zip') name 'Caffeine' homepage 'http://example.com/with-suite' - license :unknown # TODO: change license and remove this comment; ':unknown' is a machine-generated placeholder suite 'Caffeine' end