shoe 0.6.1 → 0.6.2

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.
Files changed (51) hide show
  1. data/CHANGELOG.rdoc +10 -0
  2. data/README.rdoc +2 -4
  3. data/TODO.rdoc +8 -2
  4. data/data/shoe/templates/extension.erb +18 -2
  5. data/data/shoe/templates/gemspec.erb +5 -13
  6. data/data/shoe/templates/{manpage.erb → manpage_1.erb} +3 -4
  7. data/data/shoe/templates/manpage_3.erb +19 -0
  8. data/lib/shoe.rb +1 -1
  9. data/lib/shoe/extensions.rb +1 -0
  10. data/lib/shoe/extensions/option_parser.rb +5 -7
  11. data/lib/shoe/extensions/test_runner.rb +28 -0
  12. data/lib/shoe/extensions/validator.rb +16 -4
  13. data/lib/shoe/generator.rb +2 -1
  14. data/lib/shoe/tasks/clean.rb +20 -3
  15. data/lib/shoe/tasks/compile.rb +5 -1
  16. data/lib/shoe/tasks/cucumber.rb +2 -2
  17. data/lib/shoe/tasks/rdoc.rb +6 -1
  18. data/lib/shoe/tasks/release.rb +1 -1
  19. data/lib/shoe/tasks/ronn.rb +8 -4
  20. data/lib/shoe/tasks/test.rb +33 -16
  21. data/man/shoe.1 +9 -10
  22. data/man/shoe.1.ronn +13 -16
  23. data/man/shoe.3 +68 -0
  24. data/man/shoe.3.ronn +64 -0
  25. data/test/extensions/fake_rubygems_server.rb +62 -0
  26. data/test/extensions/helper_methods.rb +73 -0
  27. data/test/extensions/isolated_environment.rb +50 -0
  28. data/test/extensions/test_case.rb +40 -0
  29. data/test/helper.rb +20 -0
  30. data/test/system/rake_clean_test.rb +36 -0
  31. data/test/system/rake_compile_test.rb +25 -0
  32. data/test/system/rake_cucumber_test.rb +51 -0
  33. data/test/system/rake_rdoc_test.rb +26 -0
  34. data/test/system/rake_release_test.rb +94 -0
  35. data/test/system/rake_ronn_test.rb +25 -0
  36. data/test/system/rake_test_test.rb +45 -0
  37. data/test/system/shoe_test.rb +79 -0
  38. metadata +48 -26
  39. data/.gitignore +0 -4
  40. data/BUNDLER.rdoc +0 -16
  41. data/Gemfile +0 -9
  42. data/Gemfile.lock +0 -49
  43. data/Rakefile +0 -4
  44. data/cucumber.yml +0 -2
  45. data/features/cucumber.feature +0 -27
  46. data/features/generator.feature +0 -32
  47. data/features/release.feature +0 -33
  48. data/features/step_definitions/shoe_steps.rb +0 -39
  49. data/features/support/env.rb +0 -69
  50. data/features/test.feature +0 -18
  51. data/shoe.gemspec +0 -44
data/man/shoe.1 CHANGED
@@ -12,12 +12,12 @@
12
12
  .SH "DESCRIPTION"
13
13
  The \fBshoe\fR command generates a new RubyGems project. Big deal, right? As
14
14
  compared with other tools, \fBshoe\fR gently guides you toward hygenic packaging
15
- standards and provides you with a sweet library of on\-demand \fBrake(1)\fR tasks
16
- built around your (authoritative) gemspec.
15
+ standards and provides you with a sweet \fIshoe(3)\fR library of
16
+ on\-demand \fBrake(1)\fR tasks built around your (authoritative) gemspec.
17
17
  .
18
18
  .SH "OPTIONS"
19
- \fBshoe\fR's default mode of operation is to generate a basic library, its \fBRakefile\fR, and some \fBTest::Unit\fR tests in the current directory. (You may pass
20
- a different \fIpath\fR on the command line, if you like.)
19
+ By default, \fBshoe\fR generates a basic library, its \fBRakefile\fR, and some \fBTest::Unit\fR tests in the current directory. (You may pass a different \fIpath\fR
20
+ on the command line, if you like.)
21
21
  .
22
22
  .P
23
23
  To generate additional files, use the following options:
@@ -25,7 +25,7 @@ To generate additional files, use the following options:
25
25
  .TP
