shoe 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{data/shoe/templates/gitignore.erb → .gitignore} +1 -1
- data/.rvmrc +1 -0
- data/CHANGELOG.rdoc +9 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +39 -0
- data/README.rdoc +20 -72
- data/Rakefile +6 -0
- data/TODO.rdoc +10 -5
- data/lib/shoe.rb +29 -13
- data/lib/shoe/extensions.rb +0 -4
- data/lib/shoe/extensions/specification.rb +0 -4
- data/lib/shoe/extensions/validator.rb +40 -11
- data/lib/shoe/tasks.rb +13 -22
- data/lib/shoe/tasks/clean.rb +4 -4
- data/lib/shoe/tasks/compile.rb +2 -4
- data/lib/shoe/tasks/cucumber.rb +5 -9
- data/lib/shoe/tasks/rdoc.rb +2 -3
- data/lib/shoe/tasks/ronn.rb +5 -5
- data/lib/shoe/tasks/{abstract.rb → task.rb} +1 -1
- data/lib/shoe/tasks/test.rb +17 -57
- data/lib/shoe/util/minitest_colors.rb +60 -0
- data/lib/shoe/version.rb +3 -0
- data/man/shoe.3 +5 -11
- data/man/shoe.3.ronn +4 -13
- data/shoe.gemspec +35 -0
- data/test/helper.rb +6 -12
- data/test/support/assertions.rb +45 -0
- data/test/support/command_runner.rb +11 -0
- data/test/support/declarative_tests.rb +24 -0
- data/test/support/example_project.rb +37 -0
- data/test/support/file_manipulation.rb +43 -0
- data/test/support/gemspec_manipulation.rb +24 -0
- data/test/support/project_files.rb +60 -0
- data/test/support/redgreen.rb +6 -0
- data/test/system/rake_test.rb +124 -0
- metadata +75 -96
- data/bin/shoe +0 -18
- data/data/shoe/templates/application.erb +0 -23
- data/data/shoe/templates/executable.erb +0 -18
- data/data/shoe/templates/extconf.erb +0 -2
- data/data/shoe/templates/extension.erb +0 -25
- data/data/shoe/templates/gemspec.erb +0 -44
- data/data/shoe/templates/gitkeep.erb +0 -0
- data/data/shoe/templates/manpage_1.erb +0 -29
- data/data/shoe/templates/manpage_3.erb +0 -19
- data/data/shoe/templates/module.erb +0 -31
- data/data/shoe/templates/module_test.rb +0 -7
- data/data/shoe/templates/rakefile.erb +0 -3
- data/data/shoe/templates/readme.erb +0 -3
- data/data/shoe/templates/test_helper.erb +0 -9
- data/lib/shoe/extensions/option_parser.rb +0 -52
- data/lib/shoe/extensions/pathname.rb +0 -16
- data/lib/shoe/extensions/source_index.rb +0 -17
- data/lib/shoe/extensions/test_runner.rb +0 -28
- data/lib/shoe/generator.rb +0 -147
- data/lib/shoe/tasks/release.rb +0 -81
- data/man/shoe.1 +0 -63
- data/man/shoe.1.ronn +0 -60
- data/test/extensions/fake_rubygems_server.rb +0 -62
- data/test/extensions/helper_methods.rb +0 -73
- data/test/extensions/isolated_environment.rb +0 -50
- data/test/extensions/test_case.rb +0 -40
- data/test/system/rake_clean_test.rb +0 -36
- data/test/system/rake_compile_test.rb +0 -25
- data/test/system/rake_cucumber_test.rb +0 -51
- data/test/system/rake_rdoc_test.rb +0 -26
- data/test/system/rake_release_test.rb +0 -94
- data/test/system/rake_ronn_test.rb +0 -25
- data/test/system/rake_test_test.rb +0 -45
- data/test/system/shoe_test.rb +0 -79
data/bin/shoe
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'shoe'
|
5
|
-
rescue LoadError
|
6
|
-
raise unless $!.message =~ /\bshoe$/
|
7
|
-
|
8
|
-
lib = File.expand_path('../../lib', __FILE__)
|
9
|
-
if !$:.include?(lib)
|
10
|
-
warn "WARN: #{$!}.\n Trying again with #{lib} on the $LOAD_PATH..."
|
11
|
-
$:.unshift(lib)
|
12
|
-
retry
|
13
|
-
end
|
14
|
-
|
15
|
-
raise
|
16
|
-
end
|
17
|
-
|
18
|
-
Shoe::Generator.new.run(ARGV)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'optparse'
|
2
|
-
|
3
|
-
module <%= module_name %>
|
4
|
-
class Application
|
5
|
-
def initialize
|
6
|
-
@options = OptionParser.new do |opts|
|
7
|
-
# -h, --help, -v, --version are built into OptionParser
|
8
|
-
# Try `<%= name %> --version=all` as you require more libraries!
|
9
|
-
opts.version = <%= module_name %>::VERSION
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def run(argv)
|
14
|
-
begin
|
15
|
-
@options.parse(argv)
|
16
|
-
rescue OptionParser::ParseError
|
17
|
-
@options.abort($!)
|
18
|
-
end
|
19
|
-
|
20
|
-
# Have at it!
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
begin
|
4
|
-
require '<%= name %>'
|
5
|
-
rescue LoadError
|
6
|
-
raise unless $!.message =~ /\b<%= name %>$/
|
7
|
-
|
8
|
-
lib = File.expand_path('../../lib', __FILE__)
|
9
|
-
if !$:.include?(lib)
|
10
|
-
warn "#{$!}. Trying again with #{lib} on the $LOAD_PATH."
|
11
|
-
$:.unshift(lib)
|
12
|
-
retry
|
13
|
-
end
|
14
|
-
|
15
|
-
raise
|
16
|
-
end
|
17
|
-
|
18
|
-
<%= module_name %>::Application.new.run(ARGV)
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#include "ruby.h"
|
2
|
-
|
3
|
-
static VALUE m<%= module_name %>;
|
4
|
-
static VALUE m<%= extension_module_name %>;
|
5
|
-
|
6
|
-
/*
|
7
|
-
* Document-class: <%= extension_module_name %>
|
8
|
-
* Document-method: run
|
9
|
-
*
|
10
|
-
* call-seq:
|
11
|
-
* run -> nil
|
12
|
-
*
|
13
|
-
*/
|
14
|
-
static VALUE run(VALUE self) {
|
15
|
-
return Qnil;
|
16
|
-
}
|
17
|
-
|
18
|
-
/*
|
19
|
-
* Documentation for <%= extension_module_name %>.
|
20
|
-
*/
|
21
|
-
void Init_extension() {
|
22
|
-
m<%= module_name %> = rb_define_module("<%= module_name %>");
|
23
|
-
m<%= extension_module_name %> = rb_define_module_under(m<%= module_name %>, "<%= extension_module_name %>");
|
24
|
-
rb_define_method(m<%= extension_module_name %>, "run", run, 0);
|
25
|
-
}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path('../lib', __FILE__)
|
2
|
-
require '<%= name %>'
|
3
|
-
|
4
|
-
# Feel free to change whatever you like! This file is yours now.
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = '<%= name %>'
|
7
|
-
spec.version = <%= module_name %>::VERSION
|
8
|
-
|
9
|
-
spec.summary = '<%= module_name %> is one of my favorite things!'
|
10
|
-
spec.description = <<-END.gsub(/^ */, '')
|
11
|
-
#{spec.summary}
|
12
|
-
|
13
|
-
Further description here.
|
14
|
-
END
|
15
|
-
|
16
|
-
spec.author = '<%= `git config --get user.name`.chomp %>'
|
17
|
-
spec.email = '<%= `git config --get user.email`.chomp %>'
|
18
|
-
spec.homepage = 'http://github.com/<%= `git config --get github.user`.chomp %>/<%= name %>'
|
19
|
-
|
20
|
-
# You may find these helpful:
|
21
|
-
# spec.requirements = ['git'] # If your library shells out to git
|
22
|
-
# spec.required_rubygems_version = ">= 1.3.6" # If you depend on prerelease gems
|
23
|
-
# spec.add_runtime_dependency 'nokogiri' # Or what have you
|
24
|
-
# spec.add_development_dependency 'cucumber'
|
25
|
-
# spec.add_development_dependency 'redgreen'
|
26
|
-
# spec.add_development_dependency 'ronn'
|
27
|
-
spec.add_development_dependency 'shoe'
|
28
|
-
|
29
|
-
# The kooky &File.method(:basename) trick keeps us from accidentally
|
30
|
-
# shadowing a variable named "file" in the context that evaluates this
|
31
|
-
# gemspec. I actually ran into this problem with Bundler!
|
32
|
-
spec.files = Dir['**/*.rdoc', 'bin/*', 'data/**/*', 'ext/**/*.{rb,c}', 'lib/**/*.rb', 'man/**/*', 'test/**/*.rb']
|
33
|
-
spec.executables = Dir['bin/*'].map &File.method(:basename)
|
34
|
-
spec.extensions = Dir['ext/**/extconf.rb']
|
35
|
-
spec.extra_rdoc_files = Dir['**/*.rdoc', 'ext/**/*.c']
|
36
|
-
spec.test_files = Dir['test/**/*_test.rb']
|
37
|
-
|
38
|
-
spec.rdoc_options = %W(
|
39
|
-
--main README.rdoc
|
40
|
-
--title #{spec.full_name}
|
41
|
-
--inline-source
|
42
|
-
--webcvs http://github.com/<%= `git config --get github.user`.chomp %>/<%= name %>/blob/v#{spec.version}/
|
43
|
-
)
|
44
|
-
end
|
File without changes
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<%= name %>(1) --
|
2
|
-
=================
|
3
|
-
|
4
|
-
## SYNOPSIS
|
5
|
-
|
6
|
-
`<%= name %>` [_options_]
|
7
|
-
|
8
|
-
## DESCRIPTION
|
9
|
-
|
10
|
-
Write your description here.
|
11
|
-
|
12
|
-
## OPTIONS
|
13
|
-
|
14
|
-
`<%= name %>` also responds to the following standard options:
|
15
|
-
|
16
|
-
* `-h`, `--help`:
|
17
|
-
Print a help message and exit.
|
18
|
-
|
19
|
-
* `-v`, `--version`[=all]:
|
20
|
-
Print `<%= name %>`'s version number and exit. If `=all` is given, also print
|
21
|
-
version numbers of `<%= name %>`'s dependencies.
|
22
|
-
|
23
|
-
## AUTHOR
|
24
|
-
|
25
|
-
<%= `git config --get user.name`.chomp %>, [<%= `git config --get github.user`.chomp %>](http://github.com/<%= `git config --get github.user`.chomp %>) on GitHub.
|
26
|
-
|
27
|
-
## SEE ALSO
|
28
|
-
|
29
|
-
<%= name %>(3)
|
@@ -1,19 +0,0 @@
|
|
1
|
-
<%= name %>(3) --
|
2
|
-
=================
|
3
|
-
|
4
|
-
## SYNOPSIS
|
5
|
-
|
6
|
-
`require '<%= name %>'`
|
7
|
-
<%= module_name %>.somthing(_parameter_)
|
8
|
-
|
9
|
-
## DESCRIPTION
|
10
|
-
|
11
|
-
Write your description here.
|
12
|
-
|
13
|
-
## AUTHOR
|
14
|
-
|
15
|
-
<%= `git config --get user.name`.chomp %>, [<%= `git config --get github.user`.chomp %>](http://github.com/<%= `git config --get github.user`.chomp %>) on GitHub.
|
16
|
-
|
17
|
-
## SEE ALSO
|
18
|
-
|
19
|
-
ruby(1)
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<% if data? %>
|
2
|
-
require 'pathname'
|
3
|
-
require 'rbconfig'
|
4
|
-
require 'rbconfig/datadir'
|
5
|
-
|
6
|
-
<% end %>
|
7
|
-
module <%= module_name %>
|
8
|
-
VERSION = '<%= version %>'
|
9
|
-
<% if application? || extension? %>
|
10
|
-
|
11
|
-
<% end %>
|
12
|
-
<% if application? %>
|
13
|
-
autoload :Application, '<%= name %>/application'
|
14
|
-
<% end %>
|
15
|
-
<% if extension? %>
|
16
|
-
autoload :<%= extension_module_name %>, '<%= name %>/<%= extension_name %>'
|
17
|
-
<% end %>
|
18
|
-
<% if data? %>
|
19
|
-
|
20
|
-
def self.datadir
|
21
|
-
@@datadir ||= begin
|
22
|
-
datadir = RbConfig.datadir('<%= name %>')
|
23
|
-
if !File.exist?(datadir)
|
24
|
-
warn "#{datadir} does not exist. Trying again with data directory relative to __FILE__."
|
25
|
-
datadir = File.expand_path('../../data/<%= name %>', __FILE__)
|
26
|
-
end
|
27
|
-
Pathname.new(datadir)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
<% end %>
|
31
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require '<%= name %>'
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'redgreen' if $stdout.tty?
|
6
|
-
rescue LoadError
|
7
|
-
# It's nice not to have hard dependencies on any gems for testing, so that
|
8
|
-
# it's super-easy for your users to run `gem check --test <%= name %>.`
|
9
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Shoe
|
2
|
-
module Extensions
|
3
|
-
|
4
|
-
# This extension allows for default options in OptionParser, processing
|
5
|
-
# them before any given options and appending them nicely to the help
|
6
|
-
# message. (It also does the conventional thing and errors with usage when
|
7
|
-
# there's trouble parsing options.)
|
8
|
-
#
|
9
|
-
# Note that it's important to use #order rather than #permute, to ensure
|
10
|
-
# that the given options have a chance to override the defaults. (These are
|
11
|
-
# <tt>POSIX</tt>-ly correct semantics.)
|
12
|
-
#
|
13
|
-
# To use:
|
14
|
-
# parser = OptionsParser.new do |opts|
|
15
|
-
# opts.extend(Shoe::Extensions::OptionParser)
|
16
|
-
# opts.defaults = %w(--foo --no-bar --baz=42)
|
17
|
-
# # ... and so on ...
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# parser.order(ARGV)
|
21
|
-
module OptionParser
|
22
|
-
attr_reader :defaults
|
23
|
-
|
24
|
-
def defaults=(defaults)
|
25
|
-
@defaults = defaults.extend(Defaults)
|
26
|
-
end
|
27
|
-
|
28
|
-
def order(*args, &block)
|
29
|
-
super(*defaults.followed_by(*args), &block)
|
30
|
-
rescue ::OptionParser::ParseError
|
31
|
-
abort($!)
|
32
|
-
end
|
33
|
-
|
34
|
-
def help
|
35
|
-
defaults.help(super, summary_indent)
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
module Defaults #:nodoc:
|
41
|
-
def followed_by(*args)
|
42
|
-
dup.concat(args.flatten)
|
43
|
-
end
|
44
|
-
|
45
|
-
def help(before, indent)
|
46
|
-
"#{before}\nDefaults:\n#{indent}#{join ' '}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Shoe
|
2
|
-
module Extensions
|
3
|
-
|
4
|
-
module TestRunner
|
5
|
-
# Conforms the normal TestRunner interface to the slightly different form
|
6
|
-
# called by Gem::Validator.
|
7
|
-
#
|
8
|
-
# Note that we use Test::Unit::AutoRunner (rather than going directly for
|
9
|
-
# Test::Unit::UI::Console::TestRunner) in order to give redgreen a chance
|
10
|
-
# to register itself, should it have been required in one of the
|
11
|
-
# test_files.
|
12
|
-
def self.run(suite, ui)
|
13
|
-
runner = Test::Unit::AutoRunner.new(false)
|
14
|
-
runner.collector = lambda { suite }
|
15
|
-
runner.run.extend(BooleanPassed)
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
module BooleanPassed #:nodoc:
|
21
|
-
def passed?
|
22
|
-
self
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
data/lib/shoe/generator.rb
DELETED
@@ -1,147 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'optparse'
|
3
|
-
require 'pathname'
|
4
|
-
|
5
|
-
module Shoe
|
6
|
-
class Generator
|
7
|
-
def initialize
|
8
|
-
@options = {}
|
9
|
-
@parser = OptionParser.new do |opts|
|
10
|
-
opts.extend(Extensions::OptionParser)
|
11
|
-
|
12
|
-
opts.banner = "Usage: #{File.basename($0)} [-adehtv] [path]"
|
13
|
-
opts.defaults = %w(--no-application --no-data --no-extension --test-unit .)
|
14
|
-
opts.version = Shoe::VERSION
|
15
|
-
|
16
|
-
opts.on('-a', '--[no-]application', 'Generate a command-line application.') do |application|
|
17
|
-
@options[:application] = application
|
18
|
-
end
|
19
|
-
|
20
|
-
opts.on('-d', '--[no-]data', 'Generate a data directory.') do |data|
|
21
|
-
@options[:data] = data
|
22
|
-
end
|
23
|
-
|
24
|
-
opts.on('-e', '--[no-]extension', 'Generate a C extension.') do |extension|
|
25
|
-
@options[:extension] = extension
|
26
|
-
end
|
27
|
-
|
28
|
-
opts.on('-t', '--[no-]test-unit', 'Generate Test::Unit tests.') do |test_unit|
|
29
|
-
@options[:test_unit] = test_unit
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def run(arguments)
|
35
|
-
@parser.order(arguments) { |path| @project = Project.new(path, @options) }
|
36
|
-
|
37
|
-
@project.generate
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
|
43
|
-
class Project
|
44
|
-
def initialize(path, options)
|
45
|
-
@path = Pathname.new(path)
|
46
|
-
@options = options
|
47
|
-
end
|
48
|
-
|
49
|
-
def generate
|
50
|
-
install('gitignore.erb', '.gitignore')
|
51
|
-
install('readme.erb', 'README.rdoc')
|
52
|
-
install('rakefile.erb', 'Rakefile')
|
53
|
-
install('gemspec.erb', "#{name}.gemspec")
|
54
|
-
install('module.erb', "lib/#{name}.rb")
|
55
|
-
install('manpage_3.erb', "man/#{name}.3.ronn")
|
56
|
-
|
57
|
-
if application?
|
58
|
-
install('executable.erb', "bin/#{name}", 0755)
|
59
|
-
install('application.erb', "lib/#{name}/application.rb")
|
60
|
-
install('manpage_1.erb', "man/#{name}.1.ronn")
|
61
|
-
end
|
62
|
-
|
63
|
-
if data?
|
64
|
-
install('gitkeep.erb', "data/#{name}/.gitkeep")
|
65
|
-
end
|
66
|
-
|
67
|
-
if extension?
|
68
|
-
install('extconf.erb', "ext/#{name}/extconf.rb")
|
69
|
-
install('extension.erb', "ext/#{name}/#{extension_name}.c")
|
70
|
-
end
|
71
|
-
|
72
|
-
if test_unit?
|
73
|
-
install('test_helper.erb', "test/helper.rb")
|
74
|
-
install('module_test.rb', "test/#{name}_test.rb")
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def install(template, path, mode=0644)
|
81
|
-
installable_path(path).install(contents(template), mode)
|
82
|
-
end
|
83
|
-
|
84
|
-
def application?
|
85
|
-
@options[:application]
|
86
|
-
end
|
87
|
-
|
88
|
-
def data?
|
89
|
-
@options[:data]
|
90
|
-
end
|
91
|
-
|
92
|
-
def extension?
|
93
|
-
@options[:extension]
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_unit?
|
97
|
-
@options[:test_unit]
|
98
|
-
end
|
99
|
-
|
100
|
-
def name
|
101
|
-
@path.expand_path.basename.to_s
|
102
|
-
end
|
103
|
-
|
104
|
-
def module_name
|
105
|
-
name.capitalize.gsub(/_(\w)/) { $1.upcase }
|
106
|
-
end
|
107
|
-
|
108
|
-
def version
|
109
|
-
'0.0.0'
|
110
|
-
end
|
111
|
-
|
112
|
-
def extension_name
|
113
|
-
'extension'
|
114
|
-
end
|
115
|
-
|
116
|
-
def extension_module_name
|
117
|
-
extension_name.capitalize.gsub(/_(\w)/) { $1.upcase }
|
118
|
-
end
|
119
|
-
|
120
|
-
def installable_path(name)
|
121
|
-
path = @path.join(name)
|
122
|
-
path.dirname.mkpath
|
123
|
-
path.extend(Extensions::Pathname)
|
124
|
-
end
|
125
|
-
|
126
|
-
def contents(template)
|
127
|
-
Template.new(template).evaluate(binding)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
class Template
|
132
|
-
def initialize(name)
|
133
|
-
@name = name
|
134
|
-
end
|
135
|
-
|
136
|
-
def evaluate(binding)
|
137
|
-
ERB.new(contents, nil, '<>').result(binding)
|
138
|
-
end
|
139
|
-
|
140
|
-
private
|
141
|
-
|
142
|
-
def contents
|
143
|
-
Shoe.datadir.join('templates', @name).read
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|