hoe 1.8.3 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,20 @@
1
+ === 1.9.0 / 2009-02-26:
2
+
3
+ * 7 minor enhancements:
4
+
5
+ * Added flog, flay, and rdoc tasks.
6
+ * Added ~/.hoe_template and basic erb templating to sow.
7
+ * install_gem automatically installs missing dependencies. From Dr. Nic.
8
+ * Parameterized history and readme paths for github users (*sigh*).
9
+ * Added rspec support including having both tests and specs.
10
+ * Match RubyGems' RDoc behavior and removed rdoc_pattern attribute. Use
11
+ extra_rdoc_files instead.
12
+ * Added testlib and SUPPORTED_TEST_FRAMEWORKS to switch your testing library.
13
+
14
+ * 1 bug fix:
15
+
16
+ * Fixed rdoc title command-line parameters.
17
+
1
18
  === 1.8.3 / 2009-01-20:
2
19
 
3
20
  * 1 minor enhancement:
@@ -4,4 +4,12 @@ README.txt
4
4
  Rakefile
5
5
  bin/sow
6
6
  lib/hoe.rb
7
+ template/.autotest.erb
8
+ template/History.txt.erb
9
+ template/Manifest.txt.erb
10
+ template/README.txt.erb
11
+ template/Rakefile.erb
12
+ template/bin/file_name.erb
13
+ template/lib/file_name.rb.erb
14
+ template/test/test_file_name.rb.erb
7
15
  test/test_hoe.rb
data/README.txt CHANGED
@@ -12,31 +12,35 @@ testing, packaging, and deployment.
12
12
 
13
13
  Tasks Provided:
14
14
 
15
- * announce - Create news email file and post to rubyforge.
16
- * audit - Run ZenTest against the package.
17
- * check_manifest - Verify the manifest.
18
- * clean - Clean up all the extras.
19
- * config_hoe - Create a fresh ~/.hoerc file.
20
- * debug_gem - Show information about the gem.
21
- * default - Run the default tasks.
22
- * deps:email - Print a contact list for gems dependent on this gem
23
- * deps:fetch - Fetch all the dependent gems of this gem into tarballs
24
- * deps:list - List all the dependent gems of this gem
25
- * docs - Build the docs HTML Files
26
- * email - Generate email announcement file.
27
- * gem - Build the gem file hoe-1.8.0.gem
28
- * generate_key - Generate a key for signing your gems.
29
- * install_gem - Install the package as a gem.
30
- * multi - Run the test suite using multiruby.
31
- * package - Build all the packages
32
- * post_blog - Post announcement to blog.
33
- * post_news - Post announcement to rubyforge.
34
- * publish_docs - Publish RDoc to RubyForge.
35
- * release - Package and upload the release to rubyforge.
36
- * ridocs - Generate ri locally for testing.
37
- * tasks - Generate a list of tasks for doco.
38
- * test - Run the test suite.
39
- * test_deps - Show which test files fail when run alone.
15
+ * announce - Create news email file and post to rubyforge.
16
+ * audit - Run ZenTest against the package.
17
+ * check_extra_deps - Install missing dependencies.
18
+ * check_manifest - Verify the manifest.
19
+ * clean - Clean up all the extras.
20
+ * config_hoe - Create a fresh ~/.hoerc file.
21
+ * debug_gem - Show information about the gem.
22
+ * default - Run the default task(s).
23
+ * deps:email - Print a contact list for gems dependent on this gem
24
+ * deps:fetch - Fetch all the dependent gems of this gem into tarballs
25
+ * deps:list - List all the dependent gems of this gem
26
+ * docs - Build the docs HTML Files
27
+ * email - Generate email announcement file.
28
+ * flay - Analyze for code duplication.
29
+ * flog - Analyze code complexity.
30
+ * gem - Build the gem file hoe-1.9.0.gem
31
+ * generate_key - Generate a key for signing your gems.
32
+ * install_gem - Install the package as a gem.
33
+ * multi - Run the test suite using multiruby.
34
+ * package - Build all the packages
35
+ * post_blog - Post announcement to blog.
36
+ * post_news - Post announcement to rubyforge.
37
+ * publish_docs - Publish RDoc to RubyForge.
38
+ * rcov - Analyze code coverage with tests
39
+ * release - Package and upload the release to rubyforge.
40
+ * ridocs - Generate ri locally for testing.
41
+ * tasks - Generate a list of tasks for doco.
42
+ * test - Run the test suite.
43
+ * test_deps - Show which test files fail when run alone.
40
44
 
41
45
  See class rdoc for help. Hint: ri Hoe
42
46
 
data/bin/sow CHANGED
@@ -1,69 +1,78 @@
1
1
  #!/usr/bin/env ruby -ws
2
2
 
3
+ $h ||= false
3
4
  $t ||= false
4
5
  $d ||= false
5
6
 
6
7
  require 'rubygems'
7
8
  require 'hoe'