26
26
  \fB\-a\fR, \fB\-\-[no\-]application\fR
27
27
  Generate a command\-line application. Create a simple executable script in
28
- the \fBbin\fR directory and an \fBApplication\fR class that uses \fBoptparse\fR.
28
+ the \fBbin\fR directory and an \fBoptparse\fR\-based \fBApplication\fR class.
29
29
  .
30
30
  .TP
31
31
  \fB\-d\fR, \fB\-\-[no\-]data\fR
@@ -53,12 +53,11 @@ Print a help message and exit.
53
53
  .TP
54
54
  \fB\-v\fR, \fB\-\-version\fR[=all]
55
55
  Print \fBshoe\fR's version number and exit. If \fB=all\fR is given, also print
56
- version numbers of \fBshoe\fR's dependencies. (This is standard \fBoptparse\fR behavior
57
- that deserves more attention!)
56
+ version numbers of \fBshoe\fR's dependencies.
58
57
  .
59
58
  .SH "AUTHOR"
60
- Matthew Todd, \fI@matthewtodd\fR on GitHub and Twitter. Do drop me a line if you
61
- use \fBshoe\fR \-\- I'd love to hear from you!
59
+ Matthew Todd, \fImatthewtodd\fR on GitHub. Do drop
60
+ me a line if you use \fBshoe\fR \-\- I'd love to hear from you!
62
61
  .
63
62
  .SH "SEE ALSO"
64
- \fIhttp://seattlerb.rubyforge.org/hoe/\fR, \fIhttp://github.com/technicalpickles/jeweler\fR, \fIhttp://github.com/sr/mg\fR, \fIhttp://defunkt.github.com/rip/\fR, \fIhttp://gembundler.com/\fR, \fIhttp://github.com/rtomayko/rpg\fR, \fIhttp://chneukirchen.github.com/rps/\fR
63
+ \fIshoe(3)\fR, \fIhttp://chneukirchen.github.com/rps/\fR, \fIhttp://gembundler.com/\fR, \fIhttp://defunkt.github.com/rip/\fR, \fIhttp://github.com/rtomayko/rpg\fR
@@ -9,20 +9,20 @@ shoe(1) -- generate a RubyGems project
9
9
 
10
10
  The `shoe` command generates a new RubyGems project. Big deal, right? As
11
11
  compared with other tools, `shoe` gently guides you toward hygenic packaging
12
- standards and provides you with a sweet library of on-demand `rake(1)` tasks
13
- built around your (authoritative) gemspec.
12
+ standards and provides you with a sweet [shoe(3)](shoe.3.html) library of
13
+ on-demand `rake(1)` tasks built around your (authoritative) gemspec.
14
14
 
15
15
  ## OPTIONS
16
16
 
17
- `shoe`'s default mode of operation is to generate a basic library, its
18
- `Rakefile`, and some `Test::Unit` tests in the current directory. (You may pass
19
- a different _path_ on the command line, if you like.)
17
+ By default, `shoe` generates a basic library, its `Rakefile`, and some
18
+ `Test::Unit` tests in the current directory. (You may pass a different _path_
19
+ on the command line, if you like.)
20
20
 
21
21
  To generate additional files, use the following options:
22
22
 
23
23
  * `-a`, `--[no-]application`:
24
24
  Generate a command-line application. Create a simple executable script in
25
- the `bin` directory and an `Application` class that uses `optparse`.
25
+ the `bin` directory and an `optparse`-based `Application` class.
26
26
 
27
27
  * `-d`, `--[no-]data`:
28
28
  Generate a data directory. Create a `data` directory (perfect for HTML
@@ -44,20 +44,17 @@ To generate additional files, use the following options:
44
44
 
45
45
  * `-v`, `--version`[=all]:
46
46
  Print `shoe`'s version number and exit. If `=all` is given, also print
47
- version numbers of `shoe`'s dependencies. (This is standard `optparse` behavior
48
- that deserves more attention!)
47
+ version numbers of `shoe`'s dependencies.
49
48
 
50
49
  ## AUTHOR
51
50
 
