shoe 0.6.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/{data/shoe/templates/gitignore.erb → .gitignore} +1 -1
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG.rdoc +9 -1
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +39 -0
  6. data/README.rdoc +20 -72
  7. data/Rakefile +6 -0
  8. data/TODO.rdoc +10 -5
  9. data/lib/shoe.rb +29 -13
  10. data/lib/shoe/extensions.rb +0 -4
  11. data/lib/shoe/extensions/specification.rb +0 -4
  12. data/lib/shoe/extensions/validator.rb +40 -11
  13. data/lib/shoe/tasks.rb +13 -22
  14. data/lib/shoe/tasks/clean.rb +4 -4
  15. data/lib/shoe/tasks/compile.rb +2 -4
  16. data/lib/shoe/tasks/cucumber.rb +5 -9
  17. data/lib/shoe/tasks/rdoc.rb +2 -3
  18. data/lib/shoe/tasks/ronn.rb +5 -5
  19. data/lib/shoe/tasks/{abstract.rb → task.rb} +1 -1
  20. data/lib/shoe/tasks/test.rb +17 -57
  21. data/lib/shoe/util/minitest_colors.rb +60 -0
  22. data/lib/shoe/version.rb +3 -0
  23. data/man/shoe.3 +5 -11
  24. data/man/shoe.3.ronn +4 -13
  25. data/shoe.gemspec +35 -0
  26. data/test/helper.rb +6 -12
  27. data/test/support/assertions.rb +45 -0
  28. data/test/support/command_runner.rb +11 -0
  29. data/test/support/declarative_tests.rb +24 -0
  30. data/test/support/example_project.rb +37 -0
  31. data/test/support/file_manipulation.rb +43 -0
  32. data/test/support/gemspec_manipulation.rb +24 -0
  33. data/test/support/project_files.rb +60 -0
  34. data/test/support/redgreen.rb +6 -0
  35. data/test/system/rake_test.rb +124 -0
  36. metadata +75 -96
  37. data/bin/shoe +0 -18
  38. data/data/shoe/templates/application.erb +0 -23
  39. data/data/shoe/templates/executable.erb +0 -18
  40. data/data/shoe/templates/extconf.erb +0 -2
  41. data/data/shoe/templates/extension.erb +0 -25
  42. data/data/shoe/templates/gemspec.erb +0 -44
  43. data/data/shoe/templates/gitkeep.erb +0 -0
  44. data/data/shoe/templates/manpage_1.erb +0 -29
  45. data/data/shoe/templates/manpage_3.erb +0 -19
  46. data/data/shoe/templates/module.erb +0 -31
  47. data/data/shoe/templates/module_test.rb +0 -7
  48. data/data/shoe/templates/rakefile.erb +0 -3
  49. data/data/shoe/templates/readme.erb +0 -3
  50. data/data/shoe/templates/test_helper.erb +0 -9
  51. data/lib/shoe/extensions/option_parser.rb +0 -52
  52. data/lib/shoe/extensions/pathname.rb +0 -16
  53. data/lib/shoe/extensions/source_index.rb +0 -17
  54. data/lib/shoe/extensions/test_runner.rb +0 -28
  55. data/lib/shoe/generator.rb +0 -147
  56. data/lib/shoe/tasks/release.rb +0 -81
  57. data/man/shoe.1 +0 -63
  58. data/man/shoe.1.ronn +0 -60
  59. data/test/extensions/fake_rubygems_server.rb +0 -62
  60. data/test/extensions/helper_methods.rb +0 -73
  61. data/test/extensions/isolated_environment.rb +0 -50
  62. data/test/extensions/test_case.rb +0 -40
  63. data/test/system/rake_clean_test.rb +0 -36
  64. data/test/system/rake_compile_test.rb +0 -25
  65. data/test/system/rake_cucumber_test.rb +0 -51
  66. data/test/system/rake_rdoc_test.rb +0 -26
  67. data/test/system/rake_release_test.rb +0 -94
  68. data/test/system/rake_ronn_test.rb +0 -25
  69. data/test/system/rake_test_test.rb +0 -45
  70. data/test/system/shoe_test.rb +0 -79
