Deprecate license stanza
This commit is contained in:
parent
faebc64815
commit
5fead8eb5e
@ -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
|
||||
|
||||
@ -102,7 +102,6 @@ module Hbc
|
||||
:url,
|
||||
:appcast,
|
||||
:version,
|
||||
:license,
|
||||
:sha256,
|
||||
:artifacts,
|
||||
:caveats,
|
||||
|
||||
@ -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?
|
||||
|
||||
@ -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
|
||||
@ -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}) }
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
test_cask 'missing-license' do
|
||||
version '1.2.3'
|
||||
|
||||
url 'http://localhost/something.dmg'
|
||||
end
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user