lib/hoe.rb in hoe-2.16.1 vs lib/hoe.rb in hoe-3.0.0

- old
+ new

@@ -66,17 +66,34 @@ # # def define_blah_tasks # # ... # end # end +# +# === Hoe Plugin Loading Sequence +# +# Hoe.spec +# Hoe.load_plugins +# require +# activate_plugins +# extend plugin_module +# initialize_plugins +# initialize_XXX +# activate_plugin_deps +# activate_XXX_deps +# yield spec +# post_initialize +# define_spec # gemspec, not hoespec +# load_plugin_tasks +# add_dependencies class Hoe include Rake::DSL if defined?(Rake::DSL) # duh - VERSION = '2.16.1' + VERSION = '3.0.0' @@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package, :publish, :gemcutter, :signing, :test] @bad_plugins = [] @@ -225,10 +242,15 @@ # README.txt. # attr_accessor :url + require 'rubygems/deprecate' + extend Gem::Deprecate + deprecate :url, :urls, 2012, 6 + deprecate :url=, :urls=, 2012, 6 + ## # Optional: The urls of the project. This can be an array or # (preferably) a hash. Auto-populates to the urls read from the # beginning of README.txt. # @@ -373,17 +395,30 @@ next unless Hoe.plugins.include? name.downcase.intern warn "extend #{name}" if $DEBUG self.extend Hoe.const_get(name) end + initialize_plugins + activate_plugin_deps + end + + def initialize_plugins Hoe.plugins.each do |plugin| msg = "initialize_#{plugin}" warn msg if $DEBUG send msg if self.respond_to? msg end end + def activate_plugin_deps + Hoe.plugins.each do |plugin| + msg = "activate_#{plugin}_deps" + warn msg if $DEBUG + send msg if self.respond_to? msg + end + end + ## # Add a dependency declaration to your spec. Pass :dev to # +type+ for developer dependencies. def dependency name, version, type = :runtime @@ -456,11 +491,18 @@ s.name = name s.version = version if version s.summary = summary s.email = email - s.homepage = Array(url).first + s.homepage = case urls + when Hash then + urls["home"] || urls.values.first + when Array then + urls + else + raise "unknown urls format: #{urls.inspect}" + end s.rubyforge_project = rubyforge_name s.description = description s.files = manifest s.executables = s.files.grep(/^bin/) { |f| File.basename(f) } s.bindir = "bin" @@ -530,13 +572,11 @@ rescue Gem::LoadError false end ## - # Create a newly initialized hoe spec. If a block is given, yield on - # it and finish post_initialize steps. This is deprecated behavior - # and should be switched from Hoe.new to Hoe.spec. + # Create a newly initialized hoe spec. def initialize name, version = nil # :nodoc: self.name = name self.version = version @@ -553,27 +593,20 @@ self.spec = nil self.spec_extras = {} self.summary = nil self.summary_sentences = 1 self.test_globs = ['test/**/test_*.rb'] - self.url = nil if manifest = read_manifest then self.readme_file = manifest.grep(/^README\./).first self.history_file = manifest.grep(/^History\./).first end self.history_file ||= "History.txt" self.readme_file ||= "README.txt" - if block_given? then - warn "Hoe.new {...} deprecated. Switch to Hoe.spec." - Hoe.load_plugins - self.activate_plugins - yield self - post_initialize - end + abort "Hoe.new {...} removed. Switch to Hoe.spec." if block_given? end ## # Intuit values from the readme and history files. @@ -590,18 +623,10 @@ urls = parse_urls(readme[1]) self.urls ||= urls self.description ||= desc self.summary ||= summ - self.url ||= case urls - when Hash then - urls["home"] || urls["repo"] || urls.values.first - when Array then - urls - else - raise "unknown urls format: #{urls.inspect}" - end else missing readme_file end self.changes ||= begin @@ -679,17 +704,16 @@ ## # Normalize the dependencies. def normalize_deps deps - Array(deps).map { |o| - if String === o then - warn "WAR\NING: HOE DEPRECATION: Add '>= 0' to the '#{o}' dependency." - [o, ">= 0"] - else - o - end - } + deps = Array(deps) + + deps.each do |o| + abort "ERROR: Add '~> x.y' to the '#{o}' dependency." if String === o + end + + deps end ## # Reads a file at +path+ and spits out an array of the +paragraphs+ specified. #