shoe 0.6.2 → 0.7.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.
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
@@ -1,81 +0,0 @@
1
- module Shoe
2
- module Tasks
3
-
4
- # Defines <tt>`rake release`</tt> to release your gem.
5
- #
6
- # To release is to: commit, tag, optionally push (with tags), and then
7
- # build and push your gem.
8
- #
9
- # This task is enabled under very specific circumstances, to safeguard
10
- # against accidental releases:
11
- # 1. Your <tt>version[http://docs.rubygems.org/read/chapter/20#version]</tt> is greater than <tt>0.0.0</tt>.
12
- # 2. There is no existing git tag <tt>"v#{version}"</tt>.
13
- # 3. You are currently on the <tt>master</tt> branch.
14
- #
15
- # To configure, adjust the
16
- # <tt>version[http://docs.rubygems.org/read/chapter/20#version]</tt> in
17
- # your gemspec.
18
- #
19
- # = Semantic Versioning
20
- #
21
- # Shoe helps you follow the Tagging Specification of {Semantic
22
- # Versioning}[http://semver.org] by tagging your releases as
23
- # <tt>"v#{version}"</tt>, prefixing a <tt>"v"</tt> before the version
24
- # number.
25
- #
26
- # Shoe additionally complains if you haven't yet created a <tt>semver</tt>
27
- # tag to denote your compliance.
28
- class Release < Abstract
29
- def active?
30
- spec.has_version_greater_than?('0.0.0') &&
31
- there_is_no_tag_for(version_tag(spec.version)) &&
32
- we_are_on_the_master_branch
33
- end
34
-
35
- def define
36
- desc "Release #{spec.full_name}."
37
- task :release do
38
- sh "git commit -a -m 'Release #{spec.version}'"
39
- sh "git tag #{version_tag(spec.version)}"
40
-
41
- if there_is_no_tag_for('semver')
42
- warn "WARN: Please `git tag semver`. <http://semver.org/>"
43
- end
44
-
45
- if there_is_a_remote_called('origin')
46
- sh 'git push origin master'
47
- sh 'git push --tags origin'
48
- end
49
-
50
- sh "gem build #{spec.name}.gemspec"
51
- sh "gem push #{spec.file_name}"
52
- end
53
-
54
- namespace :prepare do
55
- task :release
56
- end
57
-
58
- task :release => 'prepare:release'
59
- end
60
-
61
- private
62
-
63
- def there_is_a_remote_called(name)
64
- `git remote`.to_a.include?("#{name}\n")
65
- end
66
-
67
- def there_is_no_tag_for(tag)
68
- !`git tag`.to_a.include?("#{tag}\n")
69
- end
70
-
71
- def version_tag(version)
72
- "v#{spec.version}"
73
- end
74
-
75
- def we_are_on_the_master_branch
76
- `git symbolic-ref HEAD`.strip == 'refs/heads/master'
77
- end
78
- end
79
-
80
- end
81
- end
data/man/shoe.1 DELETED
@@ -1,63 +0,0 @@
1
- .\" generated with Ronn/v0.5
2
- .\" http://github.com/rtomayko/ronn/
3
- .
4
- .TH "SHOE" "1" "April 2010" "Matthew Todd" "RubyGems Manual"
5
- .
6
- .SH "NAME"
7
- \fBshoe\fR \-\- generate a RubyGems project
8
- .
9
- .SH "SYNOPSIS"
10
- \fBshoe\fR [\-\fBadehtv\fR] [\fIpath\fR]
11
- .
12
- .SH "DESCRIPTION"
13
- The \fBshoe\fR command generates a new RubyGems project. Big deal, right? As
14
- compared with other tools, \fBshoe\fR gently guides you toward hygenic packaging
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
- .
18
- .SH "OPTIONS"
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
- .
22
- .P
23
- To generate additional files, use the following options:
24
- .
25
- .TP
26
- \fB\-a\fR, \fB\-\-[no\-]application\fR
27
- Generate a command\-line application. Create a simple executable script in
28
- the \fBbin\fR directory and an \fBoptparse\fR\-based \fBApplication\fR class.
29
- .
30
- .TP
31
- \fB\-d\fR, \fB\-\-[no\-]data\fR
32
- Generate a data directory. Create a \fBdata\fR directory (perfect for HTML
33
- templates and other static assets) and a \fBdatadir\fR method in your top\-level
34
- module to access it.
35
- .
36
- .TP
37
- \fB\-e\fR, \fB\-\-[no\-]extension\fR
38
- Generate a C extension. Create an \fBext\fR directory with an \fBextconf.rb\fR and
39
- a bare\-bones \fBextension.c\fR defining a module named \fBExtension\fR.
40
- .
41
- .TP
42
- \fB\-t\fR, \fB\-\-[no\-]test\-unit\fR
43
- Generate Test::Unit tests. Create a \fBtest\fR directory with a \fBhelper.rb\fR
44
- and a single passing test.
45
- .
46
- .P
47
- \fBshoe\fR also responds to the following standard options:
48
- .
49
- .TP
50
- \fB\-h\fR, \fB\-\-help\fR
51
- Print a help message and exit.
52
- .
53
- .TP
54
- \fB\-v\fR, \fB\-\-version\fR[=all]
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.
57
- .
58
- .SH "AUTHOR"
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!
61
- .
62
- .SH "SEE ALSO"
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
@@ -1,60 +0,0 @@
1
- shoe(1) -- generate a RubyGems project
2
- ======================================
3
-
4
- ## SYNOPSIS
5
-
6
- `shoe` [-`adehtv`] [_path_]
7
-
8
- ## DESCRIPTION
9
-
10
- The `shoe` command generates a new RubyGems project. Big deal, right? As
11
- compared with other tools, `shoe` gently guides you toward hygenic packaging
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
-
15
- ## OPTIONS
16
-
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
-
21
- To generate additional files, use the following options:
22
-
23
- * `-a`, `--[no-]application`:
24
- Generate a command-line application. Create a simple executable script in
25
- the `bin` directory and an `optparse`-based `Application` class.
26
-
27
- * `-d`, `--[no-]data`:
28
- Generate a data directory. Create a `data` directory (perfect for HTML
29
- templates and other static assets) and a `datadir` method in your top-level
30
- module to access it.
31
-
32
- * `-e`, `--[no-]extension`:
33
- Generate a C extension. Create an `ext` directory with an `extconf.rb` and
34
- a bare-bones `extension.c` defining a module named `Extension`.
35
-
36
- * `-t`, `--[no-]test-unit`:
37
- Generate Test::Unit tests. Create a `test` directory with a `helper.rb`
38
- and a single passing test.
39
-
40
- `shoe` also responds to the following standard options:
41
-
42
- * `-h`, `--help`:
43
- Print a help message and exit.
44
-
45
- * `-v`, `--version`[=all]:
46
- Print `shoe`'s version number and exit. If `=all` is given, also print
47
- version numbers of `shoe`'s dependencies.
48
-
49
- ## AUTHOR
50
-
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!
53
-
54
- ## SEE ALSO
55
-
56
- [shoe(3)](shoe.3.html),
57
- <http://chneukirchen.github.com/rps/>,
58
- <http://gembundler.com/>,
59
- <http://defunkt.github.com/rip/>,
60
- <http://github.com/rtomayko/rpg>
@@ -1,62 +0,0 @@
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
@@ -1,73 +0,0 @@
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
@@ -1,50 +0,0 @@
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
-
@@ -1,40 +0,0 @@
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
@@ -1,36 +0,0 @@
1
- require 'test/helper'
2
-
3
- class RakeCleanTest < Test::Unit::TestCase
4
- isolate_environment
5
- include_helper_methods
6
-
7
- def setup
8
- super
9
- in_project 'foo'
10
- system 'shoe'
11
- end
12
-
13
- test 'rake clean is active only if there is a .git directory' do
14
- assert_no_task 'clean'
15
- system 'git init'
16
- assert_task 'clean'
17
- end
18
-
19
- test 'rake clean removes ignored files, excluding .rvmrc and .bundler' do
20
- system 'git init'
21
-
22
- write_file '.gitignore', <<-END.gsub(/^ */, '')
23
- .bundle
24
- .rvmrc
25
- bar
26
- END
27
-
28
- write_file '.bundle/config.rb', '# STAYING ALIVE'
29
- write_file '.rvmrc', '# STAYING ALIVE'
30
- write_file 'bar', 'NOT LONG FOR THIS WORLD'
31
-
32
- files_before_clean = find('.')
33
- system 'rake clean'
34
- assert_find '.', files_before_clean - ['bar']
35
- end
36
- end