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
@@ -16,6 +16,15 @@ class Jeweler
16
16
  raise
17
17
  end
18
18
  end
19
+
20
+ def self.build_for(jeweler)
21
+ command = new
22
+
23
+ command.gemspec_helper = jeweler.gemspec_helper
24
+ command.output = jeweler.output
25
+
26
+ command
27
+ end
19
28
  end
20
29
  end
21
30
  end
@@ -24,6 +24,17 @@ class Jeweler
24
24
  self.repo.commit("Version bump to #{self.version_helper.to_s}", 'VERSION.yml')
25
25
  end
26
26
  end
27
+
28
+
29
+ def self.build_for(jeweler)
30
+ command = new
31
+ command.repo = jeweler.repo
32
+ command.version_helper = jeweler.version_helper
33
+ command.gemspec = jeweler.gemspec
34
+ command.commit = jeweler.commit
35
+
36
+ command
37
+ end
27
38
  end
28
39
  end
29
40
  end
@@ -21,6 +21,19 @@ class Jeweler
21
21
  @gemspec_helper ||= GemSpecHelper.new(self.gemspec, self.base_dir)
22
22
  end
23
23
 
24
+ def self.build_for(jeweler)
25
+ command = new
26
+
27
+ command.base_dir = jeweler.base_dir
28
+ command.gemspec = jeweler.gemspec
29
+ command.version = jeweler.version
30
+ command.output = jeweler.output
31
+ command.gemspec_helper = jeweler.gemspec_helper
32
+ command.version_helper = jeweler.version_helper
33
+
34
+ command
35
+ end
36
+
24
37
  end
25
38
  end
26
39
  end
@@ -5,4 +5,16 @@ class Jeweler
5
5
 
6
6
  class VersionYmlError < StandardError
7
7
  end
8
- 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
20
+ end
@@ -23,7 +23,7 @@ class Jeweler
23
23
  class Generator
24
24
  attr_accessor :target_dir, :user_name, :user_email, :summary, :testing_framework,
25
25
  :github_repo_name, :github_username, :github_token,
26
- :repo, :should_create_repo, :should_use_cucumber
26
+ :repo, :should_create_repo, :should_use_cucumber, :should_setup_rubyforge
27
27
 
28
28
  SUPPORTED_TESTING_FRAMEWORKS = [:shoulda, :testunit, :bacon, :rspec, :micronaut, :minitest]
29
29
 
@@ -44,6 +44,7 @@ class Jeweler
44
44
  self.should_create_repo = options[:create_repo]
45
45
  self.summary = options[:summary] || 'TODO'
46
46
  self.should_use_cucumber= options[:use_cucumber]
47
+ self.should_setup_rubyforge = options[:rubyforge]
47
48
 
48
49
  use_user_git_config
49
50
 
@@ -209,6 +210,7 @@ class Jeweler
209
210
  output_template_in_target 'Rakefile'
210
211
  output_template_in_target 'LICENSE'
211
212
  output_template_in_target 'README.rdoc'
213
+ output_template_in_target '.document'
212
214
 
213
215
  mkdir_in_target lib_dir
214
216
  touch_in_target File.join(lib_dir, "#{file_name_prefix}.rb")
@@ -43,6 +43,10 @@ class Jeweler
43
43
  self[:create_repo] = true
44
44
  end
45
45
 
46
+ o.on('--rubyforge', 'setup project for rubyforge') do
47
+ self[:rubyforge] = true
48
+ end
49
+
46
50
  o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
47
51
  self[:summary] = summary
48
52
  end
data/lib/jeweler/tasks.rb CHANGED
@@ -28,7 +28,7 @@ class Jeweler
28
28
  end
29
29
 
30
30
  desc "Install gem using sudo"
31
- task :install do
31
+ task :install => :build do
32
32
  @jeweler.install_gem
33
33
  end
34
34
 
@@ -48,14 +48,11 @@ class Jeweler
48
48
  end
49
49
 
50
50
  desc "Displays the current version"
51
- task :version => 'version:setup' do
51
+ task :version => 'VERSION.yml' do
52
52
  $stdout.puts "Current version: #{@jeweler.version}"
53
53
  end
54
54
 
55
55
  namespace :version do
