lib/hoe.rb in hoe-1.6.0 vs lib/hoe.rb in hoe-1.7.0
- old
+ new
@@ -7,10 +7,15 @@
require 'rake/testtask'
require 'rbconfig'
require 'rubyforge'
require 'yaml'
+begin
+ gem 'rdoc'
+rescue Gem::LoadError
+end
+
##
# hoe - a tool to help rake
#
# Hoe is a simple rake/rubygems helper for project Rakefiles. It
# generates all the usual tasks for projects including rdoc generation,
@@ -113,11 +118,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.6.0'
+ VERSION = '1.7.0'
ruby_prefix = Config::CONFIG['prefix']
sitelibdir = Config::CONFIG['sitelibdir']
##
@@ -212,10 +217,15 @@
# Optional: An array of rubygem dependencies.
attr_accessor :extra_deps
##
+ # Optional: An array of rubygem developer dependencies.
+
+ attr_accessor :extra_dev_deps
+
+ ##
# Populated automatically from the manifest. List of library files.
attr_accessor :lib_files # :nodoc:
##
@@ -301,10 +311,19 @@
##
# *MANDATORY*: The version. Don't hardcode! use a constant in the project.
attr_accessor :version
+ def normalize_deps deps
+ Array(deps).map { |o| String === o ? [o] : o }
+ end
+
+ 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
+
def initialize(name, version) # :nodoc:
self.name = name
self.version = version
# Defaults
@@ -313,10 +332,11 @@
*.gem *~ **/*~ *.rbc **/*.rbc)
self.description_sections = %w(description)
self.blog_categories = [name]
self.email = []
self.extra_deps = []
+ self.extra_dev_deps = []
self.multiruby_skip = []
self.need_tar = true
self.need_zip = false
self.rdoc_pattern = /^(lib|bin|ext)|txt$/
self.remote_rdoc_dir = name
@@ -329,15 +349,10 @@
yield self if block_given?
# Intuit values:
- 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
}
@@ -375,36 +390,37 @@
hoe_deps = {
'rake' => ">= #{RAKEVERSION}",
'rubyforge' => ">= #{::RubyForge::VERSION}",
}
- self.extra_deps = Array(extra_deps).map { |o| String === o ? [o] : o }
+ self.extra_deps = normalize_deps extra_deps
+ self.extra_dev_deps = normalize_deps extra_dev_deps
if name == 'hoe' then
hoe_deps.each do |pkg, vers|
extra_deps << [pkg, vers]
end
else
- extra_deps << ['hoe', ">= #{VERSION}"] unless hoe_deps.has_key? name
+ extra_dev_deps << ['hoe', ">= #{VERSION}"] unless hoe_deps.has_key? name
end
define_tasks
end
def developer name, email
self.author << name
self.email << email
end
- def define_tasks # :nodoc:
- def with_config # :nodoc:
- rc = File.expand_path("~/.hoerc")
- exists = File.exist? rc
- config = exists ? YAML.load_file(rc) : {}
- yield(config, rc)
- end
+ def with_config # :nodoc:
+ rc = File.expand_path("~/.hoerc")
+ exists = File.exist? rc
+ config = exists ? YAML.load_file(rc) : {}
+ yield(config, rc)
+ end
+ def define_tasks # :nodoc:
desc 'Run the default tasks.'
task :default => :test
desc 'Run the test suite. Use FILTER to add to the command line.'
task :test do
@@ -458,9 +474,13 @@
s.description = description
extra_deps.each do |dep|
s.add_dependency(*dep)
+ end
+
+ extra_dev_deps.each do |dep|
+ s.add_development_dependency(*dep)
end
s.files = File.read("Manifest.txt").delete("\r").split(/\n/)
s.executables = s.files.grep(/^bin/) { |f| File.basename(f) }