jeweler 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.markdown +8 -0
- data/README.markdown +2 -4
- data/Rakefile +9 -4
- data/VERSION.yml +2 -2
- data/lib/jeweler/generator.rb +39 -108
- data/lib/jeweler/generator/application.rb +8 -3
- data/lib/jeweler/generator/bacon_mixin.rb +39 -0
- data/lib/jeweler/generator/micronaut_mixin.rb +38 -0
- data/lib/jeweler/generator/minitest_mixin.rb +39 -0
- data/lib/jeweler/generator/options.rb +5 -1
- data/lib/jeweler/generator/rspec_mixin.rb +39 -0
- data/lib/jeweler/generator/shoulda_mixin.rb +39 -0
- data/lib/jeweler/generator/testunit_mixin.rb +39 -0
- data/lib/jeweler/templates/README.rdoc +1 -1
- data/lib/jeweler/templates/Rakefile +26 -26
- data/lib/jeweler/templates/bacon/helper.rb +1 -1
- data/lib/jeweler/templates/features/support/env.rb +4 -7
- data/lib/jeweler/templates/micronaut/helper.rb +1 -1
- data/lib/jeweler/templates/minitest/helper.rb +1 -1
- data/lib/jeweler/templates/rspec/helper.rb +1 -1
- data/lib/jeweler/templates/shoulda/helper.rb +1 -1
- data/lib/jeweler/templates/testunit/helper.rb +1 -1
- data/test/test_application.rb +26 -0
- data/test/test_gemspec_helper.rb +4 -0
- data/test/test_generator.rb +80 -113
- data/test/test_generator_initialization.rb +113 -0
- data/test/test_generator_mixins.rb +18 -0
- data/test/test_helper.rb +1 -0
- data/test/test_options.rb +6 -0
- data/test/version_tmp/VERSION.yml +1 -1
- metadata +23 -5
- data/test/generators/initialization_test.rb +0 -146
data/ChangeLog.markdown
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# jeweler 0.11.1
|
2
|
+
|
3
|
+
* Lots of internal refactorings to how project generation happens
|
4
|
+
* Fixed missing dependency on rubyforge
|
5
|
+
* Depend on a recent version of schacon-git which works on ruby 1.9
|
6
|
+
* Updated cucumber support for 0.3.x
|
7
|
+
* Tested on Ruby 1.9
|
8
|
+
|
1
9
|
# jeweler 0.11.0 2009-04-05
|
2
10
|
|
3
11
|
* generator will respect JEWELER_OPTS, as a way to provide default options
|
data/README.markdown
CHANGED
@@ -7,10 +7,8 @@ Jeweler provides two things:
|
|
7
7
|
|
8
8
|
## Installing
|
9
9
|
|
10
|
-
# Run the following if you haven't done so before:
|
11
|
-
gem sources -a http://gems.github.com
|
12
10
|
# Install the gem:
|
13
|
-
sudo gem install
|
11
|
+
sudo gem install jeweler
|
14
12
|
|
15
13
|
## Using in an existing project
|
16
14
|
|
@@ -119,7 +117,7 @@ With this in place, you now update your Jeweler::Tasks to setup `rubyforge_proje
|
|
119
117
|
s.rubyforge_project = 'the-perfect-gem' # This line would be new
|
120
118
|
end
|
121
119
|
rescue LoadError
|
122
|
-
puts "Jeweler not available. Install it with: sudo gem install
|
120
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
123
121
|
end
|
124
122
|
|
125
123
|
# These are new tasks
|
data/Rakefile
CHANGED
@@ -2,6 +2,9 @@ require 'rake'
|
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift('lib')
|
4
4
|
|
5
|
+
gem 'schacon-git'
|
6
|
+
require 'git'
|
7
|
+
|
5
8
|
begin
|
6
9
|
require 'jeweler'
|
7
10
|
Jeweler::Tasks.new do |gem|
|
@@ -12,19 +15,21 @@ begin
|
|
12
15
|
gem.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
13
16
|
gem.authors = ["Josh Nichols"]
|
14
17
|
gem.files.include %w(lib/jeweler/templates/.document lib/jeweler/templates/.gitignore)
|
15
|
-
gem.add_dependency "
|
18
|
+
gem.add_dependency "schacon-git", ">= 1.1.1"
|
19
|
+
gem.add_dependency "rubyforge"
|
16
20
|
gem.rubyforge_project = "pickles"
|
17
21
|
end
|
18
22
|
rescue LoadError
|
19
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install
|
23
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
20
24
|
end
|
21
25
|
|
22
26
|
require 'rake/testtask'
|
23
27
|
Rake::TestTask.new(:test) do |test|
|
24
|
-
test.
|
28
|
+
test.test_files = FileList.new('test/**/test_*.rb') do |list|
|
29
|
+
list.exclude 'test/test_helper.rb'
|
30
|
+
end
|
25
31
|
test.libs << 'test'
|
26
32
|
test.verbose = true
|
27
|
-
#test.ruby_opts << '-rtest_helper'
|
28
33
|
end
|
29
34
|
|
30
35
|
require 'rake/rdoctask'
|
data/VERSION.yml
CHANGED
data/lib/jeweler/generator.rb
CHANGED
@@ -4,6 +4,13 @@ require 'erb'
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'uri'
|
6
6
|
|
7
|
+
require 'jeweler/generator/bacon_mixin'
|
8
|
+
require 'jeweler/generator/micronaut_mixin'
|
9
|
+
require 'jeweler/generator/minitest_mixin'
|
10
|
+
require 'jeweler/generator/rspec_mixin'
|
11
|
+
require 'jeweler/generator/shoulda_mixin'
|
12
|
+
require 'jeweler/generator/testunit_mixin'
|
13
|
+
|
7
14
|
class Jeweler
|
8
15
|
class NoGitUserName < StandardError
|
9
16
|
end
|
@@ -22,28 +29,33 @@ class Jeweler
|
|
22
29
|
|
23
30
|
class Generator
|
24
31
|
attr_accessor :target_dir, :user_name, :user_email, :summary, :testing_framework,
|
25
|
-
:
|
32
|
+
:project_name, :github_username, :github_token,
|
26
33
|
:repo, :should_create_repo, :should_use_cucumber, :should_setup_rubyforge
|
27
34
|
|
28
|
-
|
35
|
+
DEFAULT_TESTING_FRAMEWORK = :shoulda
|
29
36
|
|
30
|
-
def initialize(
|
31
|
-
if
|
37
|
+
def initialize(project_name, options = {})
|
38
|
+
if project_name.nil? || project_name.squeeze.strip == ""
|
32
39
|
raise NoGitHubRepoNameGiven
|
33
40
|
end
|
34
41
|
|
35
|
-
self.
|
42
|
+
self.project_name = project_name
|
36
43
|
|
37
|
-
self.testing_framework = (options[:testing_framework] ||
|
38
|
-
|
44
|
+
self.testing_framework = (options[:testing_framework] || DEFAULT_TESTING_FRAMEWORK).to_sym
|
45
|
+
begin
|
46
|
+
generator_mixin_name = "#{self.testing_framework.to_s.capitalize}Mixin"
|
47
|
+
generator_mixin = self.class.const_get(generator_mixin_name)
|
48
|
+
extend generator_mixin
|
49
|
+
rescue NameError => e
|
39
50
|
raise ArgumentError, "Unsupported testing framework (#{testing_framework})"
|
40
51
|
end
|
41
52
|
|
42
|
-
self.target_dir = options[:directory] || self.github_repo_name
|
43
53
|
|
44
|
-
self.
|
45
|
-
|
46
|
-
self.
|
54
|
+
self.target_dir = options[:directory] || self.project_name
|
55
|
+
|
56
|
+
self.should_create_repo = options[:create_repo]
|
57
|
+
self.summary = options[:summary] || 'TODO'
|
58
|
+
self.should_use_cucumber = options[:use_cucumber]
|
47
59
|
self.should_setup_rubyforge = options[:rubyforge]
|
48
60
|
|
49
61
|
use_user_git_config
|
@@ -53,106 +65,39 @@ class Jeweler
|
|
53
65
|
def run
|
54
66
|
create_files
|
55
67
|
gitify
|
56
|
-
$stdout.puts "Jeweler has prepared your gem in #{
|
68
|
+
$stdout.puts "Jeweler has prepared your gem in #{target_dir}"
|
57
69
|
if should_create_repo
|
58
70
|
create_and_push_repo
|
59
|
-
$stdout.puts "Jeweler has pushed your repo to #{
|
71
|
+
$stdout.puts "Jeweler has pushed your repo to #{project_homepage}"
|
60
72
|
enable_gem_for_repo
|
61
73
|
$stdout.puts "Jeweler has enabled gem building for your repo"
|
62
74
|
end
|
63
75
|
end
|
64
76
|
|
65
|
-
|
66
|
-
|
67
|
-
test_or_spec
|
68
|
-
end
|
69
|
-
|
70
|
-
# Default rake task to use
|
71
|
-
def default_task
|
72
|
-
case testing_framework.to_sym
|
73
|
-
when :shoulda, :testunit, :minitest
|
74
|
-
'test'
|
75
|
-
when :bacon, :rspec
|
76
|
-
'spec'
|
77
|
-
when :micronaut
|
78
|
-
'examples'
|
79
|
-
else
|
80
|
-
raise ArgumentError, "Don't know default task for #{testing_framework}"
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def feature_support_require
|
85
|
-
case testing_framework.to_sym
|
86
|
-
when :testunit, :shoulda, :bacon # NOTE bacon doesn't really work inside of cucumber
|
87
|
-
'test/unit/assertions'
|
88
|
-
when :minitest
|
89
|
-
'mini/test'
|
90
|
-
when :rspec
|
91
|
-
'spec/expectations'
|
92
|
-
when :micronaut
|
93
|
-
'micronaut/expectations'
|
94
|
-
else
|
95
|
-
raise "Don't know what to require for #{testing_framework}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def feature_support_extend
|
100
|
-
case testing_framework.to_sym
|
101
|
-
when :testunit, :shoulda, :bacon # NOTE bacon doesn't really work inside of cucumber
|
102
|
-
'Test::Unit::Assertions'
|
103
|
-
when :minitest
|
104
|
-
'Mini::Test::Assertions'
|
105
|
-
when :rspec
|
106
|
-
nil
|
107
|
-
when :micronaut
|
108
|
-
'Micronaut::Matchers'
|
109
|
-
else
|
110
|
-
raise "Don't know what to extend for #{testing_framework}"
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def github_remote
|
115
|
-
"git@github.com:#{github_username}/#{github_repo_name}.git"
|
77
|
+
def git_remote
|
78
|
+
"git@github.com:#{github_username}/#{project_name}.git"
|
116
79
|
end
|
117
80
|
|
118
|
-
def
|
119
|
-
"http://github.com/#{github_username}/#{
|
81
|
+
def project_homepage
|
82
|
+
"http://github.com/#{github_username}/#{project_name}"
|
120
83
|
end
|
121
|
-
|
122
84
|
|
123
85
|
def constant_name
|
124
|
-
self.
|
86
|
+
self.project_name.split(/[-_]/).collect{|each| each.capitalize }.join
|
87
|
+
end
|
88
|
+
|
89
|
+
def require_name
|
90
|
+
self.project_name.gsub('-', '_')
|
125
91
|
end
|
126
92
|
|
127
93
|
def file_name_prefix
|
128
|
-
self.
|
94
|
+
self.project_name.gsub('-', '_')
|
129
95
|
end
|
130
96
|
|
131
97
|
def lib_dir
|
132
98
|
'lib'
|
133
99
|
end
|
134
100
|
|
135
|
-
def test_dir
|
136
|
-
case testing_framework.to_sym
|
137
|
-
when :shoulda, :testunit, :minitest
|
138
|
-
'test'
|
139
|
-
when :bacon, :rspec
|
140
|
-
'spec'
|
141
|
-
when :micronaut
|
142
|
-
'examples'
|
143
|
-
else
|
144
|
-
raise ArgumentError, "Don't know test dir for #{testing_framework.inspect}"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_filename
|
149
|
-
"#{file_name_prefix}_#{test_or_spec}.rb"
|
150
|
-
end
|
151
|
-
|
152
|
-
def test_helper_filename
|
153
|
-
"#{test_or_spec}_helper.rb"
|
154
|
-
end
|
155
|
-
|
156
101
|
def feature_filename
|
157
102
|
"#{file_name_prefix}.feature"
|
158
103
|
end
|
@@ -173,20 +118,6 @@ class Jeweler
|
|
173
118
|
File.join(features_dir, 'step_definitions')
|
174
119
|
end
|
175
120
|
|
176
|
-
def test_or_spec
|
177
|
-
case testing_framework.to_sym
|
178
|
-
when :shoulda, :testunit, :minitest
|
179
|
-
'test'
|
180
|
-
when :bacon, :rspec
|
181
|
-
'spec'
|
182
|
-
when :micronaut
|
183
|
-
'example'
|
184
|
-
else
|
185
|
-
raise ArgumentError, "Unknown test style: #{testing_framework}"
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
|
190
121
|
protected
|
191
122
|
|
192
123
|
# This is in a separate method so we can stub it out during testing
|
@@ -306,13 +237,13 @@ class Jeweler
|
|
306
237
|
end
|
307
238
|
|
308
239
|
begin
|
309
|
-
@repo.commit "Initial commit to #{
|
240
|
+
@repo.commit "Initial commit to #{project_name}."
|
310
241
|
rescue Git::GitExecuteError => e
|
311
242
|
raise
|
312
243
|
end
|
313
244
|
|
314
245
|
begin
|
315
|
-
@repo.add_remote('origin',
|
246
|
+
@repo.add_remote('origin', git_remote)
|
316
247
|
rescue Git::GitExecuteError => e
|
317
248
|
puts "Encountered an error while adding origin remote. Maybe you have some weird settings in ~/.gitconfig?"
|
318
249
|
raise
|
@@ -327,13 +258,13 @@ class Jeweler
|
|
327
258
|
'login' => github_username,
|
328
259
|
'token' => github_token,
|
329
260
|
'repository[description]' => summary,
|
330
|
-
'repository[name]' =>
|
261
|
+
'repository[name]' => project_name
|
331
262
|
# TODO do a HEAD request to see when it's ready
|
332
263
|
@repo.push('origin')
|
333
264
|
end
|
334
265
|
|
335
266
|
def enable_gem_for_repo
|
336
|
-
url = "https://github.com/#{github_username}/#{
|
267
|
+
url = "https://github.com/#{github_username}/#{project_name}/update"
|
337
268
|
`curl -F 'login=#{github_username}' -F 'token=#{github_token}' -F 'field=repository_rubygem' -F 'value=1' #{url} 2>/dev/null`
|
338
269
|
# FIXME use NET::HTTP instead of curl
|
339
270
|
#Net::HTTP.post_form URI.parse(url),
|
@@ -9,6 +9,11 @@ class Jeweler
|
|
9
9
|
options = Jeweler::Generator::Options.new(arguments)
|
10
10
|
options = options.merge(env_opts) if env_opts
|
11
11
|
|
12
|
+
if options[:invalid_argument]
|
13
|
+
$stderr.puts options[:invalid_argument]
|
14
|
+
options[:show_help] = true
|
15
|
+
end
|
16
|
+
|
12
17
|
if options[:show_help]
|
13
18
|
$stderr.puts options.opts
|
14
19
|
return 1
|
@@ -19,10 +24,10 @@ class Jeweler
|
|
19
24
|
return 1
|
20
25
|
end
|
21
26
|
|
22
|
-
|
27
|
+
project_name = arguments.first
|
23
28
|
|
24
29
|
begin
|
25
|
-
generator = Jeweler::Generator.new(
|
30
|
+
generator = Jeweler::Generator.new(project_name, options)
|
26
31
|
generator.run
|
27
32
|
return 0
|
28
33
|
rescue Jeweler::NoGitUserName
|
@@ -38,7 +43,7 @@ class Jeweler
|
|
38
43
|
$stderr.puts %Q{No github.token found in ~/.gitconfig. Please tell git about your GitHub account (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.token 6ef8395fecf207165f1a82178ae1b984}
|
39
44
|
return 1
|
40
45
|
rescue Jeweler::FileInTheWay
|
41
|
-
$stderr.puts "The directory #{
|
46
|
+
$stderr.puts "The directory #{project_name} already exists. Maybe move it out of the way before continuing?"
|
42
47
|
return 1
|
43
48
|
end
|
44
49
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class Generator
|
3
|
+
module BaconMixin
|
4
|
+
|
5
|
+
def default_task
|
6
|
+
'spec'
|
7
|
+
end
|
8
|
+
|
9
|
+
def feature_support_require
|
10
|
+
'test/unit/assertions'
|
11
|
+
end
|
12
|
+
|
13
|
+
def feature_support_extend
|
14
|
+
'Test::Unit::Assertions' # NOTE can't use bacon inside of cucumber actually
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_dir
|
18
|
+
'spec'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_task
|
22
|
+
'spec'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_pattern
|
26
|
+
'spec/**/*_spec.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_filename
|
30
|
+
"#{require_name}_spec.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_helper_filename
|
34
|
+
"spec_helper.rb"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class Generator
|
3
|
+
module MicronautMixin
|
4
|
+
|
5
|
+
def default_task
|
6
|
+
'examples'
|
7
|
+
end
|
8
|
+
|
9
|
+
def feature_support_require
|
10
|
+
'micronaut/expectations'
|
11
|
+
end
|
12
|
+
|
13
|
+
def feature_support_extend
|
14
|
+
'Micronaut::Matchers'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_dir
|
18
|
+
'examples'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_task
|
22
|
+
'examples'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_pattern
|
26
|
+
'examples/**/*_example.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_filename
|
30
|
+
"#{require_name}_example.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_helper_filename
|
34
|
+
"example_helper.rb"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class Generator
|
3
|
+
module MinitestMixin
|
4
|
+
|
5
|
+
def default_task
|
6
|
+
'test'
|
7
|
+
end
|
8
|
+
|
9
|
+
def feature_support_require
|
10
|
+
'mini/test'
|
11
|
+
end
|
12
|
+
|
13
|
+
def feature_support_extend
|
14
|
+
'Mini::Test::Assertions'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_dir
|
18
|
+
'test'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_task
|
22
|
+
'test'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_pattern
|
26
|
+
'test/**/*_test.rb'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_filename
|
30
|
+
"#{require_name}_test.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_helper_filename
|
34
|
+
"test_helper.rb"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|