technicalpickles-jeweler 0.11.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/.gitignore +7 -0
  2. data/ChangeLog.markdown +8 -0
  3. data/README.markdown +9 -9
  4. data/ROADMAP +12 -0
  5. data/Rakefile +22 -5
  6. data/VERSION.yml +2 -2
  7. data/features/generator/cucumber.feature +83 -0
  8. data/features/generator/directory_layout.feature +76 -0
  9. data/features/generator/dotdocument.feature +14 -0
  10. data/features/generator/env_options.feature +9 -0
  11. data/features/generator/git.feature +94 -0
  12. data/features/generator/license.feature +11 -0
  13. data/features/generator/rakefile.feature +110 -0
  14. data/features/generator/readme.feature +12 -0
  15. data/features/generator/test.feature +41 -0
  16. data/features/generator/test_helper.feature +49 -0
  17. data/features/placeholder.feature +5 -0
  18. data/features/step_definitions/debug_steps.rb +6 -0
  19. data/features/step_definitions/filesystem_steps.rb +65 -0
  20. data/features/step_definitions/generator_steps.rb +251 -0
  21. data/features/step_definitions/task_steps.rb +6 -0
  22. data/features/support/env.rb +19 -0
  23. data/features/tasks/build_gem.feature +9 -0
  24. data/features/tasks/version.feature +24 -0
  25. data/features/tasks/version_bumping.feature +33 -0
  26. data/jeweler.gemspec +204 -0
  27. data/lib/jeweler/commands/release.rb +35 -11
  28. data/lib/jeweler/commands/version/base.rb +1 -1
  29. data/lib/jeweler/gemspec_helper.rb +4 -6
  30. data/lib/jeweler/generator/application.rb +8 -3
  31. data/lib/jeweler/generator/bacon_mixin.rb +39 -0
  32. data/lib/jeweler/generator/micronaut_mixin.rb +38 -0
  33. data/lib/jeweler/generator/minitest_mixin.rb +39 -0
  34. data/lib/jeweler/generator/options.rb +5 -1
  35. data/lib/jeweler/generator/rspec_mixin.rb +39 -0
  36. data/lib/jeweler/generator/shoulda_mixin.rb +39 -0
  37. data/lib/jeweler/generator/testunit_mixin.rb +39 -0
  38. data/lib/jeweler/generator.rb +48 -111
  39. data/lib/jeweler/rubyforge_tasks.rb +46 -0
  40. data/lib/jeweler/specification.rb +3 -2
  41. data/lib/jeweler/tasks.rb +32 -26
  42. data/lib/jeweler/templates/README.rdoc +1 -1
  43. data/lib/jeweler/templates/Rakefile +29 -52
  44. data/lib/jeweler/templates/bacon/helper.rb +1 -1
  45. data/lib/jeweler/templates/features/support/env.rb +4 -7
  46. data/lib/jeweler/templates/micronaut/helper.rb +1 -1
  47. data/lib/jeweler/templates/minitest/helper.rb +1 -1
  48. data/lib/jeweler/templates/rspec/flunking.rb +1 -1
  49. data/lib/jeweler/templates/rspec/helper.rb +1 -1
  50. data/lib/jeweler/templates/shoulda/helper.rb +1 -1
  51. data/lib/jeweler/templates/testunit/helper.rb +1 -1
  52. data/lib/jeweler/version_helper.rb +78 -33
  53. data/lib/jeweler.rb +5 -0
  54. data/test/fixtures/existing-project-with-version-plaintext/.document +5 -0
  55. data/test/fixtures/existing-project-with-version-plaintext/.gitignore +5 -0
  56. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/LICENSE +0 -0
  57. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/README.rdoc +0 -0
  58. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/Rakefile +0 -0
  59. data/test/fixtures/existing-project-with-version-plaintext/VERSION +1 -0
  60. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/existing-project-with-version.gemspec +0 -0
  61. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/lib/existing_project_with_version.rb +0 -0
  62. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/test/existing_project_with_version_test.rb +0 -0
  63. data/test/fixtures/{existing-project-with-version → existing-project-with-version-plaintext}/test/test_helper.rb +0 -0
  64. data/test/fixtures/existing-project-with-version-yaml/.document +5 -0
  65. data/test/fixtures/existing-project-with-version-yaml/.gitignore +5 -0
  66. data/test/fixtures/existing-project-with-version-yaml/LICENSE +20 -0
  67. data/test/fixtures/existing-project-with-version-yaml/README.rdoc +7 -0
  68. data/test/fixtures/existing-project-with-version-yaml/Rakefile +82 -0
  69. data/test/fixtures/{existing-project-with-version → existing-project-with-version-yaml}/VERSION.yml +0 -0
  70. data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +29 -0
  71. data/test/fixtures/existing-project-with-version-yaml/lib/existing_project_with_version.rb +0 -0
  72. data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +7 -0
  73. data/test/fixtures/existing-project-with-version-yaml/test/test_helper.rb +10 -0
  74. data/test/jeweler/commands/test_release.rb +304 -79
  75. data/test/test_application.rb +26 -0
  76. data/test/test_gemspec_helper.rb +4 -0
  77. data/test/test_generator.rb +83 -112
  78. data/test/test_generator_initialization.rb +113 -0
  79. data/test/test_generator_mixins.rb +18 -0
  80. data/test/test_helper.rb +3 -0
  81. data/test/test_options.rb +6 -0
  82. data/test/test_specification.rb +6 -2
  83. data/test/test_version_helper.rb +47 -9
  84. metadata +72 -17
  85. data/test/generators/initialization_test.rb +0 -146
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'rake/contrib/sshpublisher'
4
+
5
+
6
+ class Jeweler
7
+ class RubyforgeTasks < ::Rake::TaskLib
8
+ attr_accessor :project, :remote_doc_path
9
+ attr_accessor :jeweler
10
+
11
+ def initialize
12
+ yield self if block_given?
13
+
14
+ self.jeweler = Rake.application.jeweler
15
+
16
+ self.remote_doc_path ||= jeweler.gemspec.name
17
+ self.project ||= jeweler.gemspec.rubyforge_project
18
+
19
+ define
20
+ end
21
+
22
+ def define
23
+ namespace :rubyforge do
24
+
25
+ desc "Release gem and RDoc documentation to RubyForge"
26
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
27
+
28
+ namespace :release do
29
+ desc "Publish RDoc to RubyForge."
30
+ task :docs => [:rdoc] do
31
+ config = YAML.load(
32
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
33
+ )
34
+
35
+ host = "#{config['username']}@rubyforge.org"
36
+ remote_dir = "/var/www/gforge-projects/#{project}/#{remote_doc_path}"
37
+ local_dir = 'rdoc'
38
+
39
+ sh %{rsync -av --delete #{local_dir}/ #{host}:#{remote_dir}}
40
+ end
41
+ end
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -26,8 +26,9 @@ class Jeweler
26
26
  # Assigns the Jeweler defaults to the Gem::Specification
27
27
  def set_jeweler_defaults(base_dir)
28
28
  Dir.chdir(base_dir) do
29
- if blank?(files)
30
- self.files = FileList["[A-Z]*.*", "{bin,examples,generators,lib,rails,spec,test}/**/*", 'Rakefile', 'LICENSE*']
29
+ if blank?(files) && File.directory?(File.join(base_dir, '.git'))
30
+ repo = Git.open(base_dir)
31
+ self.files = repo.ls_files.keys
31
32
  end
32
33
 
33
34
  if blank?(test_files)
data/lib/jeweler/tasks.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'rake'
2
2
  require 'rake/tasklib'
3
3
 
4
+ class Rake::Application
5
+ attr_accessor :jeweler
6
+ end
7
+
4
8
  class Jeweler
5
9
  class Tasks < ::Rake::TaskLib
6
10
  attr_accessor :gemspec, :jeweler
@@ -10,25 +14,27 @@ class Jeweler
10
14
  @jeweler = Jeweler.new(@gemspec)
11
15
  yield @gemspec if block_given?
12
16
 
17
+ Rake.application.jeweler = @jeweler
13
18
  define
14
19
  end
15
20
 
16
21
  private
17
22
  def define
18
23
  desc "Setup initial version of 0.0.0"
19
- file "VERSION.yml" do
20
- @jeweler.write_version 0, 0, 0, :commit => false
21
- $stdout.puts "Created VERSION.yml: 0.0.0"
24
+ task :version_required do
25
+ unless jeweler.version_exists?
26
+ abort "Expected VERSION or VERSION.yml to exist. See version:write to create an initial one."
27
+ end
22
28
  end
23
29
 
24
30
  desc "Build gem"
25
31
  task :build do
26
- @jeweler.build_gem
32
+ jeweler.build_gem
27
33
  end
28
34
 
29
35
  desc "Install gem using sudo"
30
36
  task :install => :build do
31
- @jeweler.install_gem
37
+ jeweler.install_gem
32
38
  end
33
39
 
34
40
  desc "Generate and validates gemspec"
@@ -36,53 +42,53 @@ class Jeweler
36
42
 
37
43
  namespace :gemspec do
38
44
  desc "Validates the gemspec"
39
- task :validate => 'VERSION.yml' do
40
- @jeweler.validate_gemspec
45
+ task :validate => :version_required do
46
+ jeweler.validate_gemspec
41
47
  end
42
48
 
43
- desc "Generates the gemspec, using version from VERSION.yml"
44
- task :generate => 'VERSION.yml' do
45
- @jeweler.write_gemspec
49
+ desc "Generates the gemspec, using version from VERSION"
50
+ task :generate => :version_required do
51
+ jeweler.write_gemspec
46
52
  end
47
53
  end
48
54
 
49
55
  desc "Displays the current version"
50
- task :version => 'VERSION.yml' do
51
- $stdout.puts "Current version: #{@jeweler.version}"
56
+ task :version => :version_required do
57
+ $stdout.puts "Current version: #{jeweler.version}"
52
58
  end
53
59
 
54
60
  namespace :version do
55
61
  desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
56
62
  task :write do
57
63
  major, minor, patch = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i
58
- @jeweler.write_version(major, minor, patch, :announce => false, :commit => false)
59
- $stdout.puts "Updated version: #{@jeweler.version}"
64
+ jeweler.write_version(major, minor, patch, :announce => false, :commit => false)
65
+ $stdout.puts "Updated version: #{jeweler.version}"
60
66
  end
61
67
 
62
68
  namespace :bump do
63
69
  desc "Bump the gemspec by a major version."
64
- task :major => ['VERSION.yml', :version] do
65
- @jeweler.bump_major_version
66
- $stdout.puts "Updated version: #{@jeweler.version}"
70
+ task :major => [:version_required, :version] do
71
+ jeweler.bump_major_version
72
+ $stdout.puts "Updated version: #{jeweler.version}"
67
73
  end
68
74
 
69
75
  desc "Bump the gemspec by a minor version."
70
- task :minor => ['VERSION.yml', :version] do
71
- @jeweler.bump_minor_version
72
- $stdout.puts "Updated version: #{@jeweler.version}"
76
+ task :minor => [:version_required, :version] do
77
+ jeweler.bump_minor_version
78
+ $stdout.puts "Updated version: #{jeweler.version}"
73
79
  end
74
80
 
75
81
  desc "Bump the gemspec by a patch version."
76
- task :patch => ['VERSION.yml', :version] do
77
- @jeweler.bump_patch_version
78
- $stdout.puts "Updated version: #{@jeweler.version}"
82
+ task :patch => [:version_required, :version] do
83
+ jeweler.bump_patch_version
84
+ $stdout.puts "Updated version: #{jeweler.version}"
79
85
  end
80
86
  end
81
87
  end
82
88
 
83
89
  desc "Release the current version. Includes updating the gemspec, pushing, and tagging the release"
84
90
  task :release do
85
- @jeweler.release
91
+ jeweler.release
86
92
  end
87
93
 
88
94
  namespace :rubyforge do
@@ -90,7 +96,7 @@ class Jeweler
90
96
  desc "Release the current gem version to RubyForge."
91
97
  task :gem => [:gemspec, :build] do
92
98
  begin
93
- @jeweler.release_gem_to_rubyforge
99
+ jeweler.release_gem_to_rubyforge
94
100
  rescue NoRubyForgeProjectInGemspecError => e
95
101
  abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
96
102
  rescue MissingRubyForgePackageError => e
@@ -104,7 +110,7 @@ class Jeweler
104
110
  desc "Setup a rubyforge project for this gem"
105
111
  task :setup do
106
112
  begin
107
- @jeweler.setup_rubyforge
113
+ jeweler.setup_rubyforge
108
114
  rescue NoRubyForgeProjectInGemspecError => e
109
115
  abort "Setting up RubyForge requires that you specify a 'rubyforge_project' in your Jeweler::Tasks declaration"
110
116
  rescue RubyForgeProjectNotConfiguredError => e
@@ -1,4 +1,4 @@
1
- = <%= github_repo_name %>
1
+ = <%= project_name %>
2
2
 
3
3
  Description goes here.
4
4
 
@@ -4,62 +4,66 @@ require 'rake'
4
4
  begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
- gem.name = "<%= github_repo_name %>"
7
+ gem.name = "<%= project_name %>"
8
8
  gem.summary = %Q{<%= summary %>}
9
9
  gem.email = "<%= user_email %>"
10
- gem.homepage = "<%= github_url %>"
10
+ gem.homepage = "<%= project_homepage %>"
11
11
  gem.authors = ["<%= user_name %>"]
12
12
  <% if should_setup_rubyforge %>
13
- gem.rubyforge_project = "<%= github_repo_name %>"
14
- <% end %>
13
+ gem.rubyforge_project = "<%= project_name %>"
14
+ <% end %>
15
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
16
  end
17
+
18
+ <% if should_setup_rubyforge %>
19
+ Jeweler::RubyforgeTasks.new
20
+ <% end %>
17
21
  rescue LoadError
18
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
23
  end
20
24
 
21
- <% case testing_framework.to_sym %>
25
+ <% case testing_framework %>
22
26
  <% when :rspec %>
23
27
  require 'spec/rake/spectask'
24
- Spec::Rake::SpecTask.new(:spec) do |spec|
25
- spec.libs << 'lib' << 'spec'
26
- spec.spec_files = FileList['spec/**/*_spec.rb']
28
+ Spec::Rake::SpecTask.new(:<%= test_task %>) do |<%= test_task %>|
29
+ <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
30
+ <%= test_task %>.spec_files = FileList['<%= test_pattern %>']
27
31
  end
28
32
  <% when :micronaut %>
29
33
  require 'micronaut/rake_task'
30
- Micronaut::RakeTask.new(:examples) do |examples|
31
- examples.pattern = 'examples/**/*_example.rb'
32
- examples.ruby_opts << '-Ilib -Iexamples'
34
+ Micronaut::RakeTask.new(<%= test_task %>) do |<%= test_task %>|
35
+ <%= test_task %>.pattern = '<%= test_pattern %>'
36
+ <%= test_task %>.ruby_opts << '-Ilib -I<%= test_dir %>'
33
37
  end
34
38
  <% else %>
35
39
  require 'rake/testtask'
36
- Rake::TestTask.new(:<%= test_or_spec %>) do |<%= test_or_spec %>|
37
- <%= test_or_spec %>.libs << 'lib' << '<%= test_or_spec %>'
38
- <%= test_or_spec %>.pattern = '<%= test_or_spec %>/**/*_<%= test_or_spec %>.rb'
39
- <%= test_or_spec %>.verbose = true
40
+ Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
41
+ <%= test_task %>.libs << 'lib' << '<%= test_dir %>'
42
+ <%= test_task %>.pattern = '<%= test_pattern %>'
43
+ <%= test_task %>.verbose = true
40
44
  end
41
45
  <% end %>
42
46
 
43
- <% case testing_framework.to_sym %>
47
+ <% case testing_framework %>
44
48
  <% when :rspec %>
45
49
  Spec::Rake::SpecTask.new(:rcov) do |spec|
46
50
  spec.libs << 'lib' << 'spec'
47
- spec.pattern = 'spec/**/*_spec.rb'
51
+ spec.pattern = '<%= test_pattern %>'
48
52
  spec.rcov = true
49
53
  end
50
54
  <% when :micronaut %>
51
55
  Micronaut::RakeTask.new(:rcov) do |examples|
52
- examples.pattern = 'examples/**/*_example.rb'
53
- examples.rcov_opts = '-Ilib -Iexamples'
56
+ examples.pattern = '<%= test_pattern %>'
57
+ examples.rcov_opts = '-Ilib -I<%= test_dir %>'
54
58
  examples.rcov = true
55
59
  end
56
60
  <% else %>
57
61
  begin
58
62
  require 'rcov/rcovtask'
59
- Rcov::RcovTask.new do |<%= test_or_spec %>|
60
- <%= test_or_spec %>.libs << '<%= test_or_spec %>'
61
- <%= test_or_spec %>.pattern = '<%= test_or_spec %>/**/*_<%= test_or_spec %>.rb'
62
- <%= test_or_spec %>.verbose = true
63
+ Rcov::RcovTask.new do |<%= test_task %>|
64
+ <%= test_task %>.libs << '<%= test_dir %>'
65
+ <%= test_task %>.pattern = '<%= test_pattern %>'
66
+ <%= test_task %>.verbose = true
63
67
  end
64
68
  rescue LoadError
65
69
  task :rcov do
@@ -91,35 +95,8 @@ Rake::RDocTask.new do |rdoc|
91
95
  end
92
96
 
93
97
  rdoc.rdoc_dir = 'rdoc'
94
- rdoc.title = "<%= github_repo_name %> #{version}"
98
+ rdoc.title = "<%= project_name %> #{version}"
95
99
  rdoc.rdoc_files.include('README*')
96
100
  rdoc.rdoc_files.include('lib/**/*.rb')
97
101
  end
98
102
 
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 %>
@@ -3,6 +3,6 @@ require 'bacon'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require '<%= file_name_prefix %>'
6
+ require '<%= require_name %>'
7
7
 
8
8
  Bacon.summary_on_exit
@@ -1,11 +1,8 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
- require '<%= file_name_prefix %>'
2
+ require '<%= require_name %>'
3
3
 
4
4
  require '<%= feature_support_require %>'
5
+ <% if feature_support_extend %>
5
6
 
6
- World do |world|
7
- <% if feature_support_extend %>
8
- world.extend(<%= feature_support_extend %>)
9
- <% end %>
10
- world
11
- end
7
+ World(<%= feature_support_extend %>)
8
+ <% end %>
@@ -4,7 +4,7 @@ require 'micronaut'
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
 
7
- require '<%= file_name_prefix %>'
7
+ require '<%= require_name %>'
8
8
 
9
9
  def not_in_editor?
10
10
  !(ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM'))
@@ -3,7 +3,7 @@ require 'mini/test'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require '<%= file_name_prefix %>'
6
+ require '<%= require_name %>'
7
7
 
8
8
  class Mini::Test::TestCase
9
9
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "<%= constant_name %>" do
4
4
  it "fails" do
@@ -2,7 +2,7 @@ require 'spec'
2
2
 
3
3
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
- require '<%= file_name_prefix %>'
5
+ require '<%= require_name %>'
6
6
 
7
7
  Spec::Runner.configure do |config|
8
8
 
@@ -4,7 +4,7 @@ require 'shoulda'
4
4
 
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
6
  $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require '<%= file_name_prefix %>'
7
+ require '<%= require_name %>'
8
8
 
9
9
  class Test::Unit::TestCase
10
10
  end
@@ -3,7 +3,7 @@ require 'test/unit'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require '<%= file_name_prefix %>'
6
+ require '<%= require_name %>'
7
7
 
8
8
  class Test::Unit::TestCase
9
9
  end
@@ -5,11 +5,85 @@ class Jeweler
5
5
  attr_accessor :base_dir
6
6
  attr_reader :major, :minor, :patch
7
7
 
8
+ module YamlExtension
9
+ def write
10
+ File.open(yaml_path, 'w+') do |f|
11
+ YAML.dump(self.to_hash, f)
12
+ end
13
+ end
14
+
15
+ def to_hash
16
+ {
17
+ :major => major,
18
+ :minor => minor,
19
+ :patch => patch
20
+ }
21
+ end
22
+
23
+ def refresh
24
+ parse_yaml
25
+ end
26
+
27
+ def parse_yaml
28
+ yaml = read_yaml
29
+ @major = (yaml['major'] || yaml[:major]).to_i
30
+ @minor = (yaml['minor'] || yaml[:minor]).to_i
31
+ @patch = (yaml['patch'] || yaml[:patch]).to_i
32
+ end
33
+
34
+ def read_yaml
35
+ if File.exists?(yaml_path)
36
+ YAML.load_file(yaml_path)
37
+ else
38
+ raise VersionYmlError, "#{yaml_path} does not exist!"
39
+ end
40
+ end
41
+
42
+ def path
43
+ yaml_path
44
+ end
45
+ end
46
+
47
+ module PlaintextExtension
48
+ def write
49
+ File.open(plaintext_path, 'w') do |file|
50
+ file.puts to_s
51
+ end
52
+ end
53
+
54
+ def parse_plaintext
55
+ plaintext = read_plaintext.chomp
56
+ if plaintext =~ /^(\d+)\.(\d+)\.(\d+)$/
57
+ @major = $1.to_i
58
+ @minor = $2.to_i
59
+ @patch = $3.to_i
60
+ end
61
+ end
62
+
63
+ def read_plaintext
64
+ File.read(plaintext_path)
65
+ end
66
+
67
+ def refresh
68
+ parse_plaintext
69
+ end
70
+
71
+ def path
72
+ plaintext_path
73
+ end
74
+ end
75
+
8
76
  def initialize(base_dir)
9
77
  self.base_dir = base_dir
10
78
 
11
79
  if File.exists?(yaml_path)
80
+ extend YamlExtension
12
81
  parse_yaml
82
+ else
83
+ extend PlaintextExtension
84
+ if File.exists?(plaintext_path)
85
+ parse_plaintext
86
+ end
13
87
  end
14
88
  end
15
89
 
@@ -34,49 +108,20 @@ class Jeweler
34
108
  @patch = patch
35
109
  end
36
110
 
37
- def write
38
- File.open(yaml_path, 'w+') do |f|
39
- YAML.dump(self.to_hash, f)
40
- end
41
- end
42
-
43
111
  def to_s
44
112
  "#{major}.#{minor}.#{patch}"
45
113
  end
46
114
 
47
- def to_hash
48
- {
49
- :major => major,
50
- :minor => minor,
51
- :patch => patch
52
- }
53
- end
54
-
55
- def refresh
56
- parse_yaml
57
- end
58
-
59
115
  def yaml_path
60
116
  denormalized_path = File.join(@base_dir, 'VERSION.yml')
61
117
  absolute_path = File.expand_path(denormalized_path)
62
118
  absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
63
119
  end
64
120
 
65
- protected
66
-
67
- def parse_yaml
68
- yaml = read_yaml
69
- @major = (yaml['major'] || yaml[:major]).to_i
70
- @minor = (yaml['minor'] || yaml[:minor]).to_i
71
- @patch = (yaml['patch'] || yaml[:patch]).to_i
72
- end
73
-
74
- def read_yaml
75
- if File.exists?(yaml_path)
76
- YAML.load_file(yaml_path)
77
- else
78
- raise VersionYmlError, "#{yaml_path} does not exist!"
79
- end
121
+ def plaintext_path
122
+ denormalized_path = File.join(@base_dir, 'VERSION')
123
+ absolute_path = File.expand_path(denormalized_path)
124
+ absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
80
125
  end
81
126
 
82
127
  end
data/lib/jeweler.rb CHANGED
@@ -13,6 +13,7 @@ require 'jeweler/generator/application'
13
13
  require 'jeweler/commands'
14
14
 
15
15
  require 'jeweler/tasks'
16
+ require 'jeweler/rubyforge_tasks'
16
17
 
17
18
  require 'jeweler/specification'
18
19
 
@@ -133,5 +134,9 @@ class Jeweler
133
134
  File.exists?(File.join(self.base_dir, '.git'))
134
135
  end
135
136
 
137
+ def version_exists?
138
+ File.exists?(@version_helper.plaintext_path) || File.exists?(@version_helper.yaml_path)
139
+ end
140
+
136
141
  end
137
142
 
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
@@ -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.