diff options
author | Ryan Davis <ryand@zenspider.com> | 2012-09-14 16:16:42 -0800 |
---|---|---|
committer | Ryan Davis <ryand@zenspider.com> | 2012-09-14 16:16:42 -0800 |
commit | 03b74515510dc18283ce9d1ff8b389f9d33fdde6 (patch) | |
tree | c8d3a605fba97841b8cc61485bef24433f48fefa | |
parent | b19ed9b2099536030e9d793c7b7e2770fe88b8b0 (diff) | |
download | hoe-03b74515510dc18283ce9d1ff8b389f9d33fdde6.tar.gz |
+ Added Hoe#licenses and Hoe#license for declaring your gem's license. (flavorjones)
[git-p4: depot-paths = "//src/hoe/dev/": change = 7774]
-rw-r--r-- | History.txt | 6 | ||||
-rw-r--r-- | Rakefile | 2 | ||||
-rw-r--r-- | lib/hoe.rb | 16 | ||||
-rw-r--r-- | template/Rakefile.erb | 2 | ||||
-rw-r--r-- | test/test_hoe.rb | 48 |
5 files changed, 74 insertions, 0 deletions
diff --git a/History.txt b/History.txt index 56a3c31..326899e 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,9 @@ +=== Unreleased + +* 1 minor enhancement: + + * New Hoe#licenses attribute and Hoe#license helper method, for declaring gem's license(s). + === 3.0.8 / 2012-08-20 * 1 bug fix: @@ -13,6 +13,8 @@ Hoe.spec "hoe" do blog_categories << "Seattle.rb" << "Ruby" + license "MIT" + pluggable! require_rubygems_version '>= 1.4' @@ -183,6 +183,11 @@ class Hoe attr_accessor :history_file ## + # Optional: An array containing the license(s) under which this gem is released. + + attr_accessor :licenses + + ## # *MANDATORY*: The name of the release. # # Set via Hoe.spec. @@ -423,6 +428,14 @@ class Hoe end ## + # Specify a license for your gem. + # Call it multiple times if you are releasing under multiple licenses. + # + def license name + self.licenses << name + end + + ## # Add a dependency declaration to your spec. Pass :dev to # +type+ for developer dependencies. @@ -550,6 +563,8 @@ class Hoe end end + spec.licenses = licenses unless licenses.empty? + # Do any extra stuff the user wants spec_extras.each do |msg, val| case val @@ -593,6 +608,7 @@ class Hoe self.extra_deps = [] self.extra_dev_deps = [] self.extra_rdoc_files = [] + self.licenses = [] self.post_install_message = nil self.rubyforge_name = name.downcase self.spec = nil diff --git a/template/Rakefile.erb b/template/Rakefile.erb index 4ad54a3..42eecb0 100644 --- a/template/Rakefile.erb +++ b/template/Rakefile.erb @@ -17,6 +17,8 @@ Hoe.spec '<%= project %>' do # developer('<%= XIF %>', '<%= XIF %>@example.com') # self.rubyforge_name = '<%= project %>x' # if different than '<%= project %>' + + # license 'MIT' # this should match the license in the README end # vim: syntax=ruby diff --git a/test/test_hoe.rb b/test/test_hoe.rb index 3f74359..c078864 100644 --- a/test/test_hoe.rb +++ b/test/test_hoe.rb @@ -319,6 +319,54 @@ class TestHoe < MiniTest::Unit::TestCase # flunk "not yet" end + def test_no_license + hoe = Hoe.spec("blah") do + self.version = '1.2.3' + developer 'author', 'email' + end + + spec = hoe.spec + + assert spec.licenses.empty? + end + + def test_license + hoe = Hoe.spec("blah") do + self.version = '1.2.3' + developer 'author', 'email' + license 'MIT' + end + + spec = hoe.spec + + assert_equal %w(MIT), spec.licenses + end + + def test_multiple_calls_to_license + hoe = Hoe.spec("blah") do + self.version = '1.2.3' + developer 'author', 'email' + license 'MIT' + license 'GPL-2' + end + + spec = hoe.spec + + assert_equal %w(MIT GPL-2), spec.licenses + end + + def test_setting_licenses + hoe = Hoe.spec("blah") do + self.version = '1.2.3' + developer 'author', 'email' + self.licenses = ['MIT', 'GPL-2'] + end + + spec = hoe.spec + + assert_equal %w(MIT GPL-2), spec.licenses + end + def test_plugins before = Hoe.plugins.dup |