lib/hoe.rb in hoe-1.5.0 vs lib/hoe.rb in hoe-1.5.1
- old
+ new
@@ -32,32 +32,31 @@
#
# # add other tasks here
#
# === Tasks Provided:
#
-# announce:: Generate email announcement file and post to rubyforge.
-# audit:: Run ZenTest against the package
-# check_manifest:: Verify the manifest
-# clean:: Clean up all the extras
-# config_hoe:: Create a fresh ~/.hoerc file
+# announce:: Create news email file and post to rubyforge.
+# audit:: Run ZenTest against the package.
+# check_manifest:: Verify the manifest.
+# clean:: Clean up all the extras.
+# config_hoe:: Create a fresh ~/.hoerc file.
# debug_gem:: Show information about the gem.
-# default:: Run the default tasks
+# default:: Run the default tasks.
# docs:: Build the docs HTML Files
# email:: Generate email announcement file.
-# gem:: Build the gem file only.
-# install:: Install the package. Uses PREFIX and RUBYLIB
-# install_gem:: Install the package as a gem
-# multi:: Run the test suite using multiruby
+# gem:: Build the gem file hoe-1.5.0.gem
+# generate_key:: Generate a key for signing your gems.
+# install_gem:: Install the package as a gem.
+# multi:: Run the test suite using multiruby.
# package:: Build all the packages
# post_blog:: Post announcement to blog.
# post_news:: Post announcement to rubyforge.
-# publish_docs:: Publish RDoc to RubyForge
+# publish_docs:: Publish RDoc to RubyForge.
# release:: Package and upload the release to rubyforge.
-# ridocs:: Generate ri locally for testing
-# test:: Run the test suite. Use FILTER to add to the command line.
+# ridocs:: Generate ri locally for testing.
+# test:: Run the test suite.
# test_deps:: Show which test files fail when run alone.
-# uninstall:: Uninstall the package.
#
# === Extra Configuration Options:
#
# Run +config_hoe+ to generate a new ~/.hoerc file. The file is a
# YAML formatted config file with the following settings:
@@ -115,11 +114,11 @@
# This will set the +Gem::Specification+ platform to the one indicated in
# +FORCE_PLATFORM+ (instead of default Gem::Platform::CURRENT)
#
class Hoe
- VERSION = '1.5.0'
+ VERSION = '1.5.1'
ruby_prefix = Config::CONFIG['prefix']
sitelibdir = Config::CONFIG['sitelibdir']
##
@@ -294,11 +293,12 @@
self.name = name
self.version = version
# Defaults
self.author = []
- self.clean_globs = %w(diff diff.txt email.txt ri *.gem **/*~)
+ self.clean_globs = %w(diff diff.txt email.txt ri
+ *.gem *~ **/*~ *.rbc **/*.rbc)
self.description_sections = %w(description)
self.email = []
self.extra_deps = []
self.need_tar = true
self.need_zip = false
@@ -312,21 +312,27 @@
yield self if block_given?
# Intuit values:
- history = File.read("History.txt").split(/^(===.*)/)
readme = File.read("README.txt").split(/^(=+ .*)$/)[1..-1]
- sections = readme.map { |s| s =~ /^=/ ? s.strip.downcase.chomp(':').split.last : s.strip }
- sections = Hash[*sections]
- desc = sections.values_at(*description_sections).join("\n\n")
- summ = desc.split(/\.\s+/).first(summary_sentences).join(". ")
+ unless readme.empty? then
+ sections = readme.map { |s|
+ s =~ /^=/ ? s.strip.downcase.chomp(':').split.last : s.strip
+ }
+ sections = Hash[*sections]
+ desc = sections.values_at(*description_sections).join("\n\n")
+ summ = desc.split(/\.\s+/).first(summary_sentences).join(". ")
- self.description ||= desc
- self.changes ||= history[0..2].join.strip
- self.summary ||= summ
- self.url ||= readme[1].gsub(/^\* /, '').split(/\n/).grep(/\S+/)
+ self.description ||= desc
+ self.changes ||= File.read("History.txt").split(/^(===.*)/)[1..2].join.strip
+ self.summary ||= summ
+ self.url ||= readme[1].gsub(/^\* /, '').split(/\n/).grep(/\S+/)
+ else
+ warn "** README.txt is in the wrong format for auto-intuiting."
+ warn " run sow blah and look at it's text files"
+ end
%w(email author).each do |field|
value = self.send(field)
if value.nil? or value.empty? then
if Time.now < Time.local(2008, 4, 1) then
@@ -344,12 +350,12 @@
}
self.extra_deps = Array(extra_deps).map { |o| String === o ? [o] : o }
if name == 'hoe' then
- hoe_deps.each do |pkg, version|
- extra_deps << [pkg, version]
+ hoe_deps.each do |pkg, vers|
+ extra_deps << [pkg, vers]
end
else
extra_deps << ['hoe', ">= #{VERSION}"] unless hoe_deps.has_key? name
end
@@ -367,11 +373,11 @@
exists = File.exist? rc
config = exists ? YAML.load_file(rc) : {}
yield(config, rc)
end
- desc 'Run the default tasks'
+ desc 'Run the default tasks.'
task :default => :test
desc 'Run the test suite. Use FILTER to add to the command line.'
task :test do
run_tests
@@ -386,11 +392,11 @@
puts "Dependency Issues: #{test}"
end
end
end
- desc 'Run the test suite using multiruby'
+ desc 'Run the test suite using multiruby.'
task :multi do
run_tests :multi
end
############################################################
@@ -505,38 +511,15 @@
Rake::GemPackageTask.new spec do |pkg|
pkg.need_tar = @need_tar
pkg.need_zip = @need_zip
end
- desc 'Install the package. Uses PREFIX and RUBYLIB'
- task :install do
- [
- [lib_files + test_files, RUBYLIB, 0444],
- [bin_files, File.join(PREFIX, 'bin'), 0555]
- ].each do |files, dest, mode|
- FileUtils.mkdir_p dest unless test ?d, dest
- files.each do |file|
- install file, dest, :mode => mode
- end
- end
- end
-
- desc 'Install the package as a gem'
+ desc 'Install the package as a gem.'
task :install_gem => [:clean, :package] do
sh "#{'sudo ' unless WINDOZE}gem install --local pkg/*.gem"
end
- desc 'Uninstall the package.'
- task :uninstall do
- Dir.chdir RUBYLIB do
- rm_f((lib_files + test_files).map { |f| File.basename f })
- end
- Dir.chdir File.join(PREFIX, 'bin') do
- rm_f bin_files.map { |f| File.basename f }
- end
- end
-
desc 'Package and upload the release to rubyforge.'
task :release => [:clean, :package] do |t|
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
abort "Versions don't match #{v} vs #{version}" if v != version
pkg = "pkg/#{name}-#{version}"
@@ -573,21 +556,21 @@
files = spec.files.grep(rdoc_pattern)
files -= ['Manifest.txt']
rd.rdoc_files.push(*files)
title = "#{name}-#{version} Documentation"
- title = "#{rubyforge_name}'s " + title if rubyforge_name != title
+ title = "#{rubyforge_name}'s " + title if rubyforge_name != name
rd.options << "-t #{title}"
end
- desc "Generate ri locally for testing"
+ desc 'Generate ri locally for testing.'
task :ridocs => :clean do
sh %q{ rdoc --ri -o ri . }
end
- desc "Publish RDoc to RubyForge"
+ desc 'Publish RDoc to RubyForge.'
task :publish_docs => [:clean, :docs] do
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
host = "#{config["username"]}@rubyforge.org"
remote_dir = "/var/www/gforge-projects/#{rubyforge_name}/#{remote_rdoc_dir}"
@@ -604,25 +587,25 @@
end
############################################################
# Misc/Maintenance:
- desc 'Run ZenTest against the package'
+ desc 'Run ZenTest against the package.'
task :audit do
libs = %w(lib test ext).join(File::PATH_SEPARATOR)
sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}"
end
- desc 'Clean up all the extras'
+ desc 'Clean up all the extras.'
task :clean => [ :clobber_docs, :clobber_package ] do
clean_globs.each do |pattern|
files = Dir[pattern]
rm_rf files unless files.empty?
end
end
- desc 'Create a fresh ~/.hoerc file'
+ desc 'Create a fresh ~/.hoerc file.'
task :config_hoe do
with_config do |config, path|
default_config = {
"exclude" => /tmp$|CVS|\.svn/,
"publish_on_announce" => false,
@@ -699,14 +682,14 @@
rf.login
rf.post_news(rubyforge_name, subject, "#{title}\n\n#{body}")
puts "Posted to rubyforge"
end
- desc 'Generate email announcement file and post to rubyforge.'
+ desc 'Create news email file and post to rubyforge.'
task :announce => [:email, :post_news, :post_blog, :publish_on_announce ]
- desc "Verify the manifest"
+ desc 'Verify the manifest.'
task :check_manifest => :clean do
f = "Manifest.tmp"
require 'find'
files = []
with_config do |config, _|
@@ -789,10 +772,10 @@
def run_tests(multi=false) # :nodoc:
msg = multi ? :sh : :ruby
cmd = if test ?f, 'test/test_all.rb' then
"#{RUBY_FLAGS} test/test_all.rb #{FILTER}"
else
- tests = test_globs.map { |g| Dir.glob(g) }.flatten << 'test/unit'
+ tests = ['test/unit'] + test_globs.map { |g| Dir.glob(g) }.flatten
tests.map! {|f| %Q(require "#{f}")}
"#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}"
end
cmd = "multiruby #{cmd}" if multi
send msg, cmd