technicalpickles-jeweler 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/ChangeLog.markdown +6 -0
  2. data/README.markdown +67 -2
  3. data/Rakefile +31 -3
  4. data/VERSION.yml +2 -2
  5. data/lib/jeweler.rb +30 -31
  6. data/lib/jeweler/commands.rb +2 -0
  7. data/lib/jeweler/commands/build_gem.rb +9 -0
  8. data/lib/jeweler/commands/install_gem.rb +7 -0
  9. data/lib/jeweler/commands/release.rb +13 -0
  10. data/lib/jeweler/commands/release_to_rubyforge.rb +51 -0
  11. data/lib/jeweler/commands/setup_rubyforge.rb +38 -0
  12. data/lib/jeweler/commands/validate_gemspec.rb +9 -0
  13. data/lib/jeweler/commands/version/base.rb +11 -0
  14. data/lib/jeweler/commands/write_gemspec.rb +13 -0
  15. data/lib/jeweler/errors.rb +13 -1
  16. data/lib/jeweler/generator.rb +3 -1
  17. data/lib/jeweler/generator/options.rb +4 -0
  18. data/lib/jeweler/tasks.rb +29 -5
  19. data/lib/jeweler/templates/Rakefile +46 -9
  20. data/test/fixtures/existing-project-with-version/LICENSE +20 -0
  21. data/test/fixtures/existing-project-with-version/README.rdoc +7 -0
  22. data/test/fixtures/existing-project-with-version/Rakefile +82 -0
  23. data/test/fixtures/existing-project-with-version/VERSION.yml +4 -0
  24. data/test/fixtures/existing-project-with-version/existing-project-with-version.gemspec +29 -0
  25. data/test/fixtures/existing-project-with-version/lib/existing_project_with_version.rb +0 -0
  26. data/test/fixtures/existing-project-with-version/test/existing_project_with_version_test.rb +7 -0
  27. data/test/fixtures/existing-project-with-version/test/test_helper.rb +10 -0
  28. data/test/geminstaller.yml +12 -0
  29. data/test/jeweler/commands/test_build_gem.rb +20 -1
  30. data/test/jeweler/commands/test_install_gem.rb +21 -0
  31. data/test/jeweler/commands/test_release.rb +30 -0
  32. data/test/jeweler/commands/test_release_to_rubyforge.rb +157 -0
  33. data/test/jeweler/commands/test_setup_rubyforge.rb +88 -0
  34. data/test/jeweler/commands/test_validate_gemspec.rb +27 -0
  35. data/test/jeweler/commands/test_write_gemspec.rb +34 -0
  36. data/test/jeweler/commands/version/test_base.rb +32 -0
  37. data/test/jeweler/commands/version/test_bump_major.rb +1 -0
  38. data/test/test_application.rb +4 -0
  39. data/test/test_generator.rb +4 -0
  40. data/test/test_helper.rb +75 -8
  41. data/test/test_jeweler.rb +137 -96
  42. data/test/test_options.rb +6 -0
  43. data/test/test_tasks.rb +2 -0
  44. metadata +26 -4
data/ChangeLog.markdown CHANGED
@@ -1,4 +1,10 @@
1
1
  # jeweler x.y.z
2
+
3
+ * 'rake install' now will 'rake build' first
4
+ * Support for releasing to RubyForge, thanks to jtrupiano
5
+ * Steps towards Ruby 1.9 support, thanks to rsanheim
6
+
7
+ # jeweler 0.9.1 2009-03-05
2
8
 
3
9
  * Tasks:
4
10
  * Fixed populating default spec's extra_rdoc_files
data/README.markdown CHANGED
@@ -48,6 +48,7 @@ It supports a number of options:
48
48
  * --shoulda: generate test_helper.rb and test ready for shoulda (this is the default)
49
49
  * --rspec: generate spec_helper.rb and spec ready for rspec
50
50
  * --bacon: generate spec_helper.rb and spec ready for bacon
51
+ * --rubyfoge: setup releasing to rubyforge
51
52
 
52
53
  ## Gemspec
53
54
 
@@ -74,7 +75,7 @@ Initially, your project starts out at 0.0.0. Jeweler provides Rake tasks for bum
74
75
  rake version:bump:minor
75
76
  rake version:bump:patch
76
77
 
