jeweler 1.4.0 → 1.5.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.document +14 -0
  2. data/.gitignore +13 -2
  3. data/ChangeLog.markdown +8 -8
  4. data/Gemfile +21 -0
  5. data/Gemfile.lock +57 -0
  6. data/README.markdown +6 -6
  7. data/Rakefile +32 -46
  8. data/features/generator/cucumber.feature +20 -0
  9. data/features/generator/directory_layout.feature +10 -0
  10. data/features/generator/gemfile.feature +71 -0
  11. data/features/generator/git.feature +8 -0
  12. data/features/generator/license.feature +11 -2
  13. data/features/generator/rakefile.feature +25 -23
  14. data/features/generator/test.feature +6 -0
  15. data/features/generator/test_helper.feature +107 -11
  16. data/features/step_definitions/filesystem_steps.rb +5 -3
  17. data/features/step_definitions/generator_steps.rb +68 -4
  18. data/features/support/env.rb +26 -13
  19. data/jeweler.gemspec +222 -207
  20. data/lib/jeweler.rb +7 -5
  21. data/lib/jeweler/commands.rb +1 -3
  22. data/lib/jeweler/commands/check_dependencies.rb +3 -5
  23. data/lib/jeweler/commands/install_gem.rb +1 -2
  24. data/lib/jeweler/commands/release_to_git.rb +5 -3
  25. data/lib/jeweler/commands/release_to_github.rb +24 -8
  26. data/lib/jeweler/commands/{release_to_gemcutter.rb → release_to_rubygems.rb} +1 -2
  27. data/lib/jeweler/commands/version/base.rb +16 -2
  28. data/lib/jeweler/commands/write_gemspec.rb +0 -1
  29. data/lib/jeweler/errors.rb +4 -16
  30. data/lib/jeweler/gemcutter_tasks.rb +4 -32
  31. data/lib/jeweler/gemspec_helper.rb +3 -6
  32. data/lib/jeweler/generator.rb +23 -6
  33. data/lib/jeweler/generator/options.rb +17 -14
  34. data/lib/jeweler/generator/rspec_mixin.rb +1 -1
  35. data/lib/jeweler/generator/shindo_mixin.rb +44 -0
  36. data/lib/jeweler/generator/shoulda_mixin.rb +1 -1
  37. data/lib/jeweler/rubyforge_tasks.rb +5 -29
  38. data/lib/jeweler/rubygems_dot_org_tasks.rb +38 -0
  39. data/lib/jeweler/rubygems_tasks.rb +38 -0
  40. data/lib/jeweler/specification.rb +36 -12
  41. data/lib/jeweler/tasks.rb +49 -13
  42. data/lib/jeweler/templates/.document +6 -0
  43. data/lib/jeweler/templates/.gitignore +34 -16
  44. data/lib/jeweler/templates/Gemfile +12 -0
  45. data/lib/jeweler/templates/LICENSE +1 -1
  46. data/lib/jeweler/templates/Rakefile +1 -0
  47. data/lib/jeweler/templates/bacon/helper.rb +1 -0
  48. data/lib/jeweler/templates/bundler_setup.erb +10 -0
  49. data/lib/jeweler/templates/features/support/env.rb +2 -0
  50. data/lib/jeweler/templates/jeweler_tasks.erb +20 -23
  51. data/lib/jeweler/templates/micronaut/helper.rb +1 -0
  52. data/lib/jeweler/templates/minitest/helper.rb +1 -0
  53. data/lib/jeweler/templates/other_tasks.erb +27 -59
  54. data/lib/jeweler/templates/riot/helper.rb +1 -0
  55. data/lib/jeweler/templates/rspec/{spec.opts → .rspec} +0 -0
  56. data/lib/jeweler/templates/rspec/helper.rb +7 -3
  57. data/lib/jeweler/templates/shindo/flunking.rb +8 -0
  58. data/lib/jeweler/templates/shindo/helper.rb +6 -0
  59. data/lib/jeweler/templates/shoulda/helper.rb +1 -0
  60. data/lib/jeweler/templates/testunit/helper.rb +1 -0
  61. data/lib/jeweler/version.rb +10 -0
  62. data/lib/jeweler/version_helper.rb +1 -2
  63. data/test/fixtures/existing-project-with-version-constant/Rakefile +4 -2
  64. data/test/fixtures/existing-project-with-version-plaintext/Rakefile +4 -2
  65. data/test/fixtures/existing-project-with-version-yaml/Rakefile +4 -2
  66. data/test/jeweler/commands/test_install_gem.rb +2 -2
  67. data/test/jeweler/commands/test_release_to_gemcutter.rb +4 -4
  68. data/test/jeweler/commands/test_release_to_git.rb +32 -25
  69. data/test/jeweler/commands/test_release_to_github.rb +108 -25
  70. data/test/jeweler/generator/test_options.rb +16 -22
  71. data/test/jeweler/test_generator.rb +5 -0
  72. data/test/jeweler/test_specification.rb +18 -7
  73. data/test/jeweler/test_tasks.rb +1 -1
  74. data/test/test_helper.rb +12 -14
  75. data/test/test_jeweler.rb +0 -12
  76. metadata +159 -66
  77. data/VERSION.yml +0 -5
  78. data/lib/jeweler/commands/release_to_rubyforge.rb +0 -52
  79. data/lib/jeweler/commands/setup_rubyforge.rb +0 -63
  80. data/test/jeweler/commands/test_release_to_rubyforge.rb +0 -153
  81. data/test/jeweler/commands/test_setup_rubyforge.rb +0 -178
