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,6 @@
1
+ require 'pathname'
1
2
  require 'date'
3
+ require 'jeweler/version'
2
4
 
3
5
  # A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
4
6
  #
@@ -18,6 +20,7 @@ class Jeweler
18
20
  autoload :GemSpecHelper, 'jeweler/gemspec_helper'
19
21
 
20
22
  autoload :Tasks, 'jeweler/tasks'
23
+ autoload :RubygemsDotOrgTasks, 'jeweler/rubygems_dot_org_tasks'
21
24
  autoload :GemcutterTasks, 'jeweler/gemcutter_tasks'
22
25
  autoload :RubyforgeTasks, 'jeweler/rubyforge_tasks'
23
26
  autoload :Specification, 'jeweler/specification'
@@ -129,16 +132,16 @@ class Jeweler
129
132
  Jeweler::Commands::ReleaseToGit.build_for(self).run
130
133
  end
131
134
 
132
- def release_gem_to_gemcutter
133
- Jeweler::Commands::ReleaseToGemcutter.build_for(self).run
135
+ def release_gem_to_rubygems
136
+ Jeweler::Commands::ReleaseToRubygems.build_for(self).run
134
137
  end
135
138
 
136
139
  def release_gem_to_rubyforge
137
- Jeweler::Commands::ReleaseToRubyforge.build_for(self).run
140
+ # no-op
138
141
  end
139
142
 
140
143
  def setup_rubyforge
141
- Jeweler::Commands::SetupRubyforge.build_for(self).run
144
+ # no-op
142
145
  end
143
146
 
144
147
  def check_dependencies(type = nil)
@@ -172,4 +175,3 @@ class Jeweler
172
175
  end
173
176
 
174
177
  end
175
-
@@ -5,9 +5,7 @@ class Jeweler
5
5
  autoload :CheckDependencies, 'jeweler/commands/check_dependencies'
6
6
  autoload :ReleaseToGit, 'jeweler/commands/release_to_git'
7
7
  autoload :ReleaseToGithub, 'jeweler/commands/release_to_github'
8
- autoload :ReleaseToGemcutter, 'jeweler/commands/release_to_gemcutter'
9
- autoload :ReleaseToRubyforge, 'jeweler/commands/release_to_rubyforge'
10
- autoload :SetupRubyforge, 'jeweler/commands/setup_rubyforge'
8
+ autoload :ReleaseToRubygems, 'jeweler/commands/release_to_rubygems'
11
9
  autoload :ValidateGemspec, 'jeweler/commands/validate_gemspec'
12
10
  autoload :WriteGemspec, 'jeweler/commands/write_gemspec'
13
11
 
@@ -10,7 +10,7 @@ class Jeweler
10
10
  def run
11
11
  missing_dependencies = dependencies.select do |dependency|
12
12
  begin
13
- Gem.activate dependency.name, dependency.version_requirements.to_s
13
+ Gem.activate dependency.name, dependency.requirements.to_s
14
14
  false
15
15
  rescue LoadError => e
16
16
  true
@@ -22,12 +22,11 @@ class Jeweler
22
22
  else
23
23
  puts "Missing some dependencies. Install them with the following commands:"
24
24
  missing_dependencies.each do |dependency|
