diff options
author | Ryan Davis <ryand-ruby@zenspider.com> | 2022-05-17 15:00:16 -0800 |
---|---|---|
committer | Ryan Davis <ryand-ruby@zenspider.com> | 2022-05-17 15:00:16 -0800 |
commit | 95eb9a21fe572fe9e9dc622d7098548b88dcf041 (patch) | |
tree | 0d55802970ccb771b0071f4e244f7313a5865584 | |
parent | 24c817b027e32e46844fe2daaeb4306979e3c3b7 (diff) | |
download | hoe-95eb9a21fe572fe9e9dc622d7098548b88dcf041.tar.gz |
+ Add bindir and homepage accessor methods. (dsisnero)
+ Use bindir to determine executables. (dsisnero)
+ Don't auto-intuit values if they're already set. (dsisnero)
[git-p4: depot-paths = "//src/hoe/dev/": change = 13384]
-rw-r--r-- | lib/hoe.rb | 29 | ||||
-rw-r--r-- | test/test_hoe.rb | 24 |
2 files changed, 48 insertions, 5 deletions
@@ -223,6 +223,18 @@ class Hoe attr_accessor :group_name ## + # Optional: The name of the executables directory. [default: bin] + + attr_accessor :bindir + + ## + # Optional: The homepage of the project. Auto-populates to the home key + # of the urls read from the README.txt + # + + attr_accessor :homepage + + ## # The Gem::Specification. attr_accessor :spec # :nodoc: @@ -525,17 +537,18 @@ class Hoe s.version = version if version s.summary = summary s.email = email - s.homepage = urls["home"] || urls.values.first + s.homepage = homepage || urls["home"] || urls.values.first + s.description = description s.files = manifest - s.executables = s.files.grep(/^bin/) { |f| File.basename(f) } - s.bindir = "bin" + s.bindir = bindir || "bin" + s.executables = s.files.grep(/^#{s.bindir}/) { |f| File.basename(f) } s.require_paths = dirs unless dirs.empty? s.rdoc_options = ["--main", readme_file] s.post_install_message = post_install_message s.metadata = (urls.keys & URLS_TO_META_MAP.keys).map { |name| [URLS_TO_META_MAP[name], urls[name]] - }.to_h + }.to_h if urls missing "Manifest.txt" if s.files.empty? @@ -810,7 +823,9 @@ class Hoe def post_initialize activate_plugin_deps - intuit_values File.read_utf readme_file if readme_file + unless skip_intuit_values? + intuit_values File.read_utf readme_file if readme_file + end validate_fields define_spec load_plugin_tasks @@ -896,6 +911,10 @@ class Hoe end end + def skip_intuit_values? + %w[summary description homepage].all? { |field| send field } + end + ## # Loads ~/.hoerc, merges it with a .hoerc in the current pwd (if # any) and yields the configuration and its path diff --git a/test/test_hoe.rb b/test/test_hoe.rb index c8d8d3a..1539499 100644 --- a/test/test_hoe.rb +++ b/test/test_hoe.rb @@ -297,6 +297,30 @@ class TestHoe < Minitest::Test assert_equal exp, h.urls end + def test_intuit_values_should_be_silent_if_summary_description_and_homepage_are_set + h = nil + _readme = <<~EOM + == this is readme + + == description + this is a bogus description + EOM + + assert_silent do + h = Hoe.spec "blah" do + developer "auther", "email" + license "MIT" + self.homepage = 'http://myhome' + self.description = 'this is real description' + self.summary = 'this is summary' + end + end + + assert_equal h.homepage , 'http://myhome' + assert_equal h.description , 'this is real description' + assert_equal h.summary , 'this is summary' + end + def test_metadata hash = [ "home :: https://github.com/seattlerb/hoe", |