lib/hoe.rb in hoe-3.21.0 vs lib/hoe.rb in hoe-3.22.0
- old
+ new
@@ -1,9 +1,5 @@
-# -*- mode: ruby; coding: us-ascii; -*-
-
-require "rubygems"
-
begin
gem "rake"
rescue Gem::LoadError
warn "Using the crusty system installed rake... you probably want to upgrade"
end
@@ -89,11 +85,11 @@
class Hoe
include Rake::DSL if defined?(Rake::DSL)
# duh
- VERSION = "3.21.0"
+ VERSION = "3.22.0"
@@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package,
:publish, :gemcutter, :signing, :test]
@bad_plugins = []
@@ -117,10 +113,11 @@
URLS_TO_META_MAP = {
"bugs" => "bug_tracker_uri",
"clog" => "changelog_uri",
"doco" => "documentation_uri",
+ "docs" => "documentation_uri",
"home" => "homepage_uri",
"code" => "source_code_uri",
"wiki" => "wiki_uri",
"mail" => "mailing_list_uri",
}
@@ -648,30 +645,36 @@
if manifest then
self.readme_file = manifest.grep(/^README\./).first
self.history_file = manifest.grep(/^History\./).first
end
- self.history_file ||= Dir.glob("History.{txt,md}").first || "History.txt"
- self.readme_file ||= Dir.glob("README.{txt,md}").first || "README.txt"
+ self.history_file ||= Dir.glob("History.{rdoc,txt,md}").first || "History.txt"
+ self.readme_file ||= Dir.glob("README.{rdoc,txt,md}").first || "README.txt"
abort "Hoe.new {...} removed. Switch to Hoe.spec." if block_given?
end
##
# Intuit values from the readme and history files.
- def intuit_values
- header_re = /^((?:=+|#+) .*)$/
- readme = File.read_utf(readme_file).split(header_re)[1..-1] rescue ""
+ def intuit_values input
+ readme = input
+ .lines
+ .chunk { |l| l[/^(?:=+|#+)/] || "" }
+ .map(&:last)
+ .each_slice(2)
+ .map { |k, v|
+ kp = k.join
+ kp = kp.strip.chomp(":").split.last.downcase if k.size == 1
+ [kp, v.join.strip]
+ }
+ .to_h
unless readme.empty? then
- sections = Hash[*readme.map { |s|
- s =~ /^[=#]/ ? s.strip.downcase.chomp(":").split.last : s.strip
- }]
- desc = sections.values_at(*description_sections).join("\n\n")
+ desc = readme.values_at(*description_sections).join("\n\n")
summ = desc.split(/\.\s+/).first(summary_sentences).join(". ")
- urls = parse_urls(readme[1])
+ urls = parse_urls(readme.values.first)
self.urls ||= urls
self.description ||= desc
self.summary ||= summ
else
@@ -806,10 +809,10 @@
##
# Finalize configuration
def post_initialize
activate_plugin_deps
- intuit_values
+ intuit_values File.read_utf readme_file if readme_file
validate_fields
define_spec
load_plugin_tasks
add_dependencies
end