56
- desc "Setup initial version of 0.0.0"
57
- task :setup => "VERSION.yml"
58
-
59
56
  desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
60
57
  task :write do
61
58
  major, minor, patch = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i
@@ -88,6 +85,33 @@ class Jeweler
88
85
  task :release do
89
86
  @jeweler.release
90
87
  end
88
+
89
+ namespace :rubyforge do
90
+ namespace :release do
91
+ desc "Release the current gem version to RubyForge."
92
+ task :gem => [:gemspec, :build] do
93
+ begin
94
+ @jeweler.release_gem_to_rubyforge
95
+ rescue NoRubyForgeProjectInGemspecError => e
96
+ abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
97
+ rescue RubyForgeProjectNotConfiguredError => e
98
+ 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"
99
+ end
100
+ end
101
+ end
102
+
103
+ desc "Setup a rubyforge project for this gem"
104
+ task :setup do
105
+ begin
106
+ @jeweler.setup_rubyforge
107
+ rescue NoRubyForgeProjectInGemspecError => e
108
+ abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
109
+ rescue RubyForgeProjectNotConfiguredError => e
110
+ 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"
111
+ end
112
+ end
113
+
114
+ end
91
115
  end
92
116
  end
93
117
  end
@@ -9,21 +9,15 @@ begin
9
9
  gem.email = "<%= user_email %>"
10
10
  gem.homepage = "<%= github_url %>"
11
11
  gem.authors = ["<%= user_name %>"]
12
+ <% if should_setup_rubyforge %>
13
+ gem.rubyforge_project = "<%= github_repo_name %>"
14
+ <% end %>
12
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
16
  end
14
17
  rescue LoadError
15
18
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
19
  end
17
20
 
18
- require 'rake/rdoctask'
19
- Rake::RDocTask.new do |rdoc|
20
- rdoc.rdoc_dir = 'rdoc'
21
- rdoc.title = '<%= github_repo_name %>'
22
- rdoc.options << '--line-numbers' << '--inline-source'
23
- rdoc.rdoc_files.include('README*')
24
- rdoc.rdoc_files.include('lib/**/*.rb')
25
- end
26
-
27
21
  <% case testing_framework.to_sym %>
28
22
  <% when :rspec %>
29
23
  require 'spec/rake/spectask'
@@ -86,3 +80,46 @@ end
86
80
  <% end %>
87
81
 
88
82
  task :default => :<%= default_task %>
