jeweler 0.11.0 → 0.11.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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 technicalpickles-jeweler
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 technicalpickles-jeweler -s http://gems.github.com"
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 "peterwald-git"
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 technicalpickles-jeweler -s http://gems.github.com"
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.pattern = 'test/**/test_*.rb'
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'
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
2
  :minor: 11
4
- :patch: 0
3
+ :patch: 1
4
+ :major: 0
@@ -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
- :github_repo_name, :github_username, :github_token,
32
+ :project_name, :github_username, :github_token,
26
33
  :repo, :should_create_repo, :should_use_cucumber, :should_setup_rubyforge
27
34
 
28
- SUPPORTED_TESTING_FRAMEWORKS = [:shoulda, :testunit, :bacon, :rspec, :micronaut, :minitest]
35
+ DEFAULT_TESTING_FRAMEWORK = :shoulda
29
36
 
30
- def initialize(github_repo_name, options = {})
31
- if github_repo_name.nil? || github_repo_name.squeeze.strip == ""
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.github_repo_name = github_repo_name
42
+ self.project_name = project_name
36
43
 
37
- self.testing_framework = (options[:testing_framework] || :shoulda).to_sym
38
- unless SUPPORTED_TESTING_FRAMEWORKS.include? self.testing_framework
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.should_create_repo = options[:create_repo]
45
- self.summary = options[:summary] || 'TODO'
46
- self.should_use_cucumber= options[:use_cucumber]
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 #{github_repo_name}"
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 #{github_url}"
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
- # Directory where 'tests' live
66
- def test_dir
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 github_url
119
- "http://github.com/#{github_username}/#{github_repo_name}"
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.github_repo_name.split(/[-_]/).collect{|each| each.capitalize }.join
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.github_repo_name.gsub('-', '_')
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 #{github_repo_name}."
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', github_remote)
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]' => github_repo_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}/#{github_repo_name}/update"
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
- github_repo_name = arguments.first
27
+ project_name = arguments.first
23
28
 
24
29
  begin
25
- generator = Jeweler::Generator.new(github_repo_name, options)
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 #{github_repo_name} already exists. Maybe move it out of the way before continuing?"
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