hoe 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data.tar.gz.sig CHANGED
Binary file
File without changes
@@ -1,3 +1,26 @@
1
+ === 2.9.0 / 2011-01-31
2
+
3
+ * 11 minor enhancements:
4
+
5
+ * Added Hoe::Package#pkg_path to make package hook writing easier.
6
+ * Added Hoe::Test#test_prelude to allow for code to run before test loading.
7
+ * Added plugin?(name) to allow for easier plugin guarding in hoe spec.
8
+ * Added support for multiple template dirs for sow.
9
+ * Added support for rubygems-test. See http://www.gem-testers.org/
10
+ * Clean up sow a LOT using: include FileUtils::Verbose
11
+ * Don't warn about missing plugins without rake -t
12
+ * Hoe requires Gem::PackageTask from RubyGems 1.4+
13
+ * Moved post_news from publish to rubyforge
14
+ * Plugins can now be loaded from a +plugins+ array in ~/.hoerc
15
+ * rubyforge plugin now uses plain globs to push. Fixes releases for rubygems itself
16
+
17
+ * 4 bug fixes:
18
+
19
+ * Failed plugins should notify on both trace and debug.
20
+ * Fixed rdoc_dir for custom rdoc locations
21
+ * Fixed require 'rubyforge' that was too late
22
+ * Fixed sow to properly rename dirs depth first
23
+
1
24
  === 2.8.0 / 2010-12-08
2
25
 
3
26
  * 6 minor enhancements:
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Hoe.spec "hoe" do
16
16
  blog_categories << "Seattle.rb" << "Ruby"
17
17
 
18
18
  pluggable!
19
- require_ruby_version '>= 1.3.6'
19
+ require_rubygems_version '>= 1.4'
20
20
  end
21
21
 
22
22
  task :plugins do
data/bin/sow CHANGED
@@ -1,21 +1,50 @@
1
- #!/usr/bin/env ruby -ws
2
-
3
- $h ||= false
4
- $t ||= false
5
- $d ||= false
1
+ #!/usr/bin/env ruby -w
6
2
 
3
+ require 'optparse'
7
4
  require 'rubygems'
8
5
  require 'hoe'
9
6
  require 'fileutils'
10
7
  require 'erb'
11
8
 
12
- if $h || ARGV.empty? || ($t && $d) then
13
- puts "usage: #{File.basename $0} [-d|-t] project"
14
- puts " -t = add project to subdir under 'trunk'"
15
- puts " -d = add project to subdir under 'dev'"
16
- exit
9
+ option = {
10
+ :style => "default",
11
+ :subdir => nil,
12
+ }
13
+
14
+ def check_subdir
15
+ if option[:subdir] then
16
+ warn "ERROR: you can't specify multiple subdirs"
17
+ abort opts.to_s
18
+ end
17
19
  end
18
20
 
21
+ OptionParser.new do |opts|
22
+ opts.separator "Standard options:"
23
+
24
+ opts.on("-t", "--trunk", "Add project to subdir under 'trunk'.") do
25
+ check_subdir
26
+ option[:subdir] = "trunk"
27
+ end
28
+
29
+ opts.on("-d", "--dev", "Add project to subdir under 'dev'.") do
30
+ check_subdir
31
+ option[:subdir] = "dev"
32
+ end
33
+
34
+ opts.on("-s style", "--style style", String, "Use template <style>.") do |s|
35
+ option[:style] = s
36
+ end
37
+
38
+ opts.on("-h", "--help", "Show this message.") do
39
+ puts opts
40
+ exit
41
+ end
42
+ end.parse!
43
+
44
+ # TODO: fail if both dev and trunk
45
+
46
+ include FileUtils::Verbose
47
+
19
48
  project = ARGV.shift
20
49
 
21
50
  abort "Project #{project} seems to exist" if test ?d, project
@@ -23,24 +52,36 @@ abort "Project #{project} seems to exist" if test ?d, project
23
52
  # variables for erb:
24
53
  XIF = 'FI' + 'X' # prevents extra hits on my TAG reporter