@@ -13,7 +13,7 @@ module Shoe
13
13
  # To enable and configure, add
14
14
  # <tt>extensions[http://docs.rubygems.org/read/chapter/20#extensions]</tt>
15
15
  # to your gemspec.
16
- class Compile < Abstract
16
+ class Compile < Task
17
17
  def active?
18
18
  !spec.extensions.empty?
19
19
  end
@@ -40,9 +40,7 @@ module Shoe
40
40
  end
41
41
  end
42
42
 
43
- namespace :prepare do
44
- task :execute => :compile
45
- end
43
+ task :prepare => :compile
46
44
  end
47
45
  end
48
46
 
@@ -12,7 +12,7 @@ module Shoe
12
12
  #
13
13
  # To enable and configure, create and edit your
14
14
  # <tt>{cucumber.yml}[http://wiki.github.com/aslakhellesoy/cucumber/cucumberyml]</tt>.
15
- class Cucumber < Abstract
15
+ class Cucumber < Task
16
16
  def active?
17
17
  !cucumber_profiles.empty?
18
18
  end
@@ -44,11 +44,9 @@ module Shoe
44
44
  end
45
45
 
46
46
  def define_default_task
47
- namespace :prepare do
48
- task :execute
49
- end
47
+ task :prepare
50
48
 
51
- ::Cucumber::Rake::Task.new({ :cucumber => 'prepare:execute' }, "Run features.\nConfigure via the default profile in cucumber.yml.") do |task|
49
+ ::Cucumber::Rake::Task.new({ :cucumber => :prepare }, "Run features.\nConfigure via the default profile in cucumber.yml.") do |task|
52
50
  task.profile = 'default'
53
51
  end
54
52
 
@@ -56,12 +54,10 @@ module Shoe
56
54
  end
57
55
 
58
56
  def define_profile_task(profile)
59
- namespace :prepare do
60
- task :execute
61
- end
57
+ task :prepare
62
58
 
63
59
  namespace :cucumber do
64
- ::Cucumber::Rake::Task.new({ profile => 'prepare:execute' }, "Run #{profile} features.\nConfigure via the #{profile} profile in cucumber.yml.") do |task|
60
+ ::Cucumber::Rake::Task.new({ profile => :prepare }, "Run #{profile} features.\nConfigure via the #{profile} profile in cucumber.yml.") do |task|
65
61
  task.profile = profile
66
62
  end
67
63
  end
@@ -1,5 +1,4 @@
1
1
  require 'rubygems/doc_manager'
2
- require 'launchy'
3
2
 
4
3
  module Shoe
5
4
  module Tasks
@@ -23,7 +22,7 @@ module Shoe
23
22
  # <tt>rdoc_options[http://docs.rubygems.org/read/chapter/20#rdoc_options]</tt> and
24
23
  # <tt>extra_rdoc_files[http://docs.rubygems.org/read/chapter/20#extra_rdoc_files]</tt>
25
24
  # to your gemspec.
26
- class Rdoc < Abstract
25
+ class Rdoc < Task
27
26
  def active?
28
27
  true
29
28
  end
@@ -37,7 +36,7 @@ module Shoe
37
36
  END
38
37
  task :rdoc do
39
38
  Gem::DocManager.new(spec).extend(Extensions::DocManager).generate_rdoc
40
- Launchy::Browser.run('rdoc/index.html')
39
+ Shoe.browse('rdoc/index.html')
41
40
  end
42
41
  end
43
42
  end
@@ -17,13 +17,13 @@ module Shoe
17
17
  # * It's best to include the generated man pages in your gem, so that
18
18
  # {gem-man}[http://github.com/defunkt/gem-man] can get to them.
19
19
  #
20
- # * Ronn becomes a prerequisite for Release, so your man pages are sure to
21
- # be up-to-date.
20
+ # * Ronn becomes a prerequisite for <tt>rake build</tt>, so your man pages
21
+ # are sure to be up-to-date.
22
22
  #