25
- puts %Q{\tgem install #{dependency.name} --version "#{dependency.version_requirements}"}
25
+ puts %Q{\tgem install #{dependency.name} --version "#{dependency.requirements.to_s}"}
26
26
  end
27
-
27
+
28
28
  abort "Run the specified gem commands before trying to run this again: #{$0} #{ARGV.join(' ')}"
29
29
  end
30
-
31
30
  end
32
31
 
33
32
  def dependencies
@@ -37,7 +36,6 @@ class Jeweler
37
36
  else
38
37
  gemspec.dependencies
39
38
  end
40
-
41
39
  end
42
40
 
43
41
  def self.build_for(jeweler)
@@ -7,7 +7,6 @@ class Jeweler
7
7
  self.output = $stdout
8
8
  end
9
9
 
10
-
11
10
  def run
12
11
  command = "#{gem_command} install #{gemspec_helper.gem_path}"
13
12
  output.puts "Executing #{command.inspect}:"
@@ -16,7 +15,7 @@ class Jeweler
16
15
  end
17
16
 
18
17
  def gem_command
19
- Config::CONFIG['RUBY_INSTALL_NAME'].sub('ruby', 'gem')
18
+ "#{Config::CONFIG['RUBY_INSTALL_NAME']} -S gem"
20
19
  end
21
20
 
22
21
  def self.build_for(jeweler)
@@ -12,7 +12,10 @@ class Jeweler
12
12
  end
13
13
 
14
14
  def run
15
- raise "Hey buddy, try committing them files first" unless clean_staging_area?
15
+ unless clean_staging_area?
16
+ system "git status"
17
+ raise "Unclean staging area! Be sure to commit or .gitignore everything first."
18
+ end
16
19
 
17
20
  repo.checkout('master')
18
21
  repo.push
@@ -27,8 +30,7 @@ class Jeweler
27
30
  end
28
31
 
29
32
  def clean_staging_area?
30
- status = repo.status
31
- status.added.empty? && status.deleted.empty? && status.changed.empty?
33
+ `git ls-files --deleted --modified --others --exclude-standard` == ""
32
34
  end
33
35
 
34
36
  def release_tag
@@ -1,3 +1,5 @@
1
+ require 'pathname'
2
+
1
3
  class Jeweler
2
4
  module Commands
3
5
  class ReleaseToGithub
@@ -12,7 +14,10 @@ class Jeweler
12
14
  end
13
15
 
14
16
  def run
15
- raise "Hey buddy, try committing them files first" unless clean_staging_area?
17
+ unless clean_staging_area?
18
+ system "git status"
19
+ raise "Unclean staging area! Be sure to commit or .gitignore everything first."
20
+ end
16
21
 
17
22
  repo.checkout('master')
18
23
 
@@ -24,13 +29,14 @@ class Jeweler
24
29
  end
25
30
 
26
31
  def clean_staging_area?
27
- status = repo.status
28
- status.added.empty? && status.deleted.empty? && status.changed.empty?
32
+ # surprisingly simpler than ruby-git
33
+ `git ls-files --deleted --modified --others --exclude-standard` == ""
29
34
  end
30
35
 
31
36
  def commit_gemspec!
32
- repo.add(gemspec_helper.path)
33
- output.puts "Committing #{gemspec_helper.path}"
37
+ gemspec_gitpath = working_subdir.join(gemspec_helper.path)
38
+ repo.add(gemspec_gitpath.to_s)
39
+ output.puts "Committing #{gemspec_gitpath}"
34
40
  repo.commit "Regenerated gemspec for version #{version}"
35
41
  end
36
42
 
@@ -40,15 +46,25 @@ class Jeweler
40
46
  end
41
47
 
42
48
  def gemspec_changed?
43
- `git status` # OMGHAX. status always ends up being 'M' unless this runs
44
- status = repo.status[gemspec_helper.path]
45
- ! status.type.nil?
49
+ # OMGHAX. ruby-git status always ends up being 'M', so let's do it a crazy way
50
+ system "git status -s #{working_subdir.join(gemspec_helper.path)} | grep #{working_subdir.join(gemspec_helper.path)} > /dev/null 2>/dev/null"
46
51
  end
47
52
 
48
53
  def gemspec_helper
49
54
  @gemspec_helper ||= Jeweler::GemSpecHelper.new(self.gemspec, self.base_dir)
50
55
  end
51
56
 
57
+ def working_subdir
58
+ return @working_subdir if @working_subdir
59
+ cwd = base_dir_path
60
+ @working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
61
+ @working_subdir
62
+ end
63
+
64
+ def base_dir_path
65
+ Pathname.new(base_dir).realpath
66
+ end
67
+
52
68
  def self.build_for(jeweler)
53
69
  command = self.new
54
70
 
@@ -1,6 +1,6 @@
1
1
  class Jeweler
2
2
  module Commands
3
- class ReleaseToGemcutter
3
+ class ReleaseToRubygems
4
4
  attr_accessor :gemspec, :version, :output, :gemspec_helper
5
5
 
6
6
  def initialize
@@ -21,7 +21,6 @@ class Jeweler
21
21
  command.output = jeweler.output
22
22
  command
23
23
  end
24
-
25
24
  end
26
25
  end
27
26
  end
@@ -1,9 +1,11 @@
1
+ require 'pathname'
2
+
1
3
  class Jeweler
2
4
  module Commands
3
5
  module Version
4
6
  class Base
5
7
 
6
- attr_accessor :repo, :version_helper, :gemspec, :commit
8
+ attr_accessor :repo, :version_helper, :gemspec, :commit, :base_dir
7
9
 
8
10
  def run
9
11
  update_version
@@ -20,11 +22,22 @@ class Jeweler
20
22
 
21
23
  def commit_version
22
24
  if self.repo
23
- self.repo.add(version_helper.path)
25
+ self.repo.add(working_subdir.join(version_helper.path))
24
26
  self.repo.commit("Version bump to #{self.version_helper.to_s}")
25
27
  end
26
28
  end
27
29
 
30
+ def working_subdir
31
+ return @working_subdir if @working_subdir
32
+ cwd = base_dir_path
33
+ @working_subdir = cwd.relative_path_from(Pathname.new(repo.dir.path))
34
+ @working_subdir
35
+ end
36
+
37
+ def base_dir_path
38
+ Pathname.new(base_dir).realpath
39
+ end
40
+
28
41
 
29
42
  def self.build_for(jeweler)
30
43
  command = new
@@ -32,6 +45,7 @@ class Jeweler
32
45
  command.version_helper = jeweler.version_helper
33
46
  command.gemspec = jeweler.gemspec
34
47
  command.commit = jeweler.commit
48
+ command.base_dir = jeweler.base_dir
35
49
 
36
50
  command
37
51
  end
@@ -35,7 +35,6 @@ class Jeweler
35
35
 
36
36
  command
37
37
  end
38
-
39
38
  end
40
39
  end
41
40
  end
@@ -1,20 +1,8 @@
1
1
  class Jeweler
2
2
  # Gemspec related error
3
- class GemspecError < StandardError
4
- end
3
+ class GemspecError < StandardError
4
+ end
5
5
 
6
- class VersionYmlError < StandardError
7
- end
8
-
9
- # Occurs when interacting with RubyForge, and an expected project isn't available on RubyForge.
10
- class MissingRubyForgePackageError < StandardError
11
- end
12
-
13
- # Occurs when interacting with RubyForge, and 'rubyforge_project' isn't set on the Gem::Specification
14
- class NoRubyForgeProjectInGemspecError < StandardError
15
- end
16
-
17
- # Occurs when interacting with RubyForge, and the 'rubyforge_project' isn't setup in ~/.rubyforge/autoconfig.yml or it doesn't exist on RubyForge
18
- class RubyForgeProjectNotConfiguredError < StandardError
19
- end
6
+ class VersionYmlError < StandardError
7
+ end
20
8
  end
@@ -1,36 +1,8 @@
1
- require 'rake'
2
- require 'rake/tasklib'
1
+ require 'jeweler/rubygems_tasks'
3
2
 
4
3
  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::Gemcutter.new
12
- #
13
- # Easy enough, right?
14
- class GemcutterTasks < ::Rake::TaskLib
15
- attr_accessor :jeweler
16
-
17
- def initialize
18
- yield self if block_given?
19
-
20
- self.jeweler = Rake.application.jeweler
21
-
22
- define
23
- end
24
-
25
- def define
26
- namespace :gemcutter do
27
- desc "Release gem to Gemcutter"
28
- task :release => [:gemspec, :build] do
29
- jeweler.release_gem_to_gemcutter
30
- end
31
- end
32
-
33
- task :release => 'gemcutter:release'
34
- end
4
+ # Deprecated tasks for publishing to Gemcutter. See Jeweler::RubygemsDotOrgTasks
5
+ # for the current tasks to use.
6
+ class GemcutterTasks < RubygemsDotOrgTasks
35
7
  end
36
8
  end
@@ -1,7 +1,5 @@
1
1
  class Jeweler
2
-
3
2
  class GemSpecHelper
4
-
5
3
  attr_accessor :spec, :base_dir
6
4
 
7
5
  def initialize(spec, base_dir = nil)
@@ -21,7 +19,6 @@ class Jeweler
21
19
  end
22
20
 
23
21
  def write
24
-
25
22
  File.open(path, 'w') do |f|
26
23
  f.write self.to_ruby
27
24
  end
@@ -29,7 +26,7 @@ class Jeweler
29
26
 
30
27
  def to_ruby
31
28
  normalize_files(:files)
32
- normalize_files(:files)
29
+ normalize_files(:test_files)
33
30
  normalize_files(:extra_rdoc_files)
34
31
 
35
32
  gemspec_ruby = @spec.to_ruby
@@ -71,7 +68,8 @@ class Jeweler
71
68
  def prettyify_array(gemspec_ruby, array_name)
72
69
  gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
73
70
  leadin, files = match[0..-2].split("[")
74
- leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
71
+
72
+ leadin + "[\n #{files.gsub(%|", "|, %|",\n "|)}\n ]"
75
73
  end
76
74
  end
77
75
 
@@ -87,6 +85,5 @@ class Jeweler
87
85
  def has_version?
88
86
  !@spec.version.nil?
89
87
  end
90
-
91
88
  end
92
89
  end
@@ -4,6 +4,10 @@ require 'erb'
4
4
  require 'net/http'
5
5
  require 'uri'
6
6
 
7
+ require 'fileutils'
8
+ require 'pathname'
9
+
10
+ require 'jeweler/version'
7
11
 
8
12
  class Jeweler
9
13
  class NoGitUserName < StandardError
@@ -36,6 +40,7 @@ class Jeweler
36
40
  require 'jeweler/generator/testspec_mixin'
37
41
  require 'jeweler/generator/testunit_mixin'
38
42
  require 'jeweler/generator/riot_mixin'
43
+ require 'jeweler/generator/shindo_mixin'
39
44
 
40
45
  require 'jeweler/generator/rdoc_mixin'
41
46
  require 'jeweler/generator/yard_mixin'
@@ -44,10 +49,11 @@ class Jeweler
44
49
  :description, :project_name, :github_username, :github_token,
45
50
  :repo, :should_create_remote_repo,
46
51
  :testing_framework, :documentation_framework,
47
- :should_use_cucumber, :should_setup_gemcutter,
52
+ :should_use_cucumber, :should_use_bundler,
48
53
  :should_setup_rubyforge, :should_use_reek, :should_use_roodi,
49
54
  :development_dependencies,
50
- :options
55
+ :options,
56
+ :git_remote
51
57
 
52
58
  def initialize(options = {})
53
59
  self.options = options
@@ -83,14 +89,24 @@ class Jeweler
83
89
  self.should_use_cucumber = options[:use_cucumber]
84
90
  self.should_use_reek = options[:use_reek]
85
91
  self.should_use_roodi = options[:use_roodi]
86
- self.should_setup_gemcutter = options[:gemcutter]
87
92
  self.should_setup_rubyforge = options[:rubyforge]
93
+ self.should_use_bundler = options[:use_bundler]
88
94
 
89
95
  development_dependencies << ["cucumber", ">= 0"] if should_use_cucumber
90
96
 
97
+ # TODO make bundler optional?
98
+ development_dependencies << ["bundler", ">= 1.0.0.rc.5"]
99
+ development_dependencies << ["jeweler", "~> #{Jeweler::Version::STRING}"]
100
+ development_dependencies << ["rcov", ">= 0"]
101
+
102
+ development_dependencies << ["reek", "~> 1.2.8"] if should_use_reek
103
+ development_dependencies << ["roodi", "~> 2.1.0"] if should_use_roodi
104
+
91
105
  self.user_name = options[:user_name]
92
106
  self.user_email = options[:user_email]
93
107
  self.homepage = options[:homepage]
108
+
109
+ self.git_remote = options[:git_remote]
94
110
 
95
111
  raise NoGitUserName unless self.user_name
96
112
  raise NoGitUserEmail unless self.user_email
@@ -149,6 +165,7 @@ class Jeweler
149
165
  end
150
166
 
151
167
  private
168
+
152
169
  def create_files
153
170
  unless File.exists?(target_dir) || File.directory?(target_dir)
154
171
  FileUtils.mkdir target_dir
@@ -159,6 +176,7 @@ class Jeweler
159
176
 
160
177
  output_template_in_target '.gitignore'
161
178
  output_template_in_target 'Rakefile'
179
+ output_template_in_target 'Gemfile' if should_use_bundler
162
180
  output_template_in_target 'LICENSE'
163
181
  output_template_in_target 'README.rdoc'
164
182
  output_template_in_target '.document'
@@ -174,8 +192,8 @@ class Jeweler
174
192
 
175
193
 
176
194
  if testing_framework == :rspec
177
- output_template_in_target File.join(testing_framework.to_s, 'spec.opts'),
178
- File.join(test_dir, 'spec.opts')
195
+ output_template_in_target File.join(testing_framework.to_s, '.rspec'),
196
+ File.join(test_dir, '.rspec')
179
197
 
180
198
  end
181
199
 
@@ -189,7 +207,6 @@ class Jeweler
189
207
  mkdir_in_target features_steps_dir
190
208
  touch_in_target File.join(features_steps_dir, steps_filename)
191
209
  end
192
-
193
210
  end
194
211
 
195
212
  def render_template(source)