25
54
  project, file_name, klass = Hoe.normalize_names project
26
- template_path = File.expand_path("~/.hoe_template")
55
+ template_dir = File.expand_path("~/.hoe_template")
56
+ template_path = File.join template_dir, option[:style]
27
57
  source_path = File.join(File.dirname(File.dirname(__FILE__)),
28
58
  "template")
29
59
 
60
+ default_dir = File.join template_dir, "default"
61
+ if File.directory? template_dir and not File.directory? default_dir then
62
+ warn "Detected old #{template_dir}"
63
+ warn "Moving to #{default_dir}"
64
+ tmp = "#{template_dir}.#{$$}"
65
+ File.rename template_dir, tmp
66
+ FileUtils.mkdir template_dir
67
+ File.rename tmp, default_dir
68
+ end
69
+
30
70
  unless File.directory? template_path then
31
- FileUtils.cp_r source_path, template_path, :verbose => true
71
+ warn "Creating missing #{option[:style]} template."
72
+ FileUtils.cp_r source_path, template_path
32
73
  paths = (Dir["#{template_path}/**/*"] +
33
74
  Dir["#{template_path}/**/.*"]).select { |f| File.file? f }
34
- FileUtils.chmod 0644, paths, :verbose => true
35
- FileUtils.chmod 0755, paths.grep(/bin\//), :verbose => true
75
+ FileUtils.chmod 0644, paths
76
+ FileUtils.chmod 0755, paths.grep(/bin\//)
36
77
  end
37
78
 
38
- FileUtils.cp_r template_path, project, :verbose => true
79
+ FileUtils.cp_r template_path, project
39
80
 
40
81
  Dir.chdir project do
41
- dirs = Dir["**/*"].select { |f| File.directory? f }.sort
42
- dirs.grep(/file_name/).each do |file|
43
- FileUtils.mv file, file.gsub(/file_name/, file_name), :verbose => true
82
+ dirs = Dir["**/*"].select { |f| File.directory? f }.sort.reverse
83
+ dirs.grep(/file_name$/).each do |file|
84
+ FileUtils.mv file, file.sub(/file_name$/, file_name)
44
85
  end
45
86
 
46
87
  paths = (Dir["**/*"] + Dir["**/.*"]).select { |f| File.file? f }.sort
@@ -56,15 +97,15 @@ Dir.chdir project do
56
97
 
57
98
  paths.grep(/file_name|\.erb$/).each do |file|
58
99
  new_file = file.sub(/file_name/, file_name).sub(/\.erb$/, '')
59
- FileUtils.mv file, new_file, :verbose => true
100
+ FileUtils.mv file, new_file
60
101
  end
61
102
  end
62
103
 
63
- if $d || $t then
104
+ if option[:dev] || option[:trunk] then
64
105
  temp_dir = "#{project}.#{$$}"
65
- FileUtils.mv project, temp_dir, :verbose => true
66
- FileUtils.mkdir project, :verbose => true
67
- FileUtils.mv temp_dir, "#{project}/#{$d ? 'dev' : 'trunk'}", :verbose => true
106
+ FileUtils.mv project, temp_dir
107
+ FileUtils.mkdir project
108
+ FileUtils.mv temp_dir, "#{project}/#{option[:dev] ? 'dev' : 'trunk'}"
68
109
  end
69
110
 
70
111
  puts
data/lib/hoe.rb CHANGED
@@ -58,7 +58,7 @@ require 'hoe/rake'
58
58
 
59
59
  class Hoe
60
60
  # duh
61
- VERSION = '2.8.0'
61
+ VERSION = '2.9.0'
62
62
 
63
63
  @@plugins = [:clean, :debug, :deps, :flay, :flog, :newb, :package,
64
64
  :publish, :rcov, :gemcutter, :signing, :test]
@@ -228,23 +228,26 @@ class Hoe
228
228
  #
229
229
  # It is called at the end of hoe.rb
230
230
 
231
- def self.load_plugins
232
- loaded, found = {}, {}
231
+ def self.load_plugins plugins = Hoe.plugins
232
+ @found ||= {}
233
+ @loaded ||= {}
233
234
 
234
235
  Gem.find_files("hoe/*.rb").reverse.each do |path|
235
- found[File.basename(path, ".rb").intern] = path
236
+ @found[File.basename(path, ".rb").intern] = path
236
237
  end
237
238
 
238
- :keep_doing_this while found.map { |name, plugin|
239
- next unless Hoe.plugins.include? name
240
- next if loaded[name]
239
+ :keep_doing_this while @found.map { |name, plugin|
240
+ next unless plugins.include? name
241
+ next if @loaded[name]
241
242
  begin
242
243
  warn "loading #{plugin}" if $DEBUG
243
- loaded[name] = load plugin
244
+ @loaded[name] = require plugin
244
245
  rescue LoadError => e
245
246
  warn "error loading #{plugin.inspect}: #{e.message}. skipping..."
246
247
  end
247
248
  }.any?
249
+
250
+ return @loaded, @found
248
251
  end
249
252
 
250
253
  ##
@@ -261,15 +264,20 @@ class Hoe
261
264
  end
262
265
 
263
266
  ##
264
- # Activate plugins.
267
+ # Activates +plugins+. If a plugin cannot be loaded it will be ignored.
268
+ #
269
+ # Plugins may also be activated through a +plugins+ array in
270
+ # <tt>~/.hoerc</tt>. This should only be used for plugins that aren't
271
+ # critical to your project and plugins that you want to use on other
272
+ # projects.
265
273
 
266
- def self.plugin *names
267
- self.plugins.concat names
274
+ def self.plugin *plugins
275
+ self.plugins.concat plugins
268
276
  self.plugins.uniq!
269
277
  end
270
278
 
271
279
  ##
272
- # Return the list of activated plugins.
280
+ # The list of active plugins.
273
281
 
274
282
  def self.plugins
275
283
  @@plugins
@@ -298,11 +306,21 @@ class Hoe
298
306
  # Activate plugin modules and add them to the current instance.
299
307
 
300
308
  def activate_plugins
301
- names = self.class.constants.map { |s| s.to_s }
309
+ plugins = Hoe.plugins
310
+
311
+ with_config do |config, _|
312
+ config_plugins = config['plugins']
313
+ break unless config_plugins
314
+ plugins += config_plugins.map { |plugin| plugin.intern }
315
+ end
316
+
317
+ Hoe.load_plugins plugins
318
+
319
+ names = Hoe.constants.map { |s| s.to_s }
302
320
  names.reject! { |n| n =~ /^[A-Z_]+$/ }
303
321
 
304
322
  names.each do |name|
305
- next unless Hoe.plugins.include? name.downcase.intern
323
+ next unless plugins.include? name.downcase.intern
306
324
  warn "extend #{name}" if $DEBUG
307
325
  self.extend Hoe.const_get(name)
308
326
  end
@@ -506,7 +524,9 @@ class Hoe
506
524
  begin
507
525
  send "define_#{plugin}_tasks"
508
526
  rescue NoMethodError => e
509
- warn "warning: couldn't activate the #{plugin} plugin, skipping"
527
+ warn "warning: couldn't activate the #{plugin} plugin, skipping" if
528
+ Rake.application.options.trace or $DEBUG
529
+
510
530
  bad << plugin
511
531
  next
512
532
  end
@@ -561,6 +581,20 @@ class Hoe
561
581
  require_rubygems_version '>= 1.3.1'
562
582
  end
563
583
 
584
+ ##
585
+ # Is a plugin activated? Used for guarding missing plugins in your
586
+ # hoe spec:
587
+ #
588
+ # Hoe.spec "blah" do
589
+ # if plugin? :enhancement then
590
+ # self.enhancement = true # or whatever...
591
+ # end
592
+ # end
593
+
594
+ def plugin? name
595
+ self.class.plugins.include? name
596
+ end
597
+
564
598
  ##
565
599
  # Finalize configuration
566
600
 
@@ -610,9 +644,9 @@ class Hoe
610
644
  end
611
645
 
612
646
  ##
613
- # Load or create a default config and yield it
647
+ # Loads ~/.hoerc and yields the configuration and its path
614
648
 
615
- def with_config # :nodoc:
649
+ def with_config
616
650
  rc = File.expand_path("~/.hoerc")
617
651
  exists = File.exist? rc
618
652
  config = exists ? YAML.load_file(rc) : {}
@@ -72,6 +72,14 @@ module Hoe::Package
72
72
  end
73
73
  end
74
74
 
75
+ ##
76
+ # Returns the path used for packaging. Convenience method for those
77
+ # that need to write a package hook.
78
+
79
+ def pkg_path
80
+ "pkg/#{spec.full_name}"
81
+ end
82
+
75
83
  ##
76
84
  # Install the named gem.
77
85
 
@@ -100,7 +100,7 @@ module Hoe::Publish
100
100
  rd.main = readme_file
101
101
  rd.options << '-d' if (`which dot` =~ /\/dot/) unless
102
102
  ENV['NODOT'] || Hoe::WINDOZE
103
- rd.rdoc_dir = 'doc'
103
+ rd.rdoc_dir = local_rdoc_dir
104
104
 
105
105
  rd.rdoc_files += spec.require_paths
106
106
  rd.rdoc_files += spec.extra_rdoc_files
@@ -173,17 +173,6 @@ module Hoe::Publish
173
173
  end
174
174
  end
175
175
 
176
- desc 'Post announcement to rubyforge.'
177
- task :post_news do
178
- require 'rubyforge'
179
- subject, title, body, urls = announcement
180
-
181
- rf = RubyForge.new.configure
182
- rf.login
183
- rf.post_news(rubyforge_name, subject, "#{title}\n\n#{body}")
184
- puts "Posted to rubyforge"
185
- end
186
-
187
176
  desc 'Announce your release.'
188
177
  task :announce => [:post_blog, :publish_on_announce ]
189
178
  end
@@ -10,6 +10,8 @@
10
10
 
11
11
  module Hoe::RubyForge
12
12
  def initialize_rubyforge
13
+ require 'rubyforge'
14
+
13
15
  dependency_target << ['rubyforge', ">= #{::RubyForge::VERSION}"]
14
16
  end
15
17
 
@@ -19,8 +21,6 @@ module Hoe::RubyForge
19
21
 
20
22
  desc 'Release to rubyforge.'
21
23
  task :release_to_rubyforge => [:clean, :package, :release_sanity] do
22
- require 'rubyforge'
23
-
24
24
  rf = RubyForge.new.configure
25
25
  puts "Logging in"
26
26
  rf.login
@@ -30,12 +30,12 @@ module Hoe::RubyForge
30
30
  c["release_changes"] = changes if changes
31
31
  c["preformatted"] = true
32
32
 
33
- pkg = "pkg/#{name}-#{version}"
34
- files = [(@need_tar ? "#{pkg}.tgz" : nil),
35
- (@need_zip ? "#{pkg}.zip" : nil),
36
- Dir["#{pkg}*.gem"]].flatten.compact
33
+ files = [(@need_tar ? Dir["pkg/*.tgz"] : nil),
34
+ (@need_zip ? Dir["pkg/*.zip"] : nil),
35
+ Dir["pkg/*.gem"]].flatten.compact
37
36
 
38
37
  puts "Releasing #{name} v. #{version}"
38
+
39
39
  rf.add_release rubyforge_name, name, version, *files
40
40
  end
41
41
 
@@ -50,6 +50,17 @@ module Hoe::RubyForge
50
50
  else
51
51
  warn "Couldn't read #{path}. Run `rubyforge setup`."
52
52
  end
53
+
54
+ desc 'Post announcement to rubyforge.'
55
+ task :post_news do
56
+ require 'rubyforge'
57
+ subject, title, body, urls = announcement
58
+
59
+ rf = RubyForge.new.configure
60
+ rf.login
61
+ rf.post_news(rubyforge_name, subject, "#{title}\n\n#{body}")
62
+ puts "Posted to rubyforge"
63
+ end
53
64
  end
54
65
  end
55
66
  end
@@ -36,6 +36,11 @@ module Hoe::Test
36
36
 
37
37
  attr_accessor :testlib
38
38
 
39
+ ##
40
+ # Optional: Additional ruby to run before the test framework is loaded.
41
+
42
+ attr_accessor :test_prelude
43
+
39
44
  ##
40
45
  # Optional: RSpec dirs. [default: %w(spec lib)]
41
46
 
@@ -52,6 +57,7 @@ module Hoe::Test
52
57
  def initialize_test
53
58
  self.multiruby_skip ||= []
54
59
  self.testlib ||= :testunit
60
+ self.test_prelude ||= nil
55
61
  self.rspec_dirs ||= %w(spec lib)
56
62
  self.rspec_options ||= []
57
63
  end
@@ -125,6 +131,23 @@ module Hoe::Test
125
131
  desc 'Run the default task(s).'
126
132
  task :default => default_tasks
127
133
 
134
+ unless default_tasks.empty? then
135
+ ##
136
+ # This is for Erik Hollensbe's rubygems-test project. Hoe is
137
+ # test-happy, so by using this plugin you're already testable. For
138
+ # more information, see: <https://github.com/erikh/rubygems-test>
139
+ # and/or <http://www.gem-testers.org/>
140
+
141
+ self.spec.files += [".gemtest"]
142
+
143
+ pkg = pkg_path
144
+ turd = "#{pkg}/.gemtest"
145
+
146
+ task pkg do
147
+ touch turd
148
+ end
149
+ end
150
+
128
151
  desc 'Run ZenTest against the package.'
129
152
  task :audit do
130
153
  libs = %w(lib test ext).join(File::PATH_SEPARATOR)
@@ -143,6 +166,8 @@ module Hoe::Test
143
166
  test_globs.map { |g| Dir.glob(g) }.flatten
144
167
  tests.map! {|f| %(require "#{f}")}
145
168
 
169
+ tests.insert 1, test_prelude if test_prelude
170
+
146
171
  cmd = "#{Hoe::RUBY_FLAGS} -e '#{tests.join("; ")}' -- #{FILTER}"
147
172
 
148
173
  if multi then
@@ -9,6 +9,59 @@ class TestHoe < MiniTest::Unit::TestCase
9
9
  Rake.application.clear
10
10
  end
11
11
 
12
+ def test_class_load_plugins
13
+ loaded, = Hoe.load_plugins
14
+
15
+ assert_includes loaded.keys, :clean
16
+ assert_includes loaded.keys, :debug
17
+ assert_includes loaded.keys, :deps
18
+ end
19
+
20
+ def test_activate_plugins
21
+ hoe = Hoe.spec 'blah' do
22
+ developer 'author', 'email'
23
+ end
24
+
25
+ initializers = hoe.methods.grep(/^initialize/)
26
+
27
+ assert_includes initializers, 'initialize_clean'
28
+ assert_includes initializers, 'initialize_flay'
29
+ assert_includes initializers, 'initialize_flog'
30
+ assert_includes initializers, 'initialize_package'
31
+ assert_includes initializers, 'initialize_publish'
32
+ assert_includes initializers, 'initialize_test'
33
+ end
34
+
35
+ def test_activate_plugins_hoerc
36
+ home = ENV['HOME']
37
+ load_path = $LOAD_PATH.dup
38
+
39
+ Dir.mktmpdir do |path|
40
+ ENV['HOME'] = path
41
+ $LOAD_PATH << path
42
+
43
+ Dir.mkdir File.join(path, 'hoe')
44
+ open File.join(path, 'hoe', 'hoerc.rb'), 'w' do |io|
45
+ io.write 'module Hoe::Hoerc; def initialize_hoerc; end; end'
46
+ end
47
+
48
+ open File.join(path, '.hoerc'), 'w' do |io|
49
+ io.write YAML.dump 'plugins' => %w[hoerc]
50
+ end
51
+
52
+ spec = Hoe.spec 'blah' do
53
+ developer 'author', 'email'
54
+ end
55
+
56
+ assert_includes spec.methods.grep(/^initialize/), 'initialize_hoerc'
57
+ end
58
+ ensure
59
+ Hoe.instance_variable_get(:@loaded).delete :hoerc
60
+ Hoe.plugins.delete :hoerc
61
+ $LOAD_PATH.replace load_path
62
+ ENV['HOME'] = home
63
+ end
64
+
12
65
  def test_file_read_utf
13
66
  Tempfile.open 'BOM' do |io|
14
67
  io.write "\xEF\xBB\xBFBOM"
@@ -24,7 +77,7 @@ class TestHoe < MiniTest::Unit::TestCase
24
77
  developer 'author', 'email'
25
78
  end
26
79
 
27
- files = File.read("Manifest.txt").split(/\n/)
80
+ files = File.read("Manifest.txt").split(/\n/) + [".gemtest"]
28
81
 
29
82
  spec = hoe.spec
30
83
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoe
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 43
5
+ prerelease:
5
6
  segments:
6
7
  - 2
7
- - 8
8
+ - 9
8
9
  - 0
9
- version: 2.8.0
10
+ version: 2.9.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Ryan Davis
@@ -35,16 +36,18 @@ cert_chain:
35
36
  FBHgymkyj/AOSqKRIpXPhjC6
36
37
  -----END CERTIFICATE-----
37
38
 
38
- date: 2010-12-08 00:00:00 -08:00
39
+ date: 2011-01-31 00:00:00 -08:00
39
40
  default_executable:
40
41
  dependencies:
41
42
  - !ruby/object:Gem::Dependency
42
43
  name: rake
43
44
  prerelease: false
44
45
  requirement: &id001 !ruby/object:Gem::Requirement
46
+ none: false
45
47
  requirements:
46
48
  - - ">="
47
49
  - !ruby/object:Gem::Version
50
+ hash: 49
48
51
  segments:
49
52
  - 0
50
53
  - 8
@@ -56,14 +59,16 @@ dependencies:
56
59
  name: minitest
57
60
  prerelease: false
58
61
  requirement: &id002 !ruby/object:Gem::Requirement
62
+ none: false
59
63
  requirements:
60
64
  - - ">="
61
65
  - !ruby/object:Gem::Version
66
+ hash: 11
62
67
  segments:
63
68
  - 2
64
69
  - 0
65
- - 0
66
- version: 2.0.0
70
+ - 2
71
+ version: 2.0.2
67
72
  type: :development
68
73
  version_requirements: *id002
69
74
  description: |-
@@ -124,6 +129,7 @@ files:
124
129
  - template/test/test_file_name.rb.erb
125
130
  - test/test_hoe.rb
126
131
  - test/test_hoe_gemcutter.rb
132
+ - .gemtest
127
133
  has_rdoc: true
128
134
  homepage: http://rubyforge.org/projects/seattlerb/
129
135
  licenses: []
@@ -135,27 +141,28 @@ rdoc_options:
135
141
  require_paths:
136
142
  - lib
137
143
  required_ruby_version: !ruby/object:Gem::Requirement
144
+ none: false
138
145
  requirements:
139
146
  - - ">="
140
147
  - !ruby/object:Gem::Version
148
+ hash: 3
141
149
  segments:
142
- - 1
143
- - 3
144
- - 6
145
- version: 1.3.6
150
+ - 0
151
+ version: "0"
146
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
+ none: false
147
154
  requirements:
148
155
  - - ">="
149
156
  - !ruby/object:Gem::Version
157
+ hash: 7
150
158
  segments:
151
159
  - 1
152
- - 3
153
- - 1
154
- version: 1.3.1
160
+ - 4
161
+ version: "1.4"
155
162
  requirements: []
156
163
 
157
164
  rubyforge_project: seattlerb
158
- rubygems_version: 1.3.6
165
+ rubygems_version: 1.4.2
159
166
  signing_key:
160
167
  specification_version: 3
161
168
  summary: Hoe is a rake/rubygems helper for project Rakefiles
metadata.gz.sig CHANGED
Binary file