@@ -1,4 +1,3 @@
1
-
2
1
  class Jeweler
3
2
  class Generator
4
3
  class Options < Hash
@@ -10,11 +9,15 @@ class Jeweler
10
9
  @orig_args = args.clone
11
10
  self[:testing_framework] = :shoulda
12
11
  self[:documentation_framework] = :rdoc
13
- self[:gemcutter] = true
14
-
15
- git_config = Git.global_config
16
- self[:user_name] = git_config['user.name']
17
- self[:user_email] = git_config['user.email']
12
+ self[:use_bundler] = true
13
+
14
+ git_config = if Pathname.new("~/.gitconfig").expand_path.exist?
15
+ Git.global_config
16
+ else
17
+ {}
18
+ end
19
+ self[:user_name] = ENV['GIT_AUTHOR_NAME'] || ENV['GIT_COMMITTER_NAME'] || git_config['user.name']
20
+ self[:user_email] = ENV['GIT_AUTHOR_EMAIL'] || ENV['GIT_COMMITTER_EMAIL'] || git_config['user.email']
18
21
  self[:github_username] = git_config['github.user']
19
22
  self[:github_token] = git_config['github.token']
20
23
 
@@ -60,8 +63,16 @@ class Jeweler
60
63
  self[:testing_framework] = :riot
61
64
  end
62
65
 
66
+ o.on('--shindo', 'generate shindo tests') do
67
+ self[:testing_framework] = :shindo
68
+ end
69
+
63
70
  o.separator ""
64
71
 
72
+ o.on('--[no-]bundler', 'use bundler for managing dependencies') do |v|
73
+ self[:use_bundler] = v
74
+ end
75
+
65
76
  o.on('--cucumber', 'generate cucumber stories in addition to the other tests') do
66
77
  self[:use_cucumber] = true
67
78
  end
@@ -78,14 +89,6 @@ class Jeweler
78
89
 
79
90
  o.separator ""
80
91
 
81
- o.on('--[no-]gemcutter', 'setup project for gemcutter') do |v|
82
- self[:gemcutter] = v
83
- end
84
-
85
- o.on('--rubyforge', 'setup project for rubyforge') do
86
- self[:rubyforge] = true
87
- end
88
-
89
92
  o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
90
93
  self[:summary] = summary
91
94
  end
@@ -2,7 +2,7 @@ class Jeweler
2
2
  class Generator
3
3
  module RspecMixin
4
4
  def self.extended(generator)
5
- generator.development_dependencies << ["rspec", ">= 1.2.9"]
5
+ generator.development_dependencies << ["rspec", ">= 2.0.0.beta.19"]
6
6
  end
7
7
 
8
8
  def default_task
@@ -0,0 +1,44 @@
1
+ class Jeweler
2
+ class Generator
3
+ module ShindoMixin
4
+ def self.extended(generator)
5
+ generator.development_dependencies << ["shindo", ">= 0"]
6
+ end
7
+
8
+ def default_task
9
+ 'tests'
10
+ end
11
+
12
+ def feature_support_require
13
+ # 'test/unit/assertions'
14
+ nil
15
+ end
16
+
17
+ def feature_support_extend
18
+ # 'Test::Unit::Assertions'
19
+ nil
20
+ end
21
+
22
+ def test_dir
23
+ 'tests'
24
+ end
25
+
26
+ def test_task
27
+ 'tests'
28
+ end
29
+
30
+ def test_pattern
31
+ 'tests/**/*_tests.rb'
32
+ end
33
+
34
+ def test_filename
35
+ "#{require_name}_tests.rb"
36
+ end
37
+
38
+ def test_helper_filename
39
+ "tests_helper.rb"
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -2,7 +2,7 @@ class Jeweler
2
2
  class Generator