52
- Matthew Todd, <@matthewtodd> on GitHub and Twitter. Do drop me a line if you
53
- use `shoe` -- I'd love to hear from you!
51
+ Matthew Todd, [matthewtodd](http://github.com/matthewtodd) on GitHub. Do drop
52
+ me a line if you use `shoe` -- I'd love to hear from you!
54
53
 
55
54
  ## SEE ALSO
56
55
 
57
- <http://seattlerb.rubyforge.org/hoe/>,
58
- <http://github.com/technicalpickles/jeweler>,
59
- <http://github.com/sr/mg>,
60
- <http://defunkt.github.com/rip/>,
56
+ [shoe(3)](shoe.3.html),
57
+ <http://chneukirchen.github.com/rps/>,
61
58
  <http://gembundler.com/>,
62
- <http://github.com/rtomayko/rpg>,
63
- <http://chneukirchen.github.com/rps/>
59
+ <http://defunkt.github.com/rip/>,
60
+ <http://github.com/rtomayko/rpg>
@@ -0,0 +1,68 @@
1
+ .\" generated with Ronn/v0.5
2
+ .\" http://github.com/rtomayko/ronn/
3
+ .
4
+ .TH "SHOE" "3" "April 2010" "Matthew Todd" "RubyGems Manual"
5
+ .
6
+ .SH "NAME"
7
+ \fBshoe\fR \-\- standard Rake tasks for your RubyGems project
8
+ .
9
+ .SH "SYNOPSIS"
10
+ require 'shoe'
11
+ .
12
+ .br
13
+ Shoe::Tasks.define('\fIproject.gemspec\fR')
14
+ .
15
+ .SH "DESCRIPTION"
16
+ \fBShoe::Tasks.define()\fR defines a number of standard \fBrake(1)\fR tasks for your
17
+ RubyGems project. These tasks derive their configuration from your
18
+ Gem::Specification, and they assume you are using \fBgit(1)\fR.
19
+ .
20
+ .SH "TASKS"
21
+ .
22
+ .TP
23
+ \fBrake clean\fR
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.
26
+ .
27
+ .TP
28
+ \fBrake compile\fR
29
+ Compile C extensions with RubyGems' built\-in Gem::Ext::ExtConfBuilder,
30
+ reading the \fBextensions\fR field in your Gem::Specification.
31
+ .
32
+ .TP
33
+ \fBrake cucumber\fR
34
+ Run Cucumber features, using the \fBdefault\fR profile in \fBcucumber.yml\fR.
35
+ Tasks for the other profiles are placed under the cucumber namespace, so you
36
+ could run a hypothetical \fBwip\fR profile with \fBrake cucumber:wip\fR, etc.
37
+ .
38
+ .TP
39
+ \fBrake rdoc\fR
40
+ Generate RDoc documentation with RubyGems' built\-in Gem::DocManager, which
41
+ reads the \fBrdoc_options\fR and \fBextra_rdoc_files\fR fields in your
42
+ Gem::Specification.
43
+ .
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
+ \fBrake ronn\fR
52
+ 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
+ be available via \fBgem\-man(1)\fR once your gem is installed.)
54
+ .
55
+ .TP
56
+ \fBrake test\fR
57
+ Run tests with RubyGems' built\-in Gem::Validator, which reads the \fBtest_files\fR field in your Gem::Specification to know which tests to run.
58
+ .
59
+ .P
60
+ Note these tasks check conditions before defining themselves, so that your \fBrake \-\-tasks\fR list stays relevant and compact. You won't see all the tasks all
61
+ the time.
62
+ .
63
+ .SH "AUTHOR"
64
+ Matthew Todd, \fImatthewtodd\fR on GitHub. Do drop
65
+ me a line if you use \fBshoe\fR \-\- I'd love to hear from you!
66
+ .
67
+ .SH "SEE ALSO"
68
+ \fIshoe(1)\fR, \fIhttp://docs.rubygems.org/read/chapter/20\fR, \fIhttp://semver.org/\fR
@@ -0,0 +1,64 @@
1
+ shoe(3) -- standard Rake tasks for your RubyGems project
2
+ ========================================================
3
+
4
+ ## SYNOPSIS
5
+
6
+ require 'shoe'
7
+ Shoe::Tasks.define('_project.gemspec_')
8
+
9
+ ## DESCRIPTION
10
+
11
+ `Shoe::Tasks.define()` defines a number of standard `rake(1)` tasks for your
12
+ RubyGems project. These tasks derive their configuration from your
13
+ Gem::Specification, and they assume you are using `git(1)`.
14
+
15
+ ## TASKS
16
+
17
+ * `rake clean`:
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`.
21
+
22
+ * `rake compile`:
23
+ Compile C extensions with RubyGems' built-in Gem::Ext::ExtConfBuilder,
24
+ reading the `extensions` field in your Gem::Specification.
25
+
26
+ * `rake cucumber`:
27
+ Run Cucumber features, using the `default` profile in `cucumber.yml`.
28
+ Tasks for the other profiles are placed under the cucumber namespace, so you
29
+ could run a hypothetical `wip` profile with `rake cucumber:wip`, etc.
30
+
31
+ * `rake rdoc`:
32
+ Generate RDoc documentation with RubyGems' built-in Gem::DocManager, which
33
+ reads the `rdoc_options` and `extra_rdoc_files` fields in your
34
+ Gem::Specification.
35
+
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
+ * `rake ronn`:
43
+ Generate man pages with `ronn(1)` from the `man/*.ronn` sources listed in the
44
+ `files` field of your Gem::Specification. (The generated manpages will then
45
+ be available via `gem-man(1)` once your gem is installed.)
46
+
47
+ * `rake test`:
48
+ Run tests with RubyGems' built-in Gem::Validator, which reads the
49
+ `test_files` field in your Gem::Specification to know which tests to run.
50
+
51
+ Note these tasks check conditions before defining themselves, so that your
52
+ `rake --tasks` list stays relevant and compact. You won't see all the tasks all
53
+ the time.
54
+
55
+ ## AUTHOR
56
+
57
+ Matthew Todd, [matthewtodd](http://github.com/matthewtodd) on GitHub. Do drop
58
+ me a line if you use `shoe` -- I'd love to hear from you!
59
+
60
+ ## SEE ALSO
61
+
62
+ [shoe(1)](shoe.1.html),
63
+ <http://docs.rubygems.org/read/chapter/20>,
64
+ <http://semver.org/>
@@ -0,0 +1,62 @@
1
+ require 'logger'
2
+ require 'rubygems/format'
3
+ require 'stringio'
4
+ require 'webrick'
5
+
6
+ module Shoe
7
+ module TestExtensions
8
+
9
+ class FakeRubygemsServer
10
+ def self.start(&block)
11
+ new.start(&block)
12
+ end
13
+
14
+ def initialize(host='127.0.0.1', port=48484)
15
+ @initial_rubygems_host = ENV['RUBYGEMS_HOST']
16
+ @fake_rubygems_host = "http://#{host}:#{port}"
17
+
18
+ @message_bus = Queue.new
19
+ @webrick = WEBrick::HTTPServer.new(
20
+ # Ruby is super slow to create the underlying Socket if
21
+ # (my ISP's upstream connection is flakey? and) we don't
22
+ # specify a BindAddress.
23
+ :BindAddress => host,
24
+ :Port => port,
25
+ :Logger => Logger.new(nil),
26
+ :AccessLog => [],
27
+ :StartCallback => lambda { @message_bus.push(:ready) }
28
+ )
29
+
30
+ @webrick.mount_proc('/api/v1/gems') do |req, res|
31
+ @uploaded_gem = req.body
32
+ @uploaded_gem.extend(GemEntries)
33
+ end
34
+ end
35
+
36
+ def start(&block)
37
+ ENV['RUBYGEMS_HOST'] = @fake_rubygems_host
38
+ thread = Thread.new { @webrick.start }
39
+ @message_bus.pop
40
+ block.call
41
+ return @uploaded_gem
42
+ ensure
43
+ ENV['RUBYGEMS_HOST'] = @initial_rubygems_host
44
+ @webrick.shutdown
45
+ thread.join
46
+ end
47
+
48
+ private
49
+
50
+ module GemEntries
51
+ def contents
52
+ package.file_entries.map { |entry| entry.first['path'] }
53
+ end
54
+
55
+ def package
56
+ Gem::Format::from_io(StringIO.new(self))
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
@@ -0,0 +1,73 @@
1
+ require 'open3'
2
+ require 'pathname'
3
+
4
+ module Shoe
5
+ module TestExtensions
6
+
7
+ module HelperMethods
8
+ attr_reader :stdout, :stderr
9
+
10
+ def system(*args)
11
+ stdin, stdout, stderr = Open3.popen3(*args)
12
+ stdin.close
13
+ @stdout = stdout.read
14
+ @stderr = stderr.read
15
+ end
16
+
17
+ def find(string)
18
+ root = Pathname.new(string)
19
+ root.enum_for(:find).
20
+ select { |path| path.file? }.
21
+ collect { |path| path.relative_path_from(root).to_s }
22
+ end
23
+
24
+ def write_file(path, contents)
25
+ path = Pathname.new(path)
26
+ path.parent.mkpath
27
+ path.open('w') { |stream| stream.write(contents) }
28
+ end
29
+
30
+ def in_project(name)
31
+ Dir.mkdir(name)
32
+ Dir.chdir(name)
33
+ end
34
+
35
+ def assert_file(path)
36
+ assert Pathname.new(path).exist?, "#{path} does not exist."
37
+ end
38
+
39
+ def assert_find(path, expected)
40
+ assert_equal expected.sort, find(path).sort
41
+ end
42
+
43
+ def assert_no_task(name)
44
+ system 'rake --tasks'
45
+ assert_no_match /\srake #{name}\s/, stdout
46
+ end
47
+
48
+ def assert_task(name)
49
+ system 'rake --tasks'
50
+ assert_match /\srake #{name}\s/, stdout
51
+ end
52
+
53
+ def add_files_for_c_extension
54
+ write_file "ext/foo/extconf.rb", <<-END.gsub(/^ */, '')
55
+ require 'mkmf'
56
+ create_makefile 'foo/extension'
57
+ END
58
+
59
+ write_file "ext/foo/extension.c", <<-END.gsub(/^ */, '')
60
+ #include "ruby.h"
61
+ static VALUE mFoo;
62
+ static VALUE mExtension;
63
+ void Init_extension() {
64
+ mFoo = rb_define_module("Foo");
65
+ mExtension = rb_define_module_under(mFoo, "Extension");
66
+ }
67
+ END
68
+ end
69
+
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,50 @@
1
+ require 'tempfile'
2
+
3
+ module Shoe
4
+ module TestExtensions
5
+
6
+ module IsolatedEnvironment
7
+ def setup
8
+ @environment = Environment.new
9
+ @environment.setup do |env|
10
+ env.path('PATH') { |path| path.unshift Pathname.new('bin').expand_path }
11
+ env.path('RUBYLIB') { |path| path.unshift Pathname.new('lib').expand_path }
12
+ end
13
+ super
14
+ end
15
+
16
+ def teardown
17
+ super
18
+ @environment.teardown
19
+ end
20
+
21
+ private
22
+
23
+ class Environment
24
+ def setup
25
+ @initial_environment = {}
26
+ ENV.each { |name, value| @initial_environment[name] = value }
27
+ yield self
28
+ @initial_directory = Dir.pwd
29
+ @working_directory = Dir.mktmpdir
30
+ Dir.chdir(@working_directory)
31
+ end
32
+
33
+ def path(name)
34
+ path = ENV[name].to_s.split(File::PATH_SEPARATOR)
35
+ yield path
36
+ ENV[name] = path.join(File::PATH_SEPARATOR)
37
+ end
38
+
39
+ def teardown
40
+ Dir.chdir(@initial_directory)
41
+ FileUtils.remove_entry_secure(@working_directory)
42
+ ENV.clear
43
+ @initial_environment.each { |name, value| ENV[name] = value }
44
+ end
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+
@@ -0,0 +1,40 @@
1
+ module Shoe
2
+ module TestExtensions
3
+
4
+ module TestCase
5
+ def isolate_environment
6
+ include IsolatedEnvironment
7
+ end
8
+
9
+ def include_helper_methods
10
+ include HelperMethods
11
+ end
12
+
13
+ def pending(name, options={}, &block)
14
+ warn "WARN: Pending test \"#{name}\""
15
+ end
16
+
17
+ def test(name, options={}, &block)
18
+ if !block_given?
19
+ pending(name, options, &block)
20
+ return
21
+ end
22
+
23
+ requires = Array(options[:require])
24
+
25
+ requires.each do |lib|
26
+ begin
27
+ require lib
28
+ rescue LoadError
29
+ warn "WARN: #{lib} is not available.\n Skipping test \"#{name}\""
30
+ define_method('default_test', lambda {})
31
+ return
32
+ end
33
+ end
34
+
35
+ define_method("test #{name}", &block)
36
+ end
37
+ end
38
+
39
+ end
40
+ end