77
- ## Releasing
78
+ ## Releasing to GitHub
78
79
 
79
80
  Jeweler handles releasing your gem into the wild:
80
81
 
@@ -86,12 +87,76 @@ It does the following for you:
86
87
  * Push to GitHub (which results in a gem being build)
87
88
  * Tag the version and push to GitHub
88
89
 
90
+ ## Releasing to RubyForge
91
+
92
+ Jeweler can also handle releasing to [RubyForge](http://rubyforge.org). There are a few steps you need to do before doing any RubyForge releases with Jeweler:
93
+
94
+ * [Create an account on RubyForge](http://rubyforge.org/account/register.php)
95
+ * Request a project on RubyForge. This involves waiting for a project approval, which can take any amount of time from a few hours to a week
96
+ * You might want to create an umbrella project where you can publish your gems, instead of one project per gem
97
+ * Install the RubyForge gem: sudo gem install rubyforge
98
+ * Run 'rubyforge setup' and fill in your username and password for RubyForge
99
+ * Run 'rubyforge config' to pull down information about your projects
100
+ * Run 'rubyforge login' to make sure you are able to login
101
+
102
+ With this in place, you now update your Jeweler::Tasks to setup `rubyforge_project` with the RubyForge project you've just created. (Note, using `jeweler --rubyforge` when generating the project does this for you automatically.)
103
+
104
+ begin
105
+ require 'jeweler'
106
+ Jeweler::Tasks.new do |s|
107
+ s.name = "the-perfect-gem"
108
+ s.summary = "TODO"
109
+ s.email = "josh@technicalpickles.com"
110
+ s.homepage = "http://github.com/technicalpickles/the-perfect-gem"
111
+ s.description = "TODO"
112
+ s.authors = ["Josh Nichols"]
113
+ s.rubyforge_project = 'the-perfect-gem' # This line would be new
114
+ end
115
+ rescue LoadError
116
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
117
+ end
118
+
119
+ # These are new tasks
120
+ begin
121
+ require 'rake/contrib/sshpublisher'
122
+ namespace :rubyforge do
123
+
124
+ desc "Release gem and RDoc documentation to RubyForge"
125
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
126
+
127
+ namespace :release do
128
+ desc "Publish RDoc to RubyForge."
129
+ task :docs => [:rdoc] do
130
+ config = YAML.load(
131
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
132
+ )
133
+
134
+ host = "#{config['username']}@rubyforge.org"
135
+ remote_dir = "/var/www/gforge-projects/the-perfect-gem/"
136
+ local_dir = 'rdoc'
137
+
138
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
139
+ end
140
+ end
141
+ end
142
+ rescue LoadError
143
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
144
+ end
145
+
146
+ Now you must initially create a 'package' for your gem in your 'project':
147
+
148
+ $ rake rubyforge:setup
149
+
150
+ With all that setup out of the way, you can now release to RubyForge with impunity. This would release the current version of your gem, and upload the rdoc as your project's webpage.
151
+
152
+ $ rake rubyforge:release
153
+
89
154
  ## Workflow
90
155
 
91
156
  * Hack, commit, hack, commit, etc, etc
92
157
  * `rake version:bump:patch release` to do the actual version bump and release
93
158
  * Have a delicious scotch
94
- * Go to [Has My Gem Built Yet](http://hasmygembuiltyet.org) and wait for your gem to be built
159
+ * Install [gemstalker](http://github.com/technicalpickles/gemstalker), and use it to know when gem is built. It typically builds in a few minutes, but won't be installable for another 15 minutes.
95
160
 
96
161
  ## Links
97
162
 
data/Rakefile CHANGED
@@ -11,8 +11,9 @@ begin
11
11
  gem.homepage = "http://github.com/technicalpickles/jeweler"
12
12
  gem.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
13
13
  gem.authors = ["Josh Nichols"]
14
- gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
15
- gem.add_dependency 'schacon-git'
14
+ gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.documena', 'lib/jeweler/templates/.gitignore']
15
+ gem.add_dependency "peterwald-git"
16
+ gem.rubyforge_project = "pickles"
16
17
  end
17
18
  rescue LoadError
18
19
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
@@ -22,13 +23,14 @@ require 'rake/testtask'
22
23
  Rake::TestTask.new(:test) do |test|
23
24
  test.pattern = 'test/**/test_*.rb'
24
25
  test.libs << 'test'
26
+ test.verbose = true
27
+ #test.ruby_opts << '-rtest_helper'
25
28
  end
26
29
 
27
30
  require 'rake/rdoctask'
28
31
  Rake::RDocTask.new do |rdoc|
29
32
  rdoc.rdoc_dir = 'rdoc'
30
33
  rdoc.title = 'jeweler'
31
- rdoc.options << '--line-numbers' << '--inline-source'
32
34
  rdoc.rdoc_files.include('README.markdown')
33
35
  rdoc.rdoc_files.include('lib/**/*.rb')
34
36
  end
@@ -54,6 +56,32 @@ rescue LoadError
54
56
  end
55
57
  end
56
58
 
59
+ begin
60
+ require 'rake/contrib/sshpublisher'
61
+ namespace :rubyforge do
62
+
63
+ desc "Release gem and RDoc documentation to RubyForge"
64
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
65
+
66
+ namespace :release do
67
+ desc "Publish RDoc to RubyForge."
68
+ task :docs => [:rdoc] do
69
+ config = YAML.load(
70
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
71
+ )
72
+
73
+ host = "#{config['username']}@rubyforge.org"
74
+ remote_dir = "/var/www/gforge-projects/pickles"
75
+ local_dir = 'rdoc'
76
+
77
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
78
+ end
79
+ end
80
+ end
81
+ rescue LoadError
82
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
83
+ end
84
+
57
85
  if ENV["RUN_CODE_RUN"] == "true"
58
86
  task :default => [:test, :features]
59
87
  else
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 9
3
- :patch: 1
4
2
  :major: 0
3
+ :minor: 10
4
+ :patch: 0
data/lib/jeweler.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  require 'date'
2
+ require 'rubygems/user_interaction'
2
3
  require 'rubygems/builder'
4
+ require 'rubyforge'
3
5
 
6
+ require 'jeweler/errors'
4
7
  require 'jeweler/version_helper'
5
8
  require 'jeweler/gemspec_helper'
6
- require 'jeweler/errors'
7
9
  require 'jeweler/generator'
8
10
  require 'jeweler/generator/options'
9
11
  require 'jeweler/generator/application'
@@ -15,8 +17,8 @@ require 'jeweler/tasks'
15
17
  # A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
16
18
  class Jeweler
17
19
 
18
- attr_reader :gemspec, :gemspec_helper
19
- attr_accessor :base_dir, :output
20
+ attr_reader :gemspec, :gemspec_helper, :version_helper
21
+ attr_accessor :base_dir, :output, :repo, :commit, :rubyforge
20
22
 
21
23
  def initialize(gemspec, base_dir = '.')
22
24
  raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?
@@ -24,9 +26,11 @@ class Jeweler
24
26
  @base_dir = base_dir
25
27
  @gemspec = fill_in_gemspec_defaults(gemspec)
26
28
  @repo = Git.open(base_dir) if in_git_repo?
27
- @version_helper = Jeweler::VersionHelper.new(@base_dir)
29
+ @version_helper = Jeweler::VersionHelper.new(@base_dir)
28
30
  @output = $stdout
29
- @gemspec_helper = GemSpecHelper.new(@gemspec,base_dir)
31
+ @commit = true
32
+ @gemspec_helper = GemSpecHelper.new(@gemspec, base_dir)
33
+ @rubyforge = RubyForge.new
30
34
  end
31
35
 
32
36
  # Major version, as defined by the gemspec's Version module.
@@ -54,13 +58,13 @@ class Jeweler
54
58
 
55
59
  # Writes out the gemspec
56
60
  def write_gemspec
57
- build_command(Jeweler::Commands::WriteGemspec).run
61
+ Jeweler::Commands::WriteGemspec.build_for(self).run
58
62
  end
59
63
 
60
64
  # Validates the project's gemspec from disk in an environment similar to how
61
65
  # GitHub would build from it. See http://gist.github.com/16215
62
66
  def validate_gemspec
63
- build_command(Jeweler::Commands::ValidateGemspec).run
67
+ Jeweler::Commands::ValidateGemspec.build_for(self).run
64
68
  end
65
69
 
66
70
  # is the project's gemspec from disk valid?
@@ -69,37 +73,37 @@ class Jeweler
69
73
  end
70
74
 
71
75
  def build_gem
72
- build_command(Jeweler::Commands::BuildGem).run
76
+ Jeweler::Commands::BuildGem.build_for(self).run
73
77
  end
74
78
 
75
79
  def install_gem
76
- build_command(Jeweler::Commands::InstallGem).run
80
+ Jeweler::Commands::InstallGem.build_for(self).run
77
81
  end
78
82
 
79
83
  # Bumps the patch version.
80
84
  #
81
85
  # 1.5.1 -> 1.5.2
82
- def bump_patch_version(options = {})
83
- build_command(Jeweler::Commands::Version::BumpPatch).run
86
+ def bump_patch_version()
87
+ Jeweler::Commands::Version::BumpPatch.build_for(self).run
84
88
  end
85
89
 
86
90
  # Bumps the minor version.
87
91
  #
88
92
  # 1.5.1 -> 1.6.0
89
- def bump_minor_version(options = {})
90
- build_command(Jeweler::Commands::Version::BumpMinor).run
93
+ def bump_minor_version()
94
+ Jeweler::Commands::Version::BumpMinor.build_for(self).run
91
95
  end
92
96
 
93
97
  # Bumps the major version.
94
98
  #
95
99
  # 1.5.1 -> 2.0.0
96
- def bump_major_version(options = {})
97
- build_command(Jeweler::Commands::Version::BumpMajor).run
100
+ def bump_major_version()
101
+ Jeweler::Commands::Version::BumpMajor.build_for(self).run
98
102
  end
99
103
 
100
104
  # Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
101
105
  def write_version(major, minor, patch, options = {})
102
- command = build_command(Jeweler::Commands::Version::Write)
106
+ command = Jeweler::Commands::Version::Write.build_for(self)
103
107
  command.major = major
104
108
  command.minor = minor
105
109
  command.patch = patch
@@ -108,29 +112,24 @@ class Jeweler
108
112
  end
109
113
 
110
114
  def release
111
- build_command(Jeweler::Commands::Release).run
115
+ Jeweler::Commands::Release.build_for(self).run
116
+ end
117
+
118
+ def release_gem_to_rubyforge
119
+ Jeweler::Commands::ReleaseToRubyforge.build_for(self).run
112
120
  end
113
121
 
114
- protected
115
-
116
- def build_command(command_class)
117
- command = command_class.new
118
- command.repo = @repo if command.respond_to?(:repo=)
119
- command.version_helper = @version_helper if command.respond_to?(:version_helper=)
120
- command.gemspec = @gemspec if command.respond_to?(:gemspec=)
121
- command.commit = true if command.respond_to?(:commit=)
122
- command.version = self.version if command.respond_to?(:version=)
123
- command.output = output if command.respond_to?(:output=)
124
- command.base_dir = @base_dir if command.respond_to?(:base_dir=)
125
- command.gemspec_helper = GemSpecHelper.new(@gemspec, @base_dir) if command.respond_to?(:gemspec_helper)
126
-
127
- command
122
+ def setup_rubyforge
123
+ Jeweler::Commands::SetupRubyforge.build_for(self).run
128
124
  end
129
125
 
126
+
130
127
  def in_git_repo?
131
128
  File.exists?(File.join(self.base_dir, '.git'))
132
129
  end
133
130
 
131
+ protected
132
+
134
133
  def fill_in_gemspec_defaults(gemspec)
135
134
  if gemspec.files.nil? || gemspec.files.empty?
136
135
  gemspec.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
@@ -1,6 +1,8 @@
1
1
  require 'jeweler/commands/build_gem'
2
2
  require 'jeweler/commands/install_gem'
3
3
  require 'jeweler/commands/release'
4
+ require 'jeweler/commands/release_to_rubyforge'
5
+ require 'jeweler/commands/setup_rubyforge'
4
6
  require 'jeweler/commands/validate_gemspec'
5
7
  require 'jeweler/commands/write_gemspec'
6
8
  require 'jeweler/commands/version/base'
@@ -17,6 +17,15 @@ class Jeweler
17
17
  gem_file_name = File.join(base_dir, gem_file_name)
18
18
  file_utils.mv gem_file_name, pkg_dir
19
19
  end
20
+
21
+ def self.build_for(jeweler)
22
+ command = new
23
+
24
+ command.base_dir = jeweler.base_dir
25
+ command.gemspec_helper = jeweler.gemspec_helper
26
+
27
+ command
28
+ end
20
29
  end
21
30
  end
22
31
  end
@@ -14,6 +14,13 @@ class Jeweler
14
14
 
15
15
  sh command # TODO where does sh actually come from!?
16
16
  end
17
+
18
+ def self.build_for(jeweler)
19
+ command = new
20
+ command.output = jeweler.output
21
+ command.gemspec_helper = jeweler.gemspec_helper
22
+ command
23
+ end
17
24
  end
18
25
  end
19
26
  end
@@ -41,6 +41,19 @@ class Jeweler
41
41
  @gemspec_helper ||= Jeweler::GemSpecHelper.new(self.gemspec, self.base_dir)
42
42
  end
43
43
 
44
+ def self.build_for(jeweler)
45
+ command = self.new
46
+
47
+ command.base_dir = jeweler.base_dir
48
+ command.gemspec = jeweler.gemspec
49
+ command.version = jeweler.version
50
+ command.repo = jeweler.repo
51
+ command.output = jeweler.output
52
+ command.gemspec_helper = jeweler.gemspec_helper
53
+
54
+ command
55
+ end
56
+
44
57
  end
45
58
  end
46
59
  end
@@ -0,0 +1,51 @@
1
+ require 'rubyforge'
2
+
3
+ class Jeweler
4
+ module Commands
5
+ class ReleaseToRubyforge
6
+ attr_accessor :gemspec, :version, :output, :gemspec_helper, :rubyforge
7
+
8
+ def initialize
9
+ self.output = $stdout
10
+ end
11
+
12
+ def run
13
+ raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project
14
+
15
+ @rubyforge.configure rescue nil
16
+
17
+ output.puts 'Logging in rubyforge'
18
+ @rubyforge.login
19
+
20
+ @rubyforge.userconfig['release_notes'] = @gemspec.description if @gemspec.description
21
+ @rubyforge.userconfig['preformatted'] = true
22
+
23
+ output.puts "Releasing #{@gemspec.name}-#{@version} to #{@gemspec.rubyforge_project}"
24
+ begin
25
+ @rubyforge.add_release(@gemspec.rubyforge_project, @gemspec.name, @version.to_s, @gemspec_helper.gem_path)
26
+ rescue StandardError => e
27
+ case e.message
28
+ when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
29
+ raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
30
+ when /no <package_id> configured for <#{Regexp.escape @gemspec.name}>/i
31
+ raise MissingRubyForgePackageError, @gemspec.name
32
+ else
33
+ raise
34
+ end
35
+ end
36
+ end
37
+
38
+ def self.build_for(jeweler)
39
+ command = new
40
+ command.gemspec = jeweler.gemspec
41
+ command.gemspec_helper = jeweler.gemspec_helper
42
+ command.version = jeweler.version
43
+ command.rubyforge = jeweler.rubyforge
44
+ command.output = jeweler.output
45
+
46
+ command
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,38 @@
1
+ class Jeweler
2
+ module Commands
3
+ class SetupRubyforge
4
+ attr_accessor :gemspec, :output, :rubyforge
5
+
6
+ def run
7
+ raise NoRubyForgeProjectInGemspecError unless @gemspec.rubyforge_project
8
+
9
+ @rubyforge.configure
10
+
11
+ output.puts "Logging into rubyforge"
12
+ @rubyforge.login
13
+
14
+ output.puts "Creating #{@gemspec.name} package in the #{@gemspec.rubyforge_project} project"
15
+ begin
16
+ @rubyforge.create_package(@gemspec.rubyforge_project, @gemspec.name)
17
+ rescue StandardError => e
18
+ case e.message
19
+ when /no <group_id> configured for <#{Regexp.escape @gemspec.rubyforge_project}>/
20
+ raise RubyForgeProjectNotConfiguredError, @gemspec.rubyforge_project
21
+ else
22
+ raise
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.build_for(jeweler)
28
+ command = new
29
+
30
+ command.gemspec = jeweler.gemspec
31
+ command.output = jeweler.output
32
+ command.rubyforge = jeweler.rubyforge
33
+
34
+ command
35
+ end
36
+ end
37
+ end
38
+ end