3
3
  module ShouldaMixin
4
4
  def self.extended(generator)
5
- generator.development_dependencies << ["thoughtbot-shoulda", ">= 0"]
5
+ generator.development_dependencies << ["shoulda", ">= 0"]
6
6
  end
7
7
 
8
8
  def default_task
@@ -31,7 +31,7 @@ class Jeweler
31
31
  def initialize
32
32
  yield self if block_given?
33
33
 
34
- self.doc_task = :rdoc if self.doc_task == nil # be sure to allow it to be set to false, to allow disabling
34
+ $stderr.puts "Releasing gems to Rubyforge is deprecated. See details at http://wiki.github.com/technicalpickles/jeweler/migrating-from-releasing-gems-to-rubyforge"
35
35
 
36
36
  define
37
37
  end
@@ -50,20 +50,10 @@ class Jeweler
50
50
 
51
51
  def define
52
52
  namespace :rubyforge do
53
-
54
53
  namespace :release do
55
54
  desc "Release the current gem version to RubyForge."
56
- task :gem => [:gemspec, :build] do
55
+ task :gem do
57
56
  $stderr.puts "DEPRECATION: Releasing gems to RubyForge is deprecated. You should see about releasing to Gemcutter instead: http://wiki.github.com/technicalpickles/jeweler/gemcutter"
58
- begin
59
- jeweler.release_gem_to_rubyforge
60
- rescue NoRubyForgeProjectInGemspecError => e
61
- abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
62
- rescue MissingRubyForgePackageError => e
63
- abort "Rubyforge reported that the #{e.message} package isn't setup. Run rake rubyforge:setup to do so."
64
- rescue RubyForgeProjectNotConfiguredError => e
65
- abort "RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"
66
- end
67
57
  end
68
58
 
69
59
  if publish_documentation?
@@ -88,24 +78,10 @@ class Jeweler
88
78
  end
89
79
  end
90
80
 
91
-
92
- desc "Release gem and RDoc documentation to RubyForge"
93
- task :release => "rubyforge:release:gem"
94
- task :release => "rubyforge:release:docs" if publish_documentation?
95
-
96
-
97
- desc "Setup a rubyforge project for this gem"
98
- task :setup do
99
- $stderr.puts "DEPRECATION: Releasing gems to RubyForge is deprecated. You should see about releasing to Gemcutter instead: http://wiki.github.com/technicalpickles/jeweler/gemcutter"
100
- begin
101
- jeweler.setup_rubyforge
102
- rescue NoRubyForgeProjectInGemspecError => e
103
- abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
104
- rescue RubyForgeProjectNotConfiguredError => e
105
- abort "The RubyForge reported that #{e.message} wasn't configured. This means you need to run 'rubyforge setup', 'rubyforge login', and 'rubyforge configure', or maybe the project doesn't exist on RubyForge"
106
- end
81
+ if publish_documentation?
82
+ desc "Release RDoc documentation to RubyForge"
83
+ task :release => "rubyforge:release:docs"
107
84
  end
108
-
109
85
  end
110
86
 