83
+
84
+ require 'rake/rdoctask'
85
+ Rake::RDocTask.new do |rdoc|
86
+ if File.exist?('VERSION.yml')
87
+ config = YAML.load(File.read('VERSION.yml'))
88
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
89
+ else
90
+ version = ""
91
+ end
92
+
93
+ rdoc.rdoc_dir = 'rdoc'
94
+ rdoc.title = "<%= github_repo_name %> #{version}"
95
+ rdoc.rdoc_files.include('README*')
96
+ rdoc.rdoc_files.include('lib/**/*.rb')
97
+ end
98
+
99
+ <% if should_setup_rubyforge %>
100
+ begin
101
+ require 'rake/contrib/sshpublisher'
102
+ namespace :rubyforge do
103
+
104
+ desc "Release gem and RDoc documentation to RubyForge"
105
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
106
+
107
+ namespace :release do
108
+ desc "Publish RDoc to RubyForge."
109
+ task :docs => [:rdoc] do
110
+ config = YAML.load(
111
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
112
+ )
113
+
114
+ host = "#{config['username']}@rubyforge.org"
115
+ remote_dir = "/var/www/gforge-projects/<%= github_repo_name %>/"
116
+ local_dir = 'rdoc'
117
+
118
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
119
+ end
120
+ end
121
+ end
122
+ rescue LoadError
123
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
124
+ end
125
+ <% end %>
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Josh Nichols
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
1
+ = existing-project-with-version
2
+
3
+ Description goes here.
4
+
5
+ == Copyright
6
+
7
+ Copyright (c) 2009 Josh Nichols. See LICENSE for details.
@@ -0,0 +1,82 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "existing-project-with-version"
8
+ gem.summary = %Q{TODO}
9
+ gem.email = "josh@technicalpickles.com"
10
+ gem.homepage = "http://github.com/technicalpickles/existing-project-with-version"
11
+ gem.authors = ["Josh Nichols"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+ rescue LoadError
15
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
+ end
17
+
18
+ require 'rake/testtask'
19
+ Rake::TestTask.new(:test) do |test|
20
+ test.libs << 'lib' << 'test'
21
+ test.pattern = 'test/**/*_test.rb'
22
+ test.verbose = false
23
+ end
24
+
25
+ begin
26
+ require 'rcov/rcovtask'
27
+ Rcov::RcovTask.new do |test|
28
+ test.libs << 'test'
29
+ test.pattern = 'test/**/*_test.rb'
30
+ test.verbose = true
31
+ end
32
+ rescue LoadError
33
+ task :rcov do
34
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
35
+ end
36
+ end
37
+
38
+
39
+ task :default => :test
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ if File.exist?('VERSION.yml')
44
+ config = YAML.load(File.read('VERSION.yml'))
45
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
46
+ else
47
+ version = ""
48
+ end
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "existing-project-with-version #{version}"
52
+ rdoc.options << '--line-numbers' << '--inline-source'
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
57
+ # Rubyforge documentation task
58
+ begin
59
+ require 'rake/contrib/sshpublisher'
60
+ namespace :rubyforge do
61
+
62
+ desc "Release gem and RDoc documentation to RubyForge"
63
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
64
+
65
+ namespace :release do
66
+ desc "Publish RDoc to RubyForge."
67
+ task :docs => [:rdoc] do
68
+ config = YAML.load(
69
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
70
+ )
71
+
72
+ host = "#{config['username']}@rubyforge.org"
73
+ remote_dir = "/var/www/gforge-projects/existing-project-with-version/"
74
+ local_dir = 'rdoc'
75
+
76
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
77
+ end
78
+ end
79
+ end
80
+ rescue LoadError
81
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
82
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 5
4
+ :patch: 3
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{existing-project-with-version}
5
+ s.version = "1.5.3"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Josh Nichols"]
9
+ s.date = %q{2009-03-13}
10
+ s.email = %q{josh@technicalpickles.com}
11
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
12
+ s.files = ["README.rdoc", "VERSION.yml", "lib/existing_project_with_version.rb", "test/existing_project_with_version_test.rb", "test/test_helper.rb", "LICENSE"]
13
+ s.has_rdoc = true
14
+ s.homepage = %q{http://github.com/technicalpickles/existing-project-with-version}
15
+ s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
16
+ s.require_paths = ["lib"]
17
+ s.rubygems_version = %q{1.3.1}
18
+ s.summary = %q{TODO}
19
+
20
+ if s.respond_to? :specification_version then
21
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
22
+ s.specification_version = 2
23
+
24
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
25
+ else
26
+ end
27
+ else
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ExistingProjectWithVersionTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'existing_project_with_version'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,12 @@
1
+ # Dependencies required to run the test suite
2
+ gems:
3
+ - name: rspec
4
+ version: '~> 1.1.12'
5
+ - name: Shoulda
6
+ version: '~> 1.2.0'
7
+ - name: ruby-debug
8
+ version: '~> 0.10.3'
9
+ - name: rr
10
+ version: '~> 0.7.1'
11
+ - name: mhennemeyer-output_catcher
12
+ version: '~> 1.0.1'
@@ -1,4 +1,5 @@
1
- require 'test_helper'
1
+ # not sure why I need to use this form instead of just require 'test_helper'
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
2
3
 
3
4
  class Jeweler
4
5
  module Commands
@@ -48,6 +49,24 @@ class Jeweler
48
49
  end
49
50
  end
50
51
 
52
+ build_command_context "build for jeweler" do
53
+ setup do
54
+ @command = Jeweler::Commands::BuildGem.build_for(@jeweler)
55
+ end
56
+
57
+ should "assign base_dir" do
58
+ assert_same @base_dir, @jeweler.base_dir
59
+ end
60
+
61
+ should "assign gemspec_helper" do
62
+ assert_same @gemspec_helper, @jeweler.gemspec_helper
63
+ end
64
+
65
+ should "return BuildGem" do
66
+ assert_kind_of Jeweler::Commands::BuildGem, @command
67
+ end
68
+ end
69
+
51
70
  end
52
71
  end
53
72
  end