23
23
  # * You may like to add a <tt>task :man => :ronn</tt> to your
24
24
  # <tt>Rakefile</tt>. I felt a little uncomfortable clogging that
25
25
  # namespace without your consent.
26
- class Ronn < Abstract
26
+ class Ronn < Task
27
27
  def active?
28
28
  !ronn_files.empty?
29
29
  end
@@ -59,8 +59,8 @@ module Shoe
59
59
  ronn('--roff', task.source)
60
60
  end
61
61
 
62
- namespace :prepare do
63
- task :release => 'ronn:build'
62
+ if Rake::Task.task_defined?(:build)
63
+ task :build => 'ronn:build'
64
64
  end
65
65
  end
66
66
 
@@ -1,7 +1,7 @@
1
1
  module Shoe
2
2
  module Tasks
3
3
 
4
- class Abstract
4
+ class Task
5
5
  attr_reader :spec
6
6
 
7
7
  def initialize(spec)
@@ -1,12 +1,4 @@
1
1
  require 'rubygems/validator'
2
- require 'test/unit/ui/console/testrunner'
3
-
4
- # Disable Test::Unit::AutoRunner.
5
- #
6
- # Though I tried to be really restrictive with the above testrunner require
7
- # statement, test/unit itself still gets pulled in, activating the at_exit
8
- # hook. Dang.
9
- Test::Unit.run = true
10
2
 
11
3
  module Shoe
12
4
  module Tasks
@@ -19,60 +11,33 @@ module Shoe
19
11
  # check}[http://docs.rubygems.org/read/chapter/10#page30] --test
20
12
  # your_project`</tt>.
21
13
  #
22
- # (Incidentally, this ensures your tests _are_ runnable via <tt>`gem
23
- # check`</tt>, a forgotten command second only to <tt>`{gem
24
- # cert}[http://docs.rubygems.org/read/chapter/10#page93]`</tt> in its
25
- # underuse.)
26
- #
27
14
  # To enable and configure, edit the
28
15
  # <tt>test_files[http://docs.rubygems.org/read/chapter/20#test_files]</tt>
29
16
  # in your gemspec.
30
17
  #
31
- # = <tt>Test::Unit</tt>
32
- #
33
- # Using <tt>Gem::Validator</tt> in this way means that you *must* use
34
- # <tt>Test::Unit</tt> in all of your
35
- # <tt>test_files[http://docs</tt>.rubygems.org/read/chapter/20#test_files]
36
- # -- if you prefer Rspec[http://rspec.info], just leave <tt>test_files</tt>
37
- # blank and set up your own Rake task.
38
- #
39
- # = <tt>$LOAD_PATH</tt>
40
- #
41
- # At test time, the root of your gem, any
42
- # <tt>{require_paths}[http://docs.rubygems.org/read/chapter/20#require_paths]</tt>,
43
- # and any
44
- # <tt>{dependencies}[http://docs.rubygems.org/read/chapter/20#dependencies]</tt>
45
- # are on the <tt>$LOAD_PATH</tt>.
46
- #
47
- # <b>Wrong:</b>
18
+ # = A Few Precautions
48
19
  #
49
- # # Don't do this; test_helper's not in the $LOAD_PATH
50
- # require 'test_helper'
20
+ # * Using <tt>Gem::Validator</tt> means that only <tt>Test::Unit</tt> (all
21
+ # Rubies) and <tt>MiniTest::Unit</tt> (Ruby 1.9) tests will be run.
51
22
  #
52
- # <b>Right:</b>
23
+ # * You'll need to <tt>Bundler.setup(:default, :development)</tt> in your
24
+ # <tt>Rakefile</tt> so that the <tt>Gem::Validator</tt> can find your
25
+ # code. (If you put this line in your <tt>test_helper</tt> instead,
26
+ # you'll break <tt>`gem check --test`</tt> for people who don't have
27
+ # Bundler installed.)
53
28
  #