111
87
  task :release => 'rubyforge:release'
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ class Jeweler
5
+ # Rake tasks for putting a Jeweler gem on Gemcutter.
6
+ #
7
+ # Jeweler::Tasks.new needs to be used before this.
8
+ #
9
+ # Basic usage:
10
+ #
11
+ # Jeweler::RubygemsDotOrgTasks.new
12
+ #
13
+ # Easy enough, right?
14
+ class RubygemsDotOrgTasks < ::Rake::TaskLib
15
+ attr_accessor :jeweler
16
+
17
+ def initialize
18
+ yield self if block_given?
19
+
20
+ define
21
+ end
22
+
23
+ def jeweler
24
+ @jeweler ||= Rake.application.jeweler
25
+ end
26
+
27
+ def define
28
+ namespace :gemcutter do
29
+ desc "Release gem to Gemcutter"
30
+ task :release => [:gemspec, :build] do
31
+ jeweler.release_gem_to_rubygems
32
+ end
33
+ end
34
+
35
+ task :release => 'gemcutter:release'
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ class Jeweler
5
+ # Rake tasks for putting a Jeweler gem on Gemcutter.
6
+ #
7
+ # Jeweler::Tasks.new needs to be used before this.
8
+ #
9
+ # Basic usage:
10
+ #
11
+ # Jeweler::RubygemsDotOrgTasks.new
12
+ #
13
+ # Easy enough, right?
14
+ class RubygemsDotOrgTasks < ::Rake::TaskLib
15
+ attr_accessor :jeweler
16
+
17
+ def initialize
18
+ yield self if block_given?
19
+
20
+ define
21
+ end
22
+
23
+ def jeweler
24
+ @jeweler ||= Rake.application.jeweler
25
+ end
26
+
27
+ def define
28
+ namespace :rubygems do
29
+ desc "Release gem to Gemcutter"
30
+ task :release => [:gemspec, :build] do
31
+ jeweler.release_gem_to_rubygems
32
+ end
33
+ end
34
+
35
+ task :release => 'rubygems:release'
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,4 @@
1
+
1
2
  require 'rubygems/specification'
2
3
 
3
4
  class Jeweler
@@ -9,7 +10,6 @@ class Jeweler
9
10
  # [extra_rdoc_files] a Rake::FileList including files like README*, ChangeLog*, and LICENSE*
10
11
  # [executables] uses anything found in the bin/ directory.
11
12
  module Specification
12
-
13
13
  def self.filelist_attribute(name)
