gemma 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +85 -37
- data/bin/gemma +134 -0
- data/lib/gemma.rb +4 -9
- data/lib/gemma/conventions.rb +52 -0
- data/lib/gemma/gem_from_template.rb +134 -0
- data/lib/gemma/options.rb +3 -0
- data/lib/gemma/rake_tasks.rb +11 -11
- data/lib/gemma/rake_tasks/rcov_tasks.rb +19 -12
- data/lib/gemma/rake_tasks/rdoc_tasks.rb +11 -12
- data/lib/gemma/rake_tasks/run_tasks.rb +73 -0
- data/lib/gemma/rake_tasks/test_unit_tasks.rb +19 -7
- data/lib/gemma/rake_tasks/yard_tasks.rb +28 -30
- data/lib/gemma/utility.rb +41 -0
- data/lib/gemma/version.rb +1 -1
- data/template/base/.gitignore +6 -0
- data/template/base/README.rdoc.erb +49 -0
- data/template/base/Rakefile.rb.erb +10 -0
- data/template/base/gem_name.gemspec.erb +32 -0
- data/template/base/lib/gem_name.rb.erb +5 -0
- data/template/base/lib/gem_name/version.rb.erb +3 -0
- data/template/executable/bin/gem_name.erb +6 -0
- data/template/test_unit/test/test_gem_name.rb.erb +9 -0
- data/test/test_gemma.rb +64 -12
- metadata +57 -18
- data/lib/gemma/rake_tasks/gem_tasks.rb +0 -74
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require '<%= gem_name %>/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = '<%= gem_name %>'
|
9
|
+
s.version = <%= module_name %>::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ['TODO write your name']
|
12
|
+
s.email = ['TODO write your e-mail address']
|
13
|
+
s.homepage = 'TODO homepage'
|
14
|
+
s.summary = %q{TODO write gem summary}
|
15
|
+
s.description = %q{TODO write gem description}
|
16
|
+
|
17
|
+
s.rubyforge_project = '<%= gem_name %>'
|
18
|
+
|
19
|
+
#s.add_runtime_dependency '...'
|
20
|
+
s.add_development_dependency 'gemma', '>= <%= Gemma::VERSION %>', '<%=
|
21
|
+
gemma_version_requirement %>'
|
22
|
+
|
23
|
+
s.files = Dir.glob('{lib,bin}/**/*.rb') + %w(README.rdoc)
|
24
|
+
s.test_files = Dir.glob('test/test_*.rb')
|
25
|
+
s.executables = Dir.glob('bin/*').map{|f| File.basename(f)}
|
26
|
+
|
27
|
+
s.rdoc_options = [
|
28
|
+
"--main", "README.rdoc",
|
29
|
+
"--title", "#{s.full_name} Documentation"]
|
30
|
+
s.extra_rdoc_files << "README.rdoc"
|
31
|
+
end
|
32
|
+
|
data/test/test_gemma.rb
CHANGED
@@ -4,12 +4,13 @@ require "gemma"
|
|
4
4
|
require "set"
|
5
5
|
|
6
6
|
class TestGemma < Test::Unit::TestCase
|
7
|
+
# Can load empty spec.
|
7
8
|
def test_empty_spec
|
8
9
|
s = Gem::Specification.new
|
9
10
|
Gemma::RakeTasks.new(s)
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
+
def test_rdoc_tasks
|
13
14
|
s = Gem::Specification.new
|
14
15
|
s.files = %w(lib/a.rb lib/b.rb)
|
15
16
|
s.test_files = %w(test/test_a.rb test/test_a.rb)
|
@@ -17,8 +18,7 @@ class TestGemma < Test::Unit::TestCase
|
|
17
18
|
s.extra_rdoc_files = ['README.md', 'FAQ']
|
18
19
|
|
19
20
|
Gemma::RakeTasks.new(s) do |g|
|
20
|
-
assert_equal %w(lib
|
21
|
-
g.rdoc.files.to_set
|
21
|
+
assert_equal %w(lib FAQ README.md).to_set, g.rdoc.files.to_set
|
22
22
|
assert_equal [], g.rdoc.options
|
23
23
|
assert_equal 'README.md', g.rdoc.main
|
24
24
|
assert_equal nil, g.rdoc.title
|
@@ -29,7 +29,18 @@ class TestGemma < Test::Unit::TestCase
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def test_run_tasks
|
33
|
+
s = Gem::Specification.new
|
34
|
+
s.files = %w(lib/a.rb)
|
35
|
+
s.executables = %w(a b)
|
36
|
+
s.test_files = %w(test/test_a.rb)
|
37
|
+
|
38
|
+
Gemma::RakeTasks.new(s) do |g|
|
39
|
+
assert_equal %w(a b).to_set, g.run.program_names.to_set
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_yard_tasks
|
33
44
|
s = Gem::Specification.new
|
34
45
|
s.files = %w(lib/a.rb)
|
35
46
|
s.test_files = %w(test/test_a.rb)
|
@@ -40,7 +51,7 @@ class TestGemma < Test::Unit::TestCase
|
|
40
51
|
# A file should not be passed as an extra file if it's the --main file.
|
41
52
|
# Test files should not be documented.
|
42
53
|
Gemma::RakeTasks.new(s) do |g|
|
43
|
-
assert_equal %w(lib
|
54
|
+
assert_equal %w(lib), g.yard.files
|
44
55
|
assert_equal [], g.yard.extra_files
|
45
56
|
assert_equal 'README.rdoc', g.yard.main
|
46
57
|
assert_equal [], g.yard.options
|
@@ -49,7 +60,7 @@ class TestGemma < Test::Unit::TestCase
|
|
49
60
|
assert_equal nil, g.yard.title
|
50
61
|
|
51
62
|
g.yard.with_yardoc_task do |yd|
|
52
|
-
assert_equal %w(lib
|
63
|
+
assert_equal %w(lib), yd.files
|
53
64
|
assert_equal 4, yd.options.size
|
54
65
|
assert_equal 'README.rdoc',
|
55
66
|
Gemma::Options.extract(%w(--main), yd.options).argument
|
@@ -61,7 +72,7 @@ class TestGemma < Test::Unit::TestCase
|
|
61
72
|
# Add some extra files (that aren't the --main file).
|
62
73
|
s.extra_rdoc_files << 'FAQ'
|
63
74
|
Gemma::RakeTasks.new(s) do |g|
|
64
|
-
assert_equal %w(lib
|
75
|
+
assert_equal %w(lib), g.yard.files
|
65
76
|
assert_equal %w(FAQ), g.yard.extra_files
|
66
77
|
assert_equal 'README.rdoc', g.yard.main
|
67
78
|
assert_equal [], g.yard.options
|
@@ -70,14 +81,14 @@ class TestGemma < Test::Unit::TestCase
|
|
70
81
|
# Make sure extra options are ignored.
|
71
82
|
s.rdoc_options = ['--main', 'README.rdoc', '--diagram']
|
72
83
|
Gemma::RakeTasks.new(s) do |g|
|
73
|
-
assert_equal %w(lib
|
84
|
+
assert_equal %w(lib), g.yard.files
|
74
85
|
assert_equal %w(FAQ), g.yard.extra_files
|
75
86
|
assert_equal 'README.rdoc', g.yard.main
|
76
87
|
assert_equal [], g.yard.options
|
77
88
|
end
|
78
89
|
s.rdoc_options = ['--diagram', '--main', 'README.rdoc']
|
79
90
|
Gemma::RakeTasks.new(s) do |g|
|
80
|
-
assert_equal %w(lib
|
91
|
+
assert_equal %w(lib), g.yard.files
|
81
92
|
assert_equal %w(FAQ), g.yard.extra_files
|
82
93
|
assert_equal 'README.rdoc', g.yard.main
|
83
94
|
assert_equal [], g.yard.options
|
@@ -92,7 +103,7 @@ class TestGemma < Test::Unit::TestCase
|
|
92
103
|
assert_equal [], g.yard.options
|
93
104
|
|
94
105
|
g.yard.with_yardoc_task do |yd|
|
95
|
-
assert_equal %w(lib
|
106
|
+
assert_equal %w(lib - FAQ), yd.files
|
96
107
|
assert_equal 6, yd.options.size
|
97
108
|
assert_equal 'README.rdoc',
|
98
109
|
Gemma::Options.extract(%w(--main), yd.options).argument
|
@@ -104,7 +115,7 @@ class TestGemma < Test::Unit::TestCase
|
|
104
115
|
end
|
105
116
|
end
|
106
117
|
|
107
|
-
def
|
118
|
+
def test_test_unit_tasks
|
108
119
|
s = Gem::Specification.new
|
109
120
|
s.files = %w(lib/a.rb lib/b.rb)
|
110
121
|
s.test_files = %w(test/test_a.rb test/test_b.rb)
|
@@ -119,7 +130,7 @@ class TestGemma < Test::Unit::TestCase
|
|
119
130
|
end
|
120
131
|
end
|
121
132
|
|
122
|
-
def
|
133
|
+
def test_rcov_tasks
|
123
134
|
s = Gem::Specification.new
|
124
135
|
s.files = %w(lib/a.rb lib/b.rb)
|
125
136
|
s.test_files = %w(test/test_a.rb test/test_b.rb)
|
@@ -133,5 +144,46 @@ class TestGemma < Test::Unit::TestCase
|
|
133
144
|
end
|
134
145
|
end
|
135
146
|
end
|
147
|
+
|
148
|
+
def test_conventions_good_gem_name
|
149
|
+
assert Gemma::Conventions.good_gem_name?("my_gem_name")
|
150
|
+
assert Gemma::Conventions.good_gem_name?("my-gem-name")
|
151
|
+
assert Gemma::Conventions.good_gem_name?("foo")
|
152
|
+
assert Gemma::Conventions.good_gem_name?("foo1")
|
153
|
+
assert Gemma::Conventions.good_gem_name?("foo_4_bar")
|
154
|
+
assert !Gemma::Conventions.good_gem_name?("Foo")
|
155
|
+
assert !Gemma::Conventions.good_gem_name?("FooBar")
|
156
|
+
assert !Gemma::Conventions.good_gem_name?("Foo_Bar")
|
157
|
+
assert !Gemma::Conventions.good_gem_name?("Foo-Bar")
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_conventions_gem_name_to_module_name
|
161
|
+
assert_equal 'MyGem',
|
162
|
+
Gemma::Conventions.gem_name_to_module_name("my_gem")
|
163
|
+
assert_equal 'MyGem3',
|
164
|
+
Gemma::Conventions.gem_name_to_module_name("my_gem3")
|
165
|
+
assert_equal 'A4B',
|
166
|
+
Gemma::Conventions.gem_name_to_module_name("a_4_b")
|
167
|
+
assert_equal 'A4b',
|
168
|
+
Gemma::Conventions.gem_name_to_module_name("a4b")
|
169
|
+
end
|
170
|
+
|
171
|
+
#
|
172
|
+
# Exercise usage message for bin/gemma.
|
173
|
+
#
|
174
|
+
def test_print_usage
|
175
|
+
gemma_file = File.join(File.dirname(__FILE__), '..', 'bin', 'gemma')
|
176
|
+
io = StringIO.new
|
177
|
+
Gemma::Utility.print_usage_from_file_comment gemma_file, '#', io
|
178
|
+
assert io.string =~ /gemma/
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_plugin_abstract
|
182
|
+
s = Gem::Specification.new
|
183
|
+
plugin = Gemma::RakeTasks::Plugin.new(s)
|
184
|
+
assert_raise(NotImplementedError) {
|
185
|
+
plugin.create_rake_tasks # abstract method
|
186
|
+
}
|
187
|
+
end
|
136
188
|
end
|
137
189
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.2
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Lees-Miller
|
@@ -15,35 +15,72 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-12-06 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: highline
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 6
|
33
|
+
- 1
|
34
|
+
version: 1.6.1
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
hash: 3
|
38
|
+
segments:
|
39
|
+
- 1
|
40
|
+
- 6
|
41
|
+
version: "1.6"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id001
|
22
44
|
description: |
|
23
|
-
|
24
|
-
|
25
|
-
|
45
|
+
Gemma is a gem development helper like hoe and jeweler, but it keeps the
|
46
|
+
gemspec in a gemspec file, where it belongs, instead of in your Rakefile.
|
47
|
+
This helps your gem to play nicely with commands like gem and bundle, and it
|
48
|
+
allows gemma to provide rake tasks with sensible defaults for many common gem
|
49
|
+
development tasks.
|
26
50
|
|
27
51
|
email:
|
28
52
|
- jdleesmiller@gmail.com
|
29
|
-
executables:
|
30
|
-
|
53
|
+
executables:
|
54
|
+
- gemma
|
31
55
|
extensions: []
|
32
56
|
|
33
57
|
extra_rdoc_files:
|
34
58
|
- README.rdoc
|
59
|
+
- bin/gemma
|
35
60
|
files:
|
36
|
-
- lib/gemma
|
61
|
+
- lib/gemma.rb
|
62
|
+
- lib/gemma/options.rb
|
63
|
+
- lib/gemma/gem_from_template.rb
|
64
|
+
- lib/gemma/conventions.rb
|
65
|
+
- lib/gemma/rake_tasks/test_unit_tasks.rb
|
66
|
+
- lib/gemma/rake_tasks/rdoc_tasks.rb
|
37
67
|
- lib/gemma/rake_tasks/rcov_tasks.rb
|
68
|
+
- lib/gemma/rake_tasks/run_tasks.rb
|
38
69
|
- lib/gemma/rake_tasks/yard_tasks.rb
|
39
|
-
- lib/gemma/rake_tasks/rdoc_tasks.rb
|
40
|
-
- lib/gemma/rake_tasks/test_unit_tasks.rb
|
41
70
|
- lib/gemma/rake_tasks/plugin.rb
|
42
|
-
- lib/gemma/options.rb
|
43
|
-
- lib/gemma/rake_tasks.rb
|
44
71
|
- lib/gemma/version.rb
|
45
|
-
- lib/gemma.rb
|
72
|
+
- lib/gemma/rake_tasks.rb
|
73
|
+
- lib/gemma/utility.rb
|
74
|
+
- template/base/.gitignore
|
75
|
+
- template/base/Rakefile.rb.erb
|
76
|
+
- template/base/README.rdoc.erb
|
77
|
+
- template/base/gem_name.gemspec.erb
|
78
|
+
- template/base/lib/gem_name.rb.erb
|
79
|
+
- template/base/lib/gem_name/version.rb.erb
|
80
|
+
- template/executable/bin/gem_name.erb
|
81
|
+
- template/test_unit/test/test_gem_name.rb.erb
|
46
82
|
- README.rdoc
|
83
|
+
- bin/gemma
|
47
84
|
- test/test_options.rb
|
48
85
|
- test/test_gemma.rb
|
49
86
|
has_rdoc: true
|
@@ -54,6 +91,8 @@ post_install_message:
|
|
54
91
|
rdoc_options:
|
55
92
|
- --main
|
56
93
|
- README.rdoc
|
94
|
+
- --title
|
95
|
+
- gemma-1.0.0 Documentation
|
57
96
|
require_paths:
|
58
97
|
- lib
|
59
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -80,7 +119,7 @@ rubyforge_project:
|
|
80
119
|
rubygems_version: 1.3.7
|
81
120
|
signing_key:
|
82
121
|
specification_version: 3
|
83
|
-
summary:
|
122
|
+
summary: Gemspec-centric gem development helper.
|
84
123
|
test_files:
|
85
124
|
- test/test_options.rb
|
86
125
|
- test/test_gemma.rb
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module Gemma
|
2
|
-
class RakeTasks
|
3
|
-
#
|
4
|
-
# Create tasks to build and release (push) gems.
|
5
|
-
#
|
6
|
-
# TODO not done yet
|
7
|
-
#
|
8
|
-
class GemTasks < Plugin
|
9
|
-
#
|
10
|
-
# @param [Gem::Specification] gemspec
|
11
|
-
# @param [String, nil] gemspec_file_name
|
12
|
-
#
|
13
|
-
def initialize gemspec, gemspec_file_name
|
14
|
-
super(gemspec)
|
15
|
-
|
16
|
-
@gemspec_file_name = gemspec_file_name
|
17
|
-
|
18
|
-
# Defaults.
|
19
|
-
@output = 'pkg'
|
20
|
-
end
|
21
|
-
|
22
|
-
#
|
23
|
-
# Name of the gemspec file to be built; if this is nil, no gem tasks are
|
24
|
-
# generated.
|
25
|
-
#
|
26
|
-
# @return [String, nil]
|
27
|
-
#
|
28
|
-
attr_accessor :gemspec_file_name
|
29
|
-
|
30
|
-
#
|
31
|
-
# Name of directory in which gem files are placed; defaults to pkg.
|
32
|
-
#
|
33
|
-
# @return [String]
|
34
|
-
#
|
35
|
-
attr_accessor :output
|
36
|
-
|
37
|
-
#
|
38
|
-
# Full path to gem file.
|
39
|
-
#
|
40
|
-
# @return [String]
|
41
|
-
#
|
42
|
-
def gem_file
|
43
|
-
File.join(output, gemspec.file_name)
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# Internal method; see {Plugin#create_rake_tasks}.
|
48
|
-
#
|
49
|
-
# @return [nil]
|
50
|
-
#
|
51
|
-
# @private
|
52
|
-
#
|
53
|
-
def create_rake_tasks
|
54
|
-
if gemspec_file_name
|
55
|
-
directory output
|
56
|
-
|
57
|
-
desc "gem build"
|
58
|
-
task :build => output do
|
59
|
-
sh "gem build #{gemspec_file_name}"
|
60
|
-
mv gemspec.file_name, gem_file
|
61
|
-
end
|
62
|
-
CLOBBER.include(gem_file)
|
63
|
-
|
64
|
-
desc "gem release"
|
65
|
-
task :release => :build do
|
66
|
-
sh "gem push #{gem_file}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
nil
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|