54
- # require 'test/test_helper'
29
+ # * The <tt>test</tt> directory will not be in the <tt>$LOAD_PATH</tt>, so
30
+ # you'll have to <tt>require 'test/test_helper'</tt>.
55
31
  #
56
32
  # = Pretty Colors
57
33
  #
58
- # If you like pretty colors (I do!), just <tt>require
59
- # '{redgreen}[http://rubygems.org/gems/redgreen]'</tt> in your tests. The
60
- # <tt>Gem::Validator</tt> has been configured to play nicely with it.
34
+ # For Ruby 1.8, Shoe patches the <tt>Gem::Validator</tt> to play nicely with
35
+ # {redgreen}[http://rubygems.org/gems/redgreen]</tt>.
61
36
  #
62
- # <b>Wrong:</b>
37
+ # For Ruby 1.9, <tt>require 'shoe/util/minitest_colors'</tt> in your
38
+ # <tt>test_helper</tt>.
63
39
  #
64
- # # Don't do this; it breaks `gem check --test` if redgreen's not installed.
65
- # require 'redgreen' if $stdout.tty?
66
- #
67
- # <b>Right:</b>
68
- #
69
- # begin
70
- # require 'redgreen' if $stdout.tty?
71
- # rescue LoadError
72
- # # No colors, but `gem check --test` is golden!
73
- # end
74
- #
75
- class Test < Abstract
40
+ class Test < Task
76
41
  def active?
77
42
  !spec.test_files.empty?
78
43
  end
@@ -84,18 +49,13 @@ module Shoe
84
49
  END
85
50
 
86
51
  task :test do
87
- Gem.source_index.extend(Extensions::SourceIndex)
88
- Gem.source_index.local_gemspec = spec
89
-
90
52
  Gem::Validator.extend(Extensions::Validator)
91
53
  Gem::Validator.new.unit_test(spec)
92
54
  end
93
55
 
94
- namespace :prepare do
95
- task :execute
96
- end
56
+ task :prepare
97
57
 
98
- task :test => 'prepare:execute'
58
+ task :test => :prepare
99
59
 
100
60
  task :default
101
61
  Rake.application[:default].prerequisites.unshift(Rake.application[:test])
@@ -0,0 +1,60 @@
1
+ require 'delegate'
2
+
3
+ module Shoe
4
+ module Util
5
+
6
+ class MiniTestColors < DelegateClass(IO)
7
+ RED = 31
8
+ GREEN = 32
9
+ YELLOW = 33
10
+ CYAN = 36
11
+
12
+ def print(object)
13
+ case object
14
+ when '.'
15
+ super color(GREEN, object)
16
+ when 'F'
17
+ super color(RED, object)
18
+ when 'E'
19
+ super color(YELLOW, object)
20
+ when 'S'
21
+ super color(CYAN, object)
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ STATUS = /\d+ tests, \d+ assertions, (\d+) failures, (\d+) errors, \d+ skips/
28
+
29
+ def puts(*objects)
30
+ if objects.size == 1
31
+ string = objects.first
32
+
33
+ string.gsub!(STATUS) do |match|
34
+ failures, errors = $1.to_i, $2.to_i
35
+ if failures + errors == 0
36
+ color(GREEN, match)
37
+ else
38
+ color(RED, match)
39
+ end
40
+ end
41
+
42
+ string.gsub!(/\bFailure:/) { |s| color(RED, s) }
43
+ string.gsub!(/\bError:/) { |s| color(YELLOW, s) }
44
+ string.gsub!(/\bSkipped:/) { |s| color(CYAN, s) }
45
+ end
46
+
47
+ super
48
+ end
49
+
50
+ private
51
+
52
+ def color(code, string)
53
+ "\e[#{code}m#{string}\e[0m"
54
+ end
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ MiniTest::Unit.output = Shoe::Util::MiniTestColors.new($stdout)
@@ -0,0 +1,3 @@
1
+ module Shoe
2
+ VERSION = '0.7.0'
3
+ end
data/man/shoe.3 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.5
2
2
  .\" http://github.com/rtomayko/ronn/
3
3
  .