14
14
  code = %{
15
15
  def #{name}
@@ -33,7 +33,6 @@ class Jeweler
33
33
  # Assigns the Jeweler defaults to the Gem::Specification
34
34
  def set_jeweler_defaults(base_dir, git_base_dir = nil)
35
35
  base_dir = File.expand_path(base_dir)
36
- #breakpoint
37
36
  git_base_dir = if git_base_dir
38
37
  File.expand_path(git_base_dir)
39
38
  else
@@ -42,16 +41,15 @@ class Jeweler
42
41
  can_git = git_base_dir && base_dir.include?(git_base_dir) && File.directory?(File.join(git_base_dir, '.git'))
43
42
 
44
43
  Dir.chdir(git_base_dir) do
45
- if can_git
46
- require 'git'
47
- repo = Git.open(git_base_dir) if can_git
48
- end
44
+ repo = if can_git
45
+ require 'git'
46
+ Git.open(git_base_dir)
47
+ end
49
48
 
50
49
  if blank?(files) && repo
51
50
  base_dir_with_trailing_separator = File.join(base_dir, "")
52
51
 
53
- self.files = (repo.ls_files(base_dir).keys - repo.lib.ignored_files).map do |file|
54
- #breakpoint
52
+ self.files = (repo.ls_files(base_dir).keys - repo.lib.ignored_files).compact.map do |file|
55
53
  File.expand_path(file).sub(base_dir_with_trailing_separator, "")
56
54
  end
57
55
  end
@@ -60,8 +58,10 @@ class Jeweler
60
58
  self.test_files = FileList['{spec,test,examples}/**/*.rb'] - repo.lib.ignored_files
61
59
  end
62
60
 
63
- if blank?(executables)
64
- self.executables = Dir['bin/*'].map { |f| File.basename(f) }
61
+ if blank?(executables) && repo
62
+ self.executables = (repo.ls_files(File.join(base_dir, 'bin')).keys - repo.lib.ignored_files).map do |file|
63
+ File.basename(file)
64
+ end
65
65
  end
66
66
 
67
67
  if blank?(extensions)
@@ -69,11 +69,22 @@ class Jeweler
69
69
  end
70
70
 
71
71
  self.has_rdoc = true
72
- rdoc_options << '--charset=UTF-8'
73
72
 
74
73
  if blank?(extra_rdoc_files)
75
74
  self.extra_rdoc_files = FileList['README*', 'ChangeLog*', 'LICENSE*', 'TODO']
76
75
  end
76
+
77
+ if File.exist?('Gemfile')
78
+ require 'bundler'
79
+ bundler = Bundler.load
80
+ bundler.dependencies_for(:default).each do |dependency|
81
+ self.add_dependency dependency.name, dependency.requirement.to_s
82
+ end
83
+ bundler.dependencies_for(:development).each do |dependency|
84
+ self.add_development_dependency dependency.name, dependency.requirement.to_s
85
+ end
86
+ end
87
+
77
88
  end
78
89
  end
79
90
 
@@ -85,10 +96,23 @@ class Jeweler
85
96
  end
86
97
  end
87
98
 
88
- private
99
+ private
89
100
 
90
101
  def blank?(value)
91
102
  value.nil? || value.empty?
92
103
  end
93
104
  end
94
105
  end
106
+
107
+
108
+ # Workaround for cloning/duping a Gem::Specification
109
+ # documented in http://github.com/technicalpickles/jeweler/issues#issue/73
110
+ Gem::Specification.class_eval do
111
+ def initialize_copy(original)
112
+ super
113
+
114
+ self.files = original.files.to_a
115
+ self.test_files = original.test_files.to_a
116
+ self.extra_rdoc_files = original.extra_rdoc_files.to_a
117
+ end
118
+ end
@@ -63,16 +63,23 @@ class Jeweler
63
63
  def define
64
64
  task :version_required do
65
65
  if jeweler.expects_version_file? && !jeweler.version_file_exists?
66
- abort "Expected VERSION or VERSION.yml to exist. See version:write to create an initial one."
66
+ abort "Expected VERSION or VERSION.yml to exist. Use 'rake version:write' to create an initial one."
67
67
  end
68
68
  end
69
69
 
70
+ task :gemspec_required do
71
+ if ! File.exist?(jeweler.gemspec_helper.path)
72
+ abort "Expected #{jeweler.gemspec_helper.path} to exist. See 'rake gemspec:write' to create it"
73
+ end
74
+ end
75
+
76
+
70
77
  desc "Build gem"
71
- task :build => :gemspec do
78
+ task :build do
72
79
  jeweler.build_gem
73
80
  end
74
81
 
75
- desc "Install gem using sudo"
82
+ desc "Install gem"
76
83
  task :install => [:build] do
77
84
  jeweler.install_gem
78
85
  end
@@ -82,7 +89,7 @@ class Jeweler
82
89
 
83
90
  namespace :gemspec do
84
91
  desc "Validates the gemspec"
85
- task :validate => :version_required do
92
+ task :validate => :gemspec_required do
86
93
  jeweler.validate_gemspec
87
94
  end
88
95
 
@@ -91,10 +98,20 @@ class Jeweler
91
98
  jeweler.write_gemspec
92
99
  end
93
100
 
94
- desc "Display the gemspec for debugging purposes"
101
+ desc "Display the gemspec for debugging purposes, as jeweler knows it (not from disk)"
95
102
  task :debug do
103
+ jeweler.gemspec_helper.spec.version ||= begin
104
+ jeweler.version_helper.refresh
105
+ jeweler.version_helper.to_s
106
+ end
107
+
96
108
  puts jeweler.gemspec_helper.to_ruby
97
109
  end
110
+
111
+ desc "Release Gemspec"
112
+ task :release do
113
+ jeweler.release_gem_to_github
114
+ end
98
115
  end
99
116
 
100
117
  desc "Displays the current version"
@@ -137,14 +154,7 @@ class Jeweler
137
154
  task :release do
138
155
  end
139
156
 
140
- namespace :github do
141
- desc "Release Gem to GitHub"
142
- task :release do
143
- jeweler.release_gem_to_github
144
- end
145
- end
146
-
147
- task :release => 'github:release'
157
+ task :release => 'gemspec:release'
148
158
 
149
159
  namespace :git do
150
160
  desc "Tag a release in Git"
@@ -170,7 +180,33 @@ class Jeweler
170
180
  task :development do
171
181
  jeweler.check_dependencies(:development)
172
182
  end
183
+ end
184
+
185
+ desc "Start IRB with all runtime dependencies loaded"
186
+ task :console, [:script] do |t,args|
187
+ dirs = ['ext', 'lib'].select { |dir| File.directory?(dir) }
188
+
189
+ original_load_path = $LOAD_PATH
190
+
191
+ cmd = if File.exist?('Gemfile')
192
+ require 'bundler'
193
+ Bundler.setup(:default)
194
+ end
195
+
196
+ # add the project code directories
197
+ $LOAD_PATH.unshift(*dirs)
198
+
199
+ # clear ARGV so IRB is not confused
200
+ ARGV.clear
201
+
202
+ require 'irb'
203
+
204
+ # set the optional script to run
205
+ IRB.conf[:SCRIPT] = args.script
206
+ IRB.start
173
207
 
208
+ # return the $LOAD_PATH to it's original state
209
+ $LOAD_PATH.reject! { |path| !(original_load_path.include?(path)) }
174
210
  end
175
211
 
176
212
  end