Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Licenses #32

Closed
wants to merge 2 commits into from

2 participants

@flavorjones

Adding convenience method and attribute for declaring licenses. This might reasonably encourage people to declare licenses in their gemspec for use in, e.g. rubygems.org

See https://github.com/rubygems/rubygems.org/pull/458/files for some related work.

@zenspider
Owner

Hrm... what version of rubygems supports licenses? I guess I haven't paid attention to that one.

@zenspider zenspider was assigned
@zenspider
Owner

Done! Thanks!

@zenspider zenspider closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
6 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:
View
16 lib/hoe.rb
@@ -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 @@ def activate_plugin_deps
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 @@ def define_spec
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 @@ def initialize name, version = nil # :nodoc:
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
View
2  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
View
48 test/test_hoe.rb
@@ -319,6 +319,54 @@ def test_possibly_better
# 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
Something went wrong with that request. Please try again.