4
- .TH "SHOE" "3" "April 2010" "Matthew Todd" "RubyGems Manual"
4
+ .TH "SHOE" "3" "October 2010" "Matthew Todd" "RubyGems Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBshoe\fR \-\- standard Rake tasks for your RubyGems project
@@ -10,10 +10,10 @@
10
10
  require 'shoe'
11
11
  .
12
12
  .br
13
- Shoe::Tasks.define('\fIproject.gemspec\fR')
13
+ Shoe.install_tasks
14
14
  .
15
15
  .SH "DESCRIPTION"
16
- \fBShoe::Tasks.define()\fR defines a number of standard \fBrake(1)\fR tasks for your
16
+ \fBShoe.install_tasks\fR defines a number of standard \fBrake(1)\fR tasks for your
17
17
  RubyGems project. These tasks derive their configuration from your
18
18
  Gem::Specification, and they assume you are using \fBgit(1)\fR.
19
19
  .
@@ -22,7 +22,7 @@ Gem::Specification, and they assume you are using \fBgit(1)\fR.
22
22
  .TP
23
23
  \fBrake clean\fR
24
24
  Remove ignored files. Calls something like \fBgit\-clean(1)\fR with the \fB\-fdX\fR
25
- options, honoring your \fBgitignore(5)\fR rules, but preserving \fB.bundle/\fR and \fB.rvmrc\fR.
25
+ options, honoring your \fBgitignore(5)\fR rules, but preserving \fB.bundle/\fR.
26
26
  .
27
27
  .TP
28
28
  \fBrake compile\fR
@@ -42,12 +42,6 @@ reads the \fBrdoc_options\fR and \fBextra_rdoc_files\fR fields in your
42
42
  Gem::Specification.
43
43
  .
44
44
  .TP
45
- \fBrake release\fR
46
- Push a release to \fIhttp://rubygems.org/\fR, additionally running \fBgit\-push(1)\fR if
47
- you have a \fBgit\-remote(1)\fR named \fBorigin\fR. Before pushing, runs \fBgit\-commit(1)\fR and \fBgit\-tag(1)\fR with the current \fBversion\fR in your
48
- Gem::Specification.
49
- .
50
- .TP
51
45
  \fBrake ronn\fR
52
46
  Generate man pages with \fBronn(1)\fR from the \fBman/*.ronn\fR sources listed in the \fBfiles\fR field of your Gem::Specification. (The generated manpages will then
53
47
  be available via \fBgem\-man(1)\fR once your gem is installed.)
@@ -65,4 +59,4 @@ Matthew Todd, \fImatthewtodd\fR on GitHub. Do drop
65
59
  me a line if you use \fBshoe\fR \-\- I'd love to hear from you!
66
60
  .
67
61
  .SH "SEE ALSO"
68
- \fIshoe(1)\fR, \fIhttp://docs.rubygems.org/read/chapter/20\fR, \fIhttp://semver.org/\fR
62
+ \fIhttp://docs.rubygems.org/read/chapter/20\fR
@@ -4,11 +4,11 @@ shoe(3) -- standard Rake tasks for your RubyGems project
4
4
  ## SYNOPSIS
5
5
 
6
6
  require 'shoe'
7
- Shoe::Tasks.define('_project.gemspec_')
7
+ Shoe.install_tasks
8
8
 
9
9
  ## DESCRIPTION
10
10
 
11
- `Shoe::Tasks.define()` defines a number of standard `rake(1)` tasks for your
11
+ `Shoe.install_tasks` defines a number of standard `rake(1)` tasks for your
12
12
  RubyGems project. These tasks derive their configuration from your
13
13
  Gem::Specification, and they assume you are using `git(1)`.
14
14
 
@@ -16,8 +16,7 @@ Gem::Specification, and they assume you are using `git(1)`.
16
16
 
17
17
  * `rake clean`:
18
18
  Remove ignored files. Calls something like `git-clean(1)` with the `-fdX`
19
- options, honoring your `gitignore(5)` rules, but preserving `.bundle/` and
20
- `.rvmrc`.
19
+ options, honoring your `gitignore(5)` rules, but preserving `.bundle/`.
21
20
 
22
21
  * `rake compile`:
23
22
  Compile C extensions with RubyGems' built-in Gem::Ext::ExtConfBuilder,
@@ -33,12 +32,6 @@ Gem::Specification, and they assume you are using `git(1)`.
33
32
  reads the `rdoc_options` and `extra_rdoc_files` fields in your
34
33
  Gem::Specification.
35
34
 
36
- * `rake release`:
37
- Push a release to <http://rubygems.org/>, additionally running `git-push(1)` if
38
- you have a `git-remote(1)` named `origin`. Before pushing, runs
39
- `git-commit(1)` and `git-tag(1)` with the current `version` in your
40
- Gem::Specification.
41
-
42
35
  * `rake ronn`:
43
36
  Generate man pages with `ronn(1)` from the `man/*.ronn` sources listed in the
44
37
  `files` field of your Gem::Specification. (The generated manpages will then
@@ -59,6 +52,4 @@ me a line if you use `shoe` -- I'd love to hear from you!
59
52
 
60
53
  ## SEE ALSO
61
54
 
62
- [shoe(1)](shoe.1.html),
63
- <http://docs.rubygems.org/read/chapter/20>,
64
- <http://semver.org/>
55
+ <http://docs.rubygems.org/read/chapter/20>
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'shoe/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'shoe'
7
+ s.version = Shoe::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ['Matthew Todd']
10
+ s.email = ['matthew.todd@gmail.com']
11
+ s.homepage = 'http://github.com/matthewtodd/shoe'
12
+ s.summary = 'Configuration-free Rake tasks that read your gemspec.'
13
+ s.description = "#{s.summary} These tasks re-use built-in Rubygems functionality so you can be confident you're shipping what you think you are."
14
+
15
+ s.rubyforge_project = 'shoe'
16
+
17
+ s.requirements = ['git']
18
+ s.required_rubygems_version = '>= 1.3.6'
19
+ s.add_runtime_dependency 'rake', '~> 0.8.7'
20
+ s.add_development_dependency 'bundler', '~> 1.0.0'
21
+ s.add_development_dependency 'cucumber', '~> 0.6.4'
22
+ s.add_development_dependency 'ronn', '~> 0.5'
23
+
24
+ s.files = `git ls-files`.split("\n")
25
+ s.test_files = `git ls-files -- test`.split("\n")
26
+ s.extra_rdoc_files = `git ls-files -- "**/*.rdoc"`.split("\n")
27
+ s.require_paths = ['lib']
28
+
29
+ s.rdoc_options = %W(
30
+ --main README.rdoc
31
+ --title #{s.full_name}
32
+ --inline-source
33
+ --webcvs http://github.com/matthewtodd/shoe/blob/v#{s.version}/
34
+ )
35
+ end
@@ -1,20 +1,14 @@
1
1
  require 'test/unit'
2
2
  require 'shoe'
3
3
 
4
- begin
5
- require 'redgreen' if $stdout.tty?
6
- rescue LoadError
7
- # Since we don't have hard gem dependencies for testing, folks can run `gem
8
- # check --test shoe` without installing anything else.
4
+ if RUBY_VERSION >= '1.9' && $stdout.tty?
5
+ require 'shoe/util/minitest_colors'
9
6
  end
10
7
 
11
- module Shoe
12
- module TestExtensions
13
- autoload :FakeRubygemsServer, 'test/extensions/fake_rubygems_server'
14
- autoload :HelperMethods, 'test/extensions/helper_methods'
15
- autoload :IsolatedEnvironment, 'test/extensions/isolated_environment'
16
- autoload :TestCase, 'test/extensions/test_case'
8
+ class Shoe::TestCase < Test::Unit::TestCase
9
+ def default_test
10
+ # keep Test::Unit from complaining
17
11
  end
18
12
  end
19
13
 
20
- Test::Unit::TestCase.extend(Shoe::TestExtensions::TestCase)
14
+ Dir['test/support/*.rb'].each { |path| require path }