9
+ require 'fileutils'
10
+ require 'erb'
8
11
 
9
- if defined? $h then
10
- puts "usage: #{File.dirname($0)} [-d|-t] project"
12
+ if $h || ARGV.empty? || ($t && $d) then
13
+ puts "usage: #{File.dirname $0} [-d|-t] project"
11
14
  puts " -t = add project to subdir under 'trunk'"
12
15
  puts " -d = add project to subdir under 'dev'"
16
+ exit
13
17
  end
14
18
 
15
- abort "You must specify only one of -t or -d" if $t and $d
16
-
17
19
  project = ARGV.shift
18
20
 
19
- # prevents false positives on my tag reporter
20
- X = 'FI' + 'X'
21
-
22
- abort "You must supply a project name on the commandline" unless project
23
21
  abort "Project #{project} seems to exist" if test ?d, project
24
- puts "creating project #{project}"
25
22
 
23
+ # variables for erb:
24
+ XIF = 'FI' + 'X' # prevents extra hits on my TAG reporter
26
25
  project, file_name, klass = Hoe.normalize_names project
26
+ template_path = File.expand_path("~/.hoe_template")
27
+ source_path = File.join(File.dirname(File.dirname(__FILE__)),
28
+ "template")
29
+
30
+ unless File.directory? template_path then
31
+ FileUtils.cp_r source_path, template_path, :verbose => true
32
+ paths = (Dir["#{template_path}/**/*"] +
33
+ Dir["#{template_path}/**/.*"]).select { |f| File.file? f }
34
+ FileUtils.chmod 0644, paths, :verbose => true
35
+ FileUtils.chmod 0755, paths.grep(/bin\//), :verbose => true
36
+ end
27
37
 
28
- Dir.mkdir project
29
- Dir.chdir project do
38
+ FileUtils.cp_r template_path, project, :verbose => true
30
39
 
31
- if $d then
32
- Dir.mkdir "dev"
33
- Dir.chdir "dev"
34
- elsif $t then
35
- Dir.mkdir "trunk"
36
- Dir.chdir "trunk"
40
+ 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
37
44
  end
38
45
 
39
- %w(bin lib test).each do |path|
40
- Dir.mkdir path
41
- end
46
+ paths = (Dir["**/*"] + Dir["**/.*"]).select { |f| File.file? f }.sort
47
+ paths.each do |path|
48
+ file = File.read path
42
49
 
43
- files = {
44
- "History.txt" => "=== 1.0.0 / #{Time.new.strftime("%Y-%m-%d")}\n\n* 1 major enhancement\n\n * Birthday!\n\n",
45
- "README.txt" => "= #{project}\n\n* #{X} (url)\n\n== DESCRIPTION:\n\n#{X} (describe your package)\n\n== FEATURES/PROBLEMS:\n\n* #{X} (list of features or problems)\n\n== SYNOPSIS:\n\n #{X} (code sample of usage)\n\n== REQUIREMENTS:\n\n* #{X} (list of requirements)\n\n== INSTALL:\n\n* #{X} (sudo gem install, anything else)\n\n== LICENSE:\n\n(The MIT License)\n\nCopyright (c) #{Time.new.strftime("%Y")} #{X}\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
46
- "Manifest.txt" => "",
47
- "bin/#{file_name}" => "",
48
- "lib/#{file_name}.rb" => "class #{klass}\n VERSION = '1.0.0'\nend",
49
- "test/test_#{file_name}.rb" => "",
50
- "Rakefile" => "# -*- ruby -*-\n\nrequire 'rubygems'\nrequire 'hoe'\nrequire './lib/#{file_name}.rb'\n\nHoe.new('#{project}', #{klass}::VERSION) do |p|\n # p.rubyforge_name = '#{project}x' # if different than lowercase project name\n # p.developer('#{X}', '#{X}@example.com')\nend\n\n# vim: syntax=Ruby\n"
51
- }
52
-
53
- files["Manifest.txt"] = files.keys.sort.join("\n")
54
-
55
- files.each do |file, content|
56
- File.open(file, "w") do |f|
57
- f.write content
50
+ warn "erb: #{path}"
51
+
52
+ File.open path, "w" do |f|
53
+ f.puts ERB.new(file).result(binding)
58
54
  end
59
55
  end
56
+
57
+ paths.grep(/file_name|\.erb$/).each do |file|
58
+ new_file = file.sub(/file_name/, file_name).sub(/\.erb$/, '')
59
+ FileUtils.mv file, new_file, :verbose => true
60
+ end
61
+ end
62
+
63
+ if $d || $t then
64
+ 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
60
68
  end
61
69
 
62
70
  WINDOZE = /mswin|mingw/ =~ RUBY_PLATFORM
63
71
 
64
- puts "... done, now go fix all occurrences of '#{X}'"
72
+ puts
73
+ puts "... done, now go fix all occurrences of '#{XIF}':"
65
74
  if WINDOZE then
66
- puts `findstr /N /S /C:#{X} #{project}\\*`
75
+ puts `findstr /N /S /C:#{XIF} #{project}\\*`
67
76
  else
68
- puts `find #{project} -type f | xargs grep -n #{X}`.gsub(/\A|\n/, "\n ")
77
+ puts `find #{project} -type f | xargs grep -n #{XIF}`.gsub(/\A|\n/, "\n ")
69
78
  end
data/lib/hoe.rb CHANGED
@@ -28,9 +28,11 @@ end
28
28
  # Use this as a minimal starting point:
29
29
  #
30
30
  # require 'hoe'
31
+ # require './lib/project.rb'
31
32
  #
32
- # Hoe.new("project_name", '1.0.0') do |p|
33
+ # Hoe.new("project_name", Project::VERSION) do |p|
33
34
  # p.rubyforge_name = "rf_project"
35
+ # p.developer("Joe Blow", "joe@example.com")
34
36
  # # add other details here
35
37
  # end
36
38
  #
@@ -38,31 +40,35 @@ end
38
40
  #
39
41
  # === Tasks Provided:
40
42
  #
41
- # announce:: Create news email file and post to rubyforge.
42
- # audit:: Run ZenTest against the package.
43
- # check_manifest:: Verify the manifest.
44
- # clean:: Clean up all the extras.
45
- # config_hoe:: Create a fresh ~/.hoerc file.
46
- # debug_gem:: Show information about the gem.
47
- # default:: Run the default tasks.
48
- # deps:email:: Print a contact list for gems dependent on this gem
49
- # deps:fetch:: Fetch all the dependent gems of this gem into tarballs
50
- # deps:list:: List all the dependent gems of this gem
51
- # docs:: Build the docs HTML Files
52
- # email:: Generate email announcement file.
53
- # gem:: Build the gem file hoe-1.8.0.gem
54
- # generate_key:: Generate a key for signing your gems.
55
- # install_gem:: Install the package as a gem.
56
- # multi:: Run the test suite using multiruby.
57
- # package:: Build all the packages
58
- # post_blog:: Post announcement to blog.
59
- # post_news:: Post announcement to rubyforge.
60
- # publish_docs:: Publish RDoc to RubyForge.
61
- # release:: Package and upload the release to rubyforge.
62
- # ridocs:: Generate ri locally for testing.
63
- # tasks:: Generate a list of tasks for doco.
64
- # test:: Run the test suite.
65
- # test_deps:: Show which test files fail when run alone.
43
+ # announce:: Create news email file and post to rubyforge.
44
+ # audit:: Run ZenTest against the package.
45
+ # check_extra_deps:: Install missing dependencies.
46
+ # check_manifest:: Verify the manifest.
47
+ # clean:: Clean up all the extras.
48
+ # config_hoe:: Create a fresh ~/.hoerc file.
49
+ # debug_gem:: Show information about the gem.
50
+ # default:: Run the default task(s).
51
+ # deps:email:: Print a contact list for gems dependent on this gem
52
+ # deps:fetch:: Fetch all the dependent gems of this gem into tarballs
53
+ # deps:list:: List all the dependent gems of this gem
54
+ # docs:: Build the docs HTML Files
55
+ # email:: Generate email announcement file.
56
+ # flay:: Analyze for code duplication.
57
+ # flog:: Analyze code complexity.
58
+ # gem:: Build the gem file hoe-1.9.0.gem
59
+ # generate_key:: Generate a key for signing your gems.
60
+ # install_gem:: Install the package as a gem.
61
+ # multi:: Run the test suite using multiruby.
62
+ # package:: Build all the packages
63
+ # post_blog:: Post announcement to blog.
64
+ # post_news:: Post announcement to rubyforge.
65
+ # publish_docs:: Publish RDoc to RubyForge.
66
+ # rcov:: Analyze code coverage with tests
67
+ # release:: Package and upload the release to rubyforge.
68
+ # ridocs:: Generate ri locally for testing.
69
+ # tasks:: Generate a list of tasks for doco.
70
+ # test:: Run the test suite.
71
+ # test_deps:: Show which test files fail when run alone.
66
72
  #
67
73
  # === Extra Configuration Options:
68
74
  #
@@ -124,16 +130,19 @@ end
124
130
  #
125
131
 
126
132
  class Hoe
127
- VERSION = '1.8.3'
133
+ VERSION = '1.9.0'
128
134
  GEMURL = URI.parse 'http://gems.rubyforge.org' # for namespace :deps below
129
135
 
130
136
  ruby_prefix = Config::CONFIG['prefix']
131
137
  sitelibdir = Config::CONFIG['sitelibdir']
132
138
 
133
139
  ##
134
- # Used to specify a custom install location (for rake install).
140
+ # Configuration for the supported test frameworks for test task.
135
141
 
136
- PREFIX = ENV['PREFIX'] || ruby_prefix
142
+ SUPPORTED_TEST_FRAMEWORKS = {
143
+ :testunit => "test/unit",
144
+ :minitest => "minitest/autorun",
145
+ }
137
146
 
138
147
  ##
139
148
  # Used to add extra flags to RUBY_FLAGS.
@@ -150,17 +159,13 @@ class Hoe
150
159
 
151
160
  ##
152
161
  # Used to add flags to test_unit (e.g., -n test_borked).
162
+ #
163
+ # eg FILTER="-n test_blah"
153
164
 
154
- FILTER = ENV['FILTER'] # for tests (eg FILTER="-n test_blah")
165
+ FILTER = ENV['FILTER'] || ENV['TESTOPTS']
155
166
 
156
167
  # :stopdoc:
157
168
 
158
- RUBYLIB = if PREFIX == ruby_prefix then
159
- sitelibdir
160
- else
161
- File.join(PREFIX, sitelibdir[ruby_prefix.size..-1])
162
- end
163
-
164
169
  DLEXT = Config::CONFIG['DLEXT']
165
170
 
166
171
  WINDOZE = /mswin|mingw/ =~ RUBY_PLATFORM unless defined? WINDOZE
@@ -178,8 +183,7 @@ class Hoe
178
183
  # :startdoc:
179
184
 
180
185
  ##
181
- # *Recommended*: The author(s) of the package. (can be array)
182
- # Really. Set this or we'll tease you.
186
+ # *MANDATORY*: The author(s) of the package. (can be array)
183
187
 
184
188
  attr_accessor :author
185
189
 
@@ -214,7 +218,7 @@ class Hoe
214
218
  attr_accessor :description_sections
215
219
 
216
220
  ##
217
- # *Recommended*: The author's email address(es). (can be array)
221
+ # *MANDATORY*: The author's email address(es). (can be array)
218
222
 
219
223
  attr_accessor :email
220
224
 
@@ -228,6 +232,18 @@ class Hoe
228
232
 
229
233
  attr_accessor :extra_dev_deps
230
234
 
235
+ ##
236
+ # Optional: Extra files you want to add to RDoc.
237
+ #
238
+ # .txt files are automatically included (excluding the obvious).
239
+
240
+ attr_accessor :extra_rdoc_files
241
+
242
+ ##
243
+ # Optional: The filename for the project history. [default: History.txt]
244
+
245
+ attr_accessor :history_file
246
+
231
247
  ##
232
248
  # Populated automatically from the manifest. List of library files.
233
249
 
@@ -259,15 +275,25 @@ class Hoe
259
275
  attr_accessor :post_install_message
260
276
 
261
277
  ##
262
- # Optional: A regexp to match documentation files against the manifest.
278
+ # Optional: The filename for the project readme. [default: README.txt]
263
279
 
264
- attr_accessor :rdoc_pattern
280
+ attr_accessor :readme_file
265
281
 
266
282
  ##
267
283
  # Optional: Name of RDoc destination directory on Rubyforge. [default: +name+]
268
284
 
269
285
  attr_accessor :remote_rdoc_dir
270
286
 
287
+ ##
288
+ # Optional: RSpec dirs. [default: %w(spec lib)]
289
+
290
+ attr_accessor :rspec_dirs
291
+
292
+ ##
293
+ # Optional: RSpec options. [default: []]
294
+
295
+ attr_accessor :rspec_options
296
+
271
297
  ##
272
298
  # Optional: Flags for RDoc rsync. [default: "-av --delete"]
273
299
 
@@ -309,7 +335,7 @@ class Hoe
309
335
  attr_accessor :test_globs
310
336
 
311
337
  ##
312
- # Optional: What test library to require [default: test/unit]
338
+ # Optional: What test library to require [default: :testunit]
313
339
 
314
340
  attr_accessor :testlib
315
341
 
@@ -351,36 +377,40 @@ class Hoe
351
377
  end
352
378
 
353
379
  def initialize(name, version) # :nodoc:
354
- self.name = name
380
+ self.name = name
355
381
  self.version = version
356
382
 
357
383
  # Defaults
358
- self.author = []
359
- self.clean_globs = %w(diff diff.txt email.txt ri deps .source_index
360
- *.gem *~ **/*~ *.rbc **/*.rbc)
384
+ self.author = []
385
+ self.blog_categories = [name]
386
+ self.clean_globs = %w(diff diff.txt email.txt ri deps .source_index
387
+ *.gem **/*~ **/.*~ **/*.rbc)
361
388
  self.description_sections = %w(description)
362
- self.blog_categories = [name]
363
- self.email = []
364
- self.extra_deps = []
365
- self.extra_dev_deps = []
366
- self.multiruby_skip = []
367
- self.need_tar = true
368
- self.need_zip = false
369
- self.rdoc_pattern = /^(lib|bin|ext)|txt$/
370
- self.remote_rdoc_dir = name
371
- self.rsync_args = '-av --delete'
372
- self.rubyforge_name = name.downcase
373
- self.spec_extras = {}
374
- self.summary_sentences = 1
375
- self.test_globs = ['test/**/test_*.rb']
376
- self.testlib = 'test/unit'
389
+ self.email = []
390
+ self.extra_deps = []
391
+ self.extra_dev_deps = []
392
+ self.extra_rdoc_files = []
393
+ self.history_file = "History.txt"
394
+ self.multiruby_skip = []
395
+ self.need_tar = true
396
+ self.need_zip = false
377
397
  self.post_install_message = nil
398
+ self.readme_file = "README.txt"
399
+ self.remote_rdoc_dir = name
400
+ self.rspec_dirs = %w(spec lib)
401
+ self.rspec_options = []
402
+ self.rsync_args = '-av --delete'
403
+ self.rubyforge_name = name.downcase
404
+ self.spec_extras = {}
405
+ self.summary_sentences = 1
406
+ self.test_globs = ['test/**/test_*.rb']
407
+ self.testlib = :testunit
378
408
 
379
409
  yield self if block_given?
380
410
 
381
411
  # Intuit values:
382
412
 
383
- readme = File.read("README.txt").split(/^(=+ .*)$/)[1..-1] rescue ''
413
+ readme = File.read(readme_file).split(/^(=+ .*)$/)[1..-1] rescue ''
384
414
  unless readme.empty? then
385
415
  sections = readme.map { |s|
386
416
  s =~ /^=/ ? s.strip.downcase.chomp(':').split.last : s.strip
@@ -390,17 +420,17 @@ class Hoe
390
420
  summ = desc.split(/\.\s+/).first(summary_sentences).join(". ")
391
421
 
392
422
  self.description ||= desc
393
- self.summary ||= summ
394
- self.url ||= readme[1].gsub(/^\* /, '').split(/\n/).grep(/\S+/)
423
+ self.summary ||= summ
424
+ self.url ||= readme[1].gsub(/^\* /, '').split(/\n/).grep(/\S+/)
395
425
  else
396
- missing 'README.txt'
426
+ missing readme_file
397
427
  end
398
428
 
399
429
  self.changes ||= begin
400
- h = File.read("History.txt")
430
+ h = File.read(history_file)
401
431
  h.split(/^(===.*)/)[1..2].join.strip
402
432
  rescue
403
- missing 'History.txt'
433
+ missing history_file
404
434
  ''
405
435
  end
406
436
 
@@ -448,31 +478,104 @@ class Hoe
448
478
  end
449
479
 
450
480
  def define_tasks # :nodoc:
451
- desc 'Run the default tasks.'
452
- task :default => :test
481
+ default_tasks = []
453
482
 
454
- desc 'Run the test suite. Use FILTER to add to the command line.'
455
- task :test do
456
- run_tests
457
- end
483
+ if File.directory? "test" then
484
+ desc 'Run the test suite. Use FILTER or TESTOPTS to add flags/args.'
485
+ task :test do
486
+ run_tests
487
+ end
488
+
489
+ desc 'Run the test suite using multiruby.'
490
+ task :multi do
491
+ run_tests :multi
492
+ end
493
+
494
+ desc 'Show which test files fail when run alone.'
495
+ task :test_deps do
496
+ tests = Dir["test/**/test_*.rb"] + Dir["test/**/*_test.rb"]
497
+
498
+ paths = ['bin', 'lib', 'test'].join(File::PATH_SEPARATOR)
499
+ null_dev = WINDOZE ? '> NUL 2>&1' : '&> /dev/null'
500
+
501
+ tests.each do |test|
502
+ if not system "ruby -I#{paths} #{test} #{null_dev}" then
503
+ puts "Dependency Issues: #{test}"
504
+ end
505
+ end
506
+ end
458
507
 
459
- desc 'Show which test files fail when run alone.'
460
- task :test_deps do
461
- tests = Dir["test/**/test_*.rb"] + Dir["test/**/*_test.rb"]
508
+ default_tasks << :test
509
+ end
462
510
 
463
- paths = ['bin', 'lib', 'test'].join(File::PATH_SEPARATOR)
464
- null_dev = WINDOZE ? '> NUL 2>&1' : '&> /dev/null'
511
+ if File.directory? "spec" then
512
+ begin
513
+ require 'spec/rake/spectask'
465
514
 
466
- tests.each do |test|
467
- if not system "ruby -I#{paths} #{test} #{null_dev}" then
468
- puts "Dependency Issues: #{test}"
515
+ desc "Run all specifications"
516
+ Spec::Rake::SpecTask.new(:spec) do |t|
517
+ t.libs = self.rspec_dirs
518
+ t.spec_opts = self.rspec_options
469
519
  end
520
+ rescue LoadError
521
+ # do nothing
522
+ end
523
+ default_tasks << :spec
524
+ end
525
+
526
+ desc 'Run the default task(s).'
527
+ task :default => default_tasks
528
+
529
+ begin # take a whack at defining rcov tasks
530
+ require 'rcov/rcovtask'
531
+
532
+ Rcov::RcovTask.new do |t|
533
+ pattern = ENV['PATTERN'] || 'test/test_*.rb'
534
+
535
+ t.test_files = FileList[pattern]
536
+ t.verbose = true
537
+ t.rcov_opts << "--threshold 80"
538
+ t.rcov_opts << "--no-color"
539
+ t.rcov_opts << "-x ^/"
470
540
  end
541
+
542
+ # this is for autotest's rcov... also used by my emacs integration
543
+ task :rcov_info do
544
+ pattern = ENV['PATTERN'] || "test/test_*.rb"
545
+ ruby "-Ilib -S rcov --text-report --save coverage.info --test-unit-only #{pattern}"
546
+ end
547
+
548
+ # this is for my emacs rcov overlay stuff on emacswiki.
549
+ task :rcov_overlay do
550
+ rcov, eol = Marshal.load(File.read("coverage.info")).last[ENV["FILE"]], 1
551
+ puts rcov[:lines].zip(rcov[:coverage]).map { |line, coverage|
552
+ bol, eol = eol, eol + line.length
553
+ [bol, eol, "#ffcccc"] unless coverage
554
+ }.compact.inspect
555
+ end
556
+ rescue LoadError
557
+ # skip
471
558
  end
472
559
 
473
- desc 'Run the test suite using multiruby.'
474
- task :multi do
475
- run_tests :multi
560
+ desc "Analyze for code duplication."
561
+ task :flay do
562
+ sh "find lib test -name \*.rb | xargs flay"
563
+ end
564
+
565
+ desc "Analyze code complexity."
566
+ task :flog do
567
+ print "lib : "
568
+ sh "flog -s lib"
569
+
570
+ if File.directory? "test" then
571
+ print "test: "
572
+ sh "flog -s test"
573
+ end
574
+
575
+ if File.directory? "spec" then
576
+ print "spec: "
577
+ sh "flog -s spec"
578
+ end
476
579
  end
477
580
 
478
581
  ############################################################
@@ -521,8 +624,11 @@ class Hoe
521
624
  dirs = Dir['{lib,ext}']
522
625
  s.require_paths = dirs unless dirs.empty?
523
626
 
524
- s.rdoc_options = ['--main', 'README.txt']
525
- s.extra_rdoc_files = s.files.grep(/txt$/)
627
+ s.rdoc_options = ['--main', readme_file]
628
+
629
+ s.extra_rdoc_files += s.files.grep(/txt$/)
630
+ s.extra_rdoc_files.reject! { |f| f =~ %r%^(test|spec|vendor|template|data|tmp)/% }
631
+ s.extra_rdoc_files += @extra_rdoc_files
526
632
  s.has_rdoc = true
527
633
 
528
634
  s.post_install_message = post_install_message
@@ -530,7 +636,7 @@ class Hoe
530
636
  if test ?f, "test/test_all.rb" then
531
637
  s.test_file = "test/test_all.rb"
532
638
  else
533
- s.test_files = Dir[*test_globs]
639
+ s.test_files = Dir[*self.test_globs]
534
640
  end
535
641
 
536
642
  if signing_key and cert_chain then
@@ -589,8 +695,8 @@ class Hoe
589
695
  puts spec.to_ruby
590
696
  end
591
697
 
592
- self.lib_files = spec.files.grep(/^(lib|ext)/)
593
- self.bin_files = spec.files.grep(/^bin/)
698
+ self.lib_files = spec.files.grep(/^(lib|ext)/)
699
+ self.bin_files = spec.files.grep(/^bin/)
594
700
  self.test_files = spec.files.grep(/^test/)
595
701
 
596
702
  Rake::GemPackageTask.new spec do |pkg|
@@ -599,7 +705,7 @@ class Hoe
599
705
  end
600
706
 
601
707
  desc 'Install the package as a gem.'
602
- task :install_gem => [:clean, :package] do
708
+ task :install_gem => [:clean, :package, :check_extra_deps] do
603
709
  gem = Dir['pkg/*.gem'].first
604
710
  sh "#{'sudo ' unless WINDOZE}gem install --local #{gem}"
605
711
  end
@@ -636,18 +742,18 @@ class Hoe
636
742
  # Doco
637
743
 
638
744
  Rake::RDocTask.new(:docs) do |rd|
639
- rd.main = "README.txt"
640
- rd.options << '-d' if
641
- `which dot` =~ /\/dot/ unless ENV['NODOT'] unless WINDOZE
745
+ rd.main = readme_file
746
+ rd.options << '-d' if (`which dot` =~ /\/dot/) unless
747
+ ENV['NODOT'] || WINDOZE
642
748
  rd.rdoc_dir = 'doc'
643
- files = spec.files.grep(rdoc_pattern)
644
- files -= ['Manifest.txt']
645
- rd.rdoc_files.push(*files)
749
+
750
+ rd.rdoc_files += spec.require_paths
751
+ rd.rdoc_files += spec.extra_rdoc_files
646
752
 
647
753
  title = "#{name}-#{version} Documentation"
648
754
  title = "#{rubyforge_name}'s " + title if rubyforge_name != name
649
755
 
650
- rd.options << "-t #{title}"
756
+ rd.options << "-t" << title
651
757
  end
652
758
 
653
759
  desc 'Generate ri locally for testing.'
@@ -809,14 +915,30 @@ class Hoe
809
915
  sh "zentest -I=#{libs} #{spec.files.grep(/^(lib|test)/).join(' ')}"
810
916
  end
811
917
 
918
+ task :clobber_rcov # in case rcov didn't load
919
+
812
920
  desc 'Clean up all the extras.'
813
- task :clean => [ :clobber_docs, :clobber_package ] do
921
+ task :clean => [ :clobber_docs, :clobber_package, :clobber_rcov ] do
814
922
  clean_globs.each do |pattern|
815
923
  files = Dir[pattern]
816
924
  rm_rf files, :verbose => true unless files.empty?
817
925
  end
818
926
  end
819
927
 
928
+ desc 'Install missing dependencies.'
929
+ task :check_extra_deps do
930
+ # extra_deps = [["rubyforge", ">= 1.0.0"], ["rake", ">= 0.8.1"]]
931
+ extra_deps.each do |dep|
932
+ begin
933
+ gem(*dep)
934
+ rescue Gem::LoadError
935
+ dep_gem, dep_version = dep
936
+ dep_version = "--version '#{dep_version}'" if dep_version
937
+ sh "#{'sudo ' unless WINDOZE}gem install #{dep_gem} #{dep_version}"
938
+ end
939
+ end
940
+ end
941
+
820
942
  desc 'Create a fresh ~/.hoerc file.'
821
943
  task :config_hoe do
822
944
  with_config do |config, path|
@@ -975,6 +1097,24 @@ class Hoe
975
1097
 
976
1098
  end # end define
977
1099
 
1100
+ def run_tests(multi=false) # :nodoc:
1101
+ framework = SUPPORTED_TEST_FRAMEWORKS[testlib]
1102
+ raise "unsupported test framework #{testlib}" unless framework
1103
+
1104
+ tests = ["rubygems", framework] +
1105
+ test_globs.map { |g| Dir.glob(g) }.flatten
1106
+ tests.map! {|f| %(require "#{f}")}
1107
+
1108
+ cmd = "#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}"
1109
+
1110
+ if multi then
1111
+ ENV['EXCLUDED_VERSIONS'] = multiruby_skip.join ":"
1112
+ cmd = "-S multiruby #{cmd}"
1113
+ end
1114
+
1115
+ ruby cmd
1116
+ end
1117
+
978
1118
  def announcement # :nodoc:
979
1119
  changes = self.changes.rdoc_to_markdown
980
1120
  subject = "#{name} #{version} Released"
@@ -985,24 +1125,6 @@ class Hoe
985
1125
  return subject, title, body, urls
986
1126
  end
987
1127
 
988
- def run_tests(multi=false) # :nodoc:
989
- msg = multi ? :sh : :ruby
990
- cmd = if test ?f, 'test/test_all.rb' then
991
- "#{RUBY_FLAGS} test/test_all.rb #{FILTER}"
992
- else
993
- tests = ["rubygems", self.testlib] +
994
- test_globs.map { |g| Dir.glob(g) }.flatten
995
- tests.map! {|f| %Q(require "#{f}")}
996
- "#{RUBY_FLAGS} -e '#{tests.join("; ")}' #{FILTER}"
997
- end
998
-
999
- excludes = multiruby_skip.join(":")
1000
- ENV['EXCLUDED_VERSIONS'] = excludes
1001
- cmd = "multiruby #{cmd}" if multi
1002
-
1003
- send msg, cmd
1004
- end
1005
-
1006
1128
  ##
1007
1129
  # Reads a file at +path+ and spits out an array of the +paragraphs+ specified.
1008
1130
  #
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / <%= Time.new.strftime("%Y-%m-%d") %>
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/<%= project %>
6
+ lib/<%= project %>.rb
7
+ test/test_<%= project %>.rb
@@ -0,0 +1,48 @@
1
+ = <%= project %>
2
+
3
+ * <%= XIF %> (url)
4
+
5
+ == DESCRIPTION:
6
+
7
+ <%= XIF %> (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * <%= XIF %> (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ <%= XIF %> (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * <%= XIF %> (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * <%= XIF %> (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) <%= Time.new.strftime("%Y") %> <%= XIF %>
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,12 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/<%= project %>.rb'
6
+
7
+ Hoe.new('<%= project %>', <%= klass %>::VERSION) do |p|
8
+ # p.rubyforge_name = '<%= project %>x' # if different than lowercase project name
9
+ # p.developer('<%= XIF %>', '<%= XIF %>@example.com')
10
+ end
11
+
12
+ # vim: syntax=Ruby
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ abort "you need to write me"
@@ -0,0 +1,3 @@
1
+ class <%= klass %>
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "<%= file_name %>"
3
+
4
+ class Test<%= klass %> < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
@@ -14,9 +14,15 @@ class TestHoe < Test::Unit::TestCase
14
14
  # everything is forked out.
15
15
 
16
16
  def test_basics
17
- boring = %w(clobber_docs clobber_package gem redocs repackage)
17
+ boring = %w(clobber_docs
18
+ clobber_package
19
+ clobber_rcov
20
+ gem
21
+ redocs
22
+ repackage)
18
23
  expected = %w(audit
19
24
  announce
25
+ check_extra_deps
20
26
  check_manifest
21
27
  clean
22
28
  config_hoe
@@ -27,6 +33,8 @@ class TestHoe < Test::Unit::TestCase
27
33
  deps:list
28
34
  docs
29
35
  email
36
+ flay
37
+ flog
30
38
  generate_key
31
39
  install_gem
32
40
  multi
@@ -34,6 +42,7 @@ class TestHoe < Test::Unit::TestCase
34
42
  post_blog
35
43
  post_news
36
44
  publish_docs
45
+ rcov
37
46
  release
38
47
  ridocs
39
48
  test
@@ -63,6 +72,8 @@ class TestHoe < Test::Unit::TestCase
63
72
 
64
73
  spec = hoe.spec
65
74
 
75
+ text_files = files.grep(/txt$/).reject { |f| f =~ /template/ }
76
+
66
77
  assert_equal 'blah', spec.name
67
78
  assert_equal '1.2.3', spec.version.to_s
68
79
  assert_equal '>= 0', spec.required_rubygems_version.to_s
@@ -73,7 +84,7 @@ class TestHoe < Test::Unit::TestCase
73
84
  assert_match(/Hoe.*Rakefiles/, spec.description)
74
85
  assert_equal ['email'], spec.email
75
86
  assert_equal ['sow'], spec.executables
76
- assert_equal files.grep(/txt$/), spec.extra_rdoc_files
87
+ assert_equal text_files, spec.extra_rdoc_files
77
88
  assert_equal files, spec.files
78
89
  assert_equal true, spec.has_rdoc
79
90
  assert_equal "http://rubyforge.org/projects/seattlerb/", spec.homepage
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-20 00:00:00 -08:00
12
+ date: 2009-02-26 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.2
23
+ version: 1.0.3
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
@@ -32,7 +32,7 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.8.3
34
34
  version:
35
- description: "Hoe is a simple rake/rubygems helper for project Rakefiles. It generates all the usual tasks for projects including rdoc generation, testing, packaging, and deployment. Tasks Provided: * 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. * deps:email - Print a contact list for gems dependent on this gem * deps:fetch - Fetch all the dependent gems of this gem into tarballs * deps:list - List all the dependent gems of this gem * docs - Build the docs HTML Files * email - Generate email announcement file. * gem - Build the gem file hoe-1.8.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. * release - Package and upload the release to rubyforge. * ridocs - Generate ri locally for testing. * tasks - Generate a list of tasks for doco. * test - Run the test suite. * test_deps - Show which test files fail when run alone. See class rdoc for help. Hint: ri Hoe"
35
+ description: "Hoe is a simple rake/rubygems helper for project Rakefiles. It generates all the usual tasks for projects including rdoc generation, testing, packaging, and deployment. Tasks Provided: * announce - Create news email file and post to rubyforge. * audit - Run ZenTest against the package. * check_extra_deps - Install missing dependencies. * 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 task(s). * deps:email - Print a contact list for gems dependent on this gem * deps:fetch - Fetch all the dependent gems of this gem into tarballs * deps:list - List all the dependent gems of this gem * docs - Build the docs HTML Files * email - Generate email announcement file. * flay - Analyze for code duplication. * flog - Analyze code complexity. * gem - Build the gem file hoe-1.9.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. * rcov - Analyze code coverage with tests * release - Package and upload the release to rubyforge. * ridocs - Generate ri locally for testing. * tasks - Generate a list of tasks for doco. * test - Run the test suite. * test_deps - Show which test files fail when run alone. See class rdoc for help. Hint: ri Hoe"
36
36
  email:
37
37
  - ryand-ruby@zenspider.com
38
38
  executables:
@@ -50,6 +50,14 @@ files:
50
50
  - Rakefile
51
51
  - bin/sow
52
52
  - lib/hoe.rb
53
+ - template/.autotest.erb
54
+ - template/History.txt.erb
55
+ - template/Manifest.txt.erb
56
+ - template/README.txt.erb
57
+ - template/Rakefile.erb
58
+ - template/bin/file_name.erb
59
+ - template/lib/file_name.rb.erb
60
+ - template/test/test_file_name.rb.erb
53
61
  - test/test_hoe.rb
54
62
  has_rdoc: true
55
63
  homepage: http://rubyforge.org/projects/seattlerb/