lib/hoe.rb in hoe-1.5.1 vs lib/hoe.rb in hoe-1.5.2
- old
+ new
@@ -1,10 +1,9 @@
# -*- ruby -*-
require 'rubygems'
require 'rake'
-require 'rake/contrib/sshpublisher'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
require 'rbconfig'
require 'rubyforge'
@@ -62,12 +61,12 @@
# YAML formatted config file with the following settings:
#
# exclude:: A regular expression of files to exclude from
# +check_manifest+.
# publish_on_announce:: Run +publish_docs+ when you run +release+.
-# signing_key_file:: Signs your gems with this private key.
-# signing_cert_file:: Signs your gem with this certificate.
+# signing_key_file:: Signs your gems with this private key.
+# signing_cert_file:: Signs your gem with this certificate.
# blogs:: An array of hashes of blog settings.
#
# Run +config_hoe+ and see ~/.hoerc for examples.
#
# === Signing Gems:
@@ -114,11 +113,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.1'
+ VERSION = '1.5.2'
ruby_prefix = Config::CONFIG['prefix']
sitelibdir = Config::CONFIG['sitelibdir']
##
@@ -213,10 +212,15 @@
# Populated automatically from the manifest. List of library files.
attr_accessor :lib_files # :nodoc:
##
+ # Optional: Array of incompatible versions for multiruby filtering. Used as a regex.
+
+ attr_accessor :multiruby_skip
+
+ ##
# *MANDATORY*: The name of the release.
attr_accessor :name
##
@@ -228,10 +232,15 @@
# Optional: Should package create a zipfile? [default: false]
attr_accessor :need_zip
##
+ # Optional: A post-install message to be displayed when gem is installed.
+
+ attr_accessor :post_install_message
+
+ ##
# Optional: A regexp to match documentation files against the manifest.
attr_accessor :rdoc_pattern
##
@@ -298,50 +307,63 @@
self.clean_globs = %w(diff diff.txt email.txt ri
*.gem *~ **/*~ *.rbc **/*.rbc)
self.description_sections = %w(description)
self.email = []
self.extra_deps = []
+ self.multiruby_skip = []
self.need_tar = true
self.need_zip = false
self.rdoc_pattern = /^(lib|bin|ext)|txt$/
self.remote_rdoc_dir = name
self.rsync_args = '-av --delete'
self.rubyforge_name = name.downcase
self.spec_extras = {}
self.summary_sentences = 1
self.test_globs = ['test/**/test_*.rb']
+ self.post_install_message = nil
yield self if block_given?
# Intuit values:
- readme = File.read("README.txt").split(/^(=+ .*)$/)[1..-1]
+ def missing name
+ warn "** #{name} is missing or in the wrong format for auto-intuiting."
+ warn " run `sow blah` and look at its text files"
+ end
+
+ readme = File.read("README.txt").split(/^(=+ .*)$/)[1..-1] rescue ''
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 ||= 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"
+ missing 'README.txt'
end
+ self.changes ||= begin
+ h = File.read("History.txt")
+ h.split(/^(===.*)/)[1..2].join.strip
+ rescue
+ missing 'History.txt'
+ ''
+ 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
warn "Hoe #{field} value not set - Fix by 2008-04-01!"
self.send "#{field}=", "doofus"
else
- abort "Hoe #{field} value not set"
+ abort "Hoe #{field} value not set. aborting"
end
end
end
hoe_deps = {
@@ -443,10 +465,12 @@
s.rdoc_options = ['--main', 'README.txt']
s.extra_rdoc_files = s.files.grep(/txt$/)
s.has_rdoc = true
+ s.post_install_message = post_install_message
+
if test ?f, "test/test_all.rb" then
s.test_file = "test/test_all.rb"
else
s.test_files = Dir[*test_globs]
end
@@ -459,17 +483,15 @@
############################################################
# Allow automatic inclusion of compiled extensions
if ENV['INLINE'] then
s.platform = ENV['FORCE_PLATFORM'] || Gem::Platform::CURRENT
# name of the extension is CamelCase
- if name =~ /[A-Z]/
- # ClassName => class_name
- alternate_name = name.reverse.scan(%r/[A-Z]+|[^A-Z]*[A-Z]+?/).reverse.map { |word| word.reverse.downcase }.join('_')
- elsif name =~ /_/
- # class_name = ClassName
- alternate_name = name.strip.split(/\s*_+\s*/).map! { |w| w.downcase.sub(/^./) { |c| c.upcase } }.join
- end
+ alternate_name = if name =~ /[A-Z]/ then
+ name.gsub(/([A-Z])/, '_\1').downcase.sub(/^_/, '')
+ elsif name =~ /_/ then
+ name.capitalize.gsub(/_([a-z])/) { $1.upcase }
+ end
# Try collecting Inline extensions for +name+
if defined?(Inline) then
directory 'lib/inline'
@@ -597,11 +619,11 @@
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?
+ rm_rf files, :verbose => true unless files.empty?
end
end
desc 'Create a fresh ~/.hoerc file.'
task :config_hoe do
@@ -691,11 +713,12 @@
task :check_manifest => :clean do
f = "Manifest.tmp"
require 'find'
files = []
with_config do |config, _|
- exclusions = config["exclude"] || /tmp$|CVS|\.svn/
+ exclusions = config["exclude"]
+ abort "exclude entry missing from .hoerc. Aborting." if exclusions.nil?
Find.find '.' do |path|
next unless File.file? path
next if path =~ exclusions
files << path[2..-1]
end
@@ -776,10 +799,14 @@
else
tests = ['test/unit'] + test_globs.map { |g| Dir.glob(g) }.flatten
tests.map! {|f| %Q(require "#{f}")}
"#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}"
end
+
+ excludes = multiruby_skip.join(":")
+ ENV['EXCLUDED_VERSIONS'] = excludes
cmd = "multiruby #{cmd}" if multi
+
send msg, cmd
end
##
# Reads a file at +path+ and spits out an array of the +paragraphs+ specified.