jeweler 1.8.2 → 2.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.semver +5 -0
- data/.travis.yml +5 -3
- data/ChangeLog.markdown +30 -0
- data/Gemfile +32 -25
- data/Gemfile.lock +117 -46
- data/README.markdown +36 -10
- data/README.org +374 -0
- data/Rakefile +23 -28
- data/bin/jeweler +1 -0
- data/features/generator/gemfile.feature +1 -0
- data/features/generator/test.feature +2 -2
- data/features/step_definitions/debug_steps.rb +0 -1
- data/features/step_definitions/filesystem_steps.rb +2 -3
- data/features/step_definitions/generator_steps.rb +44 -66
- data/features/step_definitions/task_steps.rb +1 -2
- data/features/support/env.rb +22 -9
- data/jeweler.gemspec +64 -45
- data/lib/jeweler/commands/build_gem.rb +6 -2
- data/lib/jeweler/commands/check_dependencies.rb +3 -3
- data/lib/jeweler/commands/install_gem.rb +1 -1
- data/lib/jeweler/commands/release_gemspec.rb +17 -14
- data/lib/jeweler/commands/release_to_git.rb +20 -11
- data/lib/jeweler/commands/validate_gemspec.rb +5 -7
- data/lib/jeweler/commands/version/base.rb +8 -13
- data/lib/jeweler/commands/version/bump_major.rb +1 -3
- data/lib/jeweler/commands/version/bump_minor.rb +1 -2
- data/lib/jeweler/commands/version/bump_patch.rb +1 -4
- data/lib/jeweler/commands/write_gemspec.rb +4 -3
- data/lib/jeweler/commands.rb +6 -6
- data/lib/jeweler/gemspec_helper.rb +15 -15
- data/lib/jeweler/generator/application.rb +5 -10
- data/lib/jeweler/generator/bacon_mixin.rb +2 -4
- data/lib/jeweler/generator/github_mixin.rb +1 -10
- data/lib/jeweler/generator/micronaut_mixin.rb +3 -3
- data/lib/jeweler/generator/minitest_mixin.rb +2 -3
- data/lib/jeweler/generator/options.rb +16 -25
- data/lib/jeweler/generator/rdoc_mixin.rb +1 -1
- data/lib/jeweler/generator/riot_mixin.rb +2 -3
- data/lib/jeweler/generator/rspec_mixin.rb +2 -3
- data/lib/jeweler/generator/shindo_mixin.rb +2 -3
- data/lib/jeweler/generator/shoulda_mixin.rb +2 -3
- data/lib/jeweler/generator/testspec_mixin.rb +2 -3
- data/lib/jeweler/generator/testunit_mixin.rb +1 -3
- data/lib/jeweler/generator/yard_mixin.rb +3 -4
- data/lib/jeweler/generator.rb +52 -45
- data/lib/jeweler/rubyforge_tasks.rb +13 -13
- data/lib/jeweler/rubygems_dot_org_tasks.rb +3 -3
- data/lib/jeweler/rubygems_tasks.rb +3 -3
- data/lib/jeweler/specification.rb +22 -11
- data/lib/jeweler/tasks.rb +68 -59
- data/lib/jeweler/templates/Gemfile +1 -1
- data/lib/jeweler/templates/bacon/flunking.rb +3 -3
- data/lib/jeweler/templates/bacon/helper.rb +1 -0
- data/lib/jeweler/templates/features/support/env.rb +1 -0
- data/lib/jeweler/templates/jeweler_tasks.erb +1 -1
- data/lib/jeweler/templates/micronaut/flunking.rb +3 -3
- data/lib/jeweler/templates/micronaut/helper.rb +1 -0
- data/lib/jeweler/templates/minitest/flunking.rb +1 -1
- data/lib/jeweler/templates/minitest/helper.rb +4 -3
- data/lib/jeweler/templates/other_tasks.erb +4 -20
- data/lib/jeweler/templates/riot/flunking.rb +1 -1
- data/lib/jeweler/templates/riot/helper.rb +1 -0
- data/lib/jeweler/templates/rspec/flunking.rb +3 -3
- data/lib/jeweler/templates/rspec/helper.rb +3 -1
- data/lib/jeweler/templates/shindo/flunking.rb +3 -3
- data/lib/jeweler/templates/shindo/helper.rb +1 -0
- data/lib/jeweler/templates/shoulda/helper.rb +1 -0
- data/lib/jeweler/templates/simplecov.erb +16 -0
- data/lib/jeweler/templates/testspec/flunking.rb +3 -3
- data/lib/jeweler/templates/testspec/helper.rb +1 -1
- data/lib/jeweler/templates/testunit/helper.rb +1 -0
- data/lib/jeweler/version.rb +3 -3
- data/lib/jeweler/version_helper.rb +18 -15
- data/lib/jeweler.rb +23 -23
- data/test/fixtures/bar/lib/foo_the_ultimate_lib.rb +1 -1
- data/test/fixtures/existing-project-with-version-constant/Rakefile +18 -20
- data/test/fixtures/existing-project-with-version-constant/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-constant/test/existing_project_with_version_test.rb +2 -2
- data/test/fixtures/existing-project-with-version-plaintext/Rakefile +17 -19
- data/test/fixtures/existing-project-with-version-plaintext/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-plaintext/test/existing_project_with_version_test.rb +2 -2
- data/test/fixtures/existing-project-with-version-yaml/Rakefile +17 -19
- data/test/fixtures/existing-project-with-version-yaml/existing-project-with-version.gemspec +15 -17
- data/test/fixtures/existing-project-with-version-yaml/test/existing_project_with_version_test.rb +2 -2
- data/test/jeweler/commands/test_build_gem.rb +33 -27
- data/test/jeweler/commands/test_install_gem.rb +7 -7
- data/test/jeweler/commands/test_release_to_gemcutter.rb +6 -7
- data/test/jeweler/commands/test_release_to_git.rb +95 -37
- data/test/jeweler/commands/test_release_to_github.rb +161 -97
- data/test/jeweler/commands/test_validate_gemspec.rb +4 -6
- data/test/jeweler/commands/test_write_gemspec.rb +21 -24
- data/test/jeweler/commands/version/test_base.rb +26 -6
- data/test/jeweler/commands/version/test_bump_major.rb +1 -5
- data/test/jeweler/commands/version/test_bump_minor.rb +1 -2
- data/test/jeweler/commands/version/test_bump_patch.rb +1 -3
- data/test/jeweler/commands/version/test_write.rb +1 -3
- data/test/jeweler/generator/test_application.rb +22 -26
- data/test/jeweler/generator/test_options.rb +26 -38
- data/test/jeweler/test_gemspec_helper.rb +7 -7
- data/test/jeweler/test_generator.rb +31 -33
- data/test/jeweler/test_generator_initialization.rb +40 -57
- data/test/jeweler/test_generator_mixins.rb +6 -7
- data/test/jeweler/test_specification.rb +44 -43
- data/test/jeweler/test_tasks.rb +2 -3
- data/test/jeweler/test_version_helper.rb +33 -35
- data/test/shoulda_macros/jeweler_macros.rb +5 -5
- data/test/test_helper.rb +25 -31
- data/test/test_jeweler.rb +28 -29
- metadata +206 -165
data/lib/jeweler/tasks.rb
CHANGED
@@ -33,11 +33,12 @@ class Jeweler
|
|
33
33
|
# The block variable gem is actually a Gem::Specification, so you can
|
34
34
|
# do anything you would normally do with a Gem::Specification.
|
35
35
|
# For more details, see the official gemspec reference:
|
36
|
-
# http://
|
36
|
+
# http://guides.rubygems.org/specification-reference
|
37
37
|
#
|
38
38
|
# In addition, it provides reasonable defaults for several values. See Jeweler::Specification for more details.
|
39
39
|
class Tasks < ::Rake::TaskLib
|
40
|
-
attr_accessor :gemspec, :
|
40
|
+
attr_accessor :gemspec, :gemspec_building_block
|
41
|
+
attr_writer :jeweler
|
41
42
|
|
42
43
|
def initialize(gemspec = nil, &gemspec_building_block)
|
43
44
|
@gemspec = gemspec || Gem::Specification.new
|
@@ -48,14 +49,16 @@ class Jeweler
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def jeweler
|
51
|
-
|
52
|
-
@jeweler = Jeweler.new(gemspec)
|
53
|
-
gemspec_building_block.call gemspec if gemspec_building_block
|
54
|
-
end
|
55
|
-
@jeweler
|
52
|
+
@jeweler ||= jeweler!
|
56
53
|
end
|
57
54
|
|
58
|
-
|
55
|
+
private
|
56
|
+
|
57
|
+
def jeweler!
|
58
|
+
j = Jeweler.new(gemspec)
|
59
|
+
gemspec_building_block.call gemspec if gemspec_building_block
|
60
|
+
j
|
61
|
+
end
|
59
62
|
|
60
63
|
def yield_gemspec_set_version?
|
61
64
|
yielded_gemspec = @gemspec.dup
|
@@ -65,61 +68,67 @@ class Jeweler
|
|
65
68
|
|
66
69
|
gemspec_building_block.call(yielded_gemspec) if gemspec_building_block
|
67
70
|
|
68
|
-
!
|
71
|
+
!yielded_gemspec.version.nil?
|
72
|
+
end
|
73
|
+
|
74
|
+
def release_args
|
75
|
+
args = {}
|
76
|
+
args[:remote] = ENV['REMOTE']
|
77
|
+
args[:branch] = ENV['BRANCH']
|
78
|
+
args[:local_branch] = ENV['LOCAL_BRANCH']
|
79
|
+
args[:remote_branch] = ENV['REMOTE_BRANCH']
|
80
|
+
args
|
69
81
|
end
|
70
82
|
|
71
83
|
def define
|
72
84
|
task :version_required do
|
73
|
-
if jeweler.expects_version_file? && !jeweler.
|
85
|
+
if jeweler.expects_version_file? && !jeweler.version_file_exist?
|
74
86
|
abort "Expected VERSION or VERSION.yml to exist. Use 'rake version:write' to create an initial one."
|
75
87
|
end
|
76
88
|
end
|
77
89
|
|
78
90
|
task :gemspec_required do
|
79
|
-
|
91
|
+
unless File.exist?(jeweler.gemspec_helper.path)
|
80
92
|
abort "Expected #{jeweler.gemspec_helper.path} to exist. See 'rake gemspec:write' to create it"
|
81
93
|
end
|
82
94
|
end
|
83
95
|
|
84
|
-
|
85
|
-
desc "Build gem into pkg/"
|
96
|
+
desc 'Build gem into pkg/'
|
86
97
|
task :build do
|
87
98
|
jeweler.build_gem
|
88
99
|
end
|
89
100
|
|
90
|
-
|
91
|
-
|
92
|
-
desc "Build and install gem using `gem install`"
|
93
|
-
task :install => [:build] do
|
101
|
+
desc 'Build and install gem using `gem install`'
|
102
|
+
task install: [:build] do
|
94
103
|
jeweler.install_gem
|
95
104
|
end
|
96
105
|
|
97
|
-
desc
|
98
|
-
task :
|
106
|
+
desc 'Displays the current version'
|
107
|
+
task version: :version_required do
|
99
108
|
$stdout.puts "Current version: #{jeweler.version}"
|
100
109
|
end
|
101
110
|
|
102
|
-
desc
|
103
|
-
task :
|
111
|
+
desc 'Release gem'
|
112
|
+
task release: :clean do
|
104
113
|
end
|
105
114
|
|
106
|
-
desc
|
107
|
-
task :
|
115
|
+
desc 'Generate and validate gemspec'
|
116
|
+
task gemspec: ['gemspec:generate', 'gemspec:validate']
|
108
117
|
|
109
118
|
namespace :gemspec do
|
110
|
-
desc
|
111
|
-
task :
|
119
|
+
desc 'Validates the gemspec on the filesystem'
|
120
|
+
task validate: :gemspec_required do
|
112
121
|
jeweler.validate_gemspec
|
113
122
|
end
|
114
123
|
|
115
|
-
desc
|
116
|
-
task :
|
124
|
+
desc 'Regenerate the gemspec on the filesystem'
|
125
|
+
task generate: :version_required do
|
117
126
|
jeweler.write_gemspec
|
118
127
|
end
|
119
128
|
|
120
|
-
desc
|
129
|
+
desc 'Display the gemspec for debugging purposes, as jeweler knows it (not from the filesystem)'
|
121
130
|
task :debug do
|
122
|
-
# TODO move to a command
|
131
|
+
# TODO: move to a command
|
123
132
|
jeweler.gemspec_helper.spec.version ||= begin
|
124
133
|
jeweler.version_helper.refresh
|
125
134
|
jeweler.version_helper.to_s
|
@@ -128,39 +137,41 @@ class Jeweler
|
|
128
137
|
puts jeweler.gemspec_helper.to_ruby
|
129
138
|
end
|
130
139
|
|
131
|
-
desc
|
140
|
+
desc 'Regenerate and validate gemspec, and then commits and pushes to git'
|
132
141
|
task :release do
|
133
|
-
jeweler.release_gemspec
|
142
|
+
jeweler.release_gemspec(release_args)
|
134
143
|
end
|
135
144
|
end
|
136
145
|
|
137
|
-
task :
|
138
|
-
|
146
|
+
task release: 'gemspec:release'
|
139
147
|
|
140
148
|
unless yield_gemspec_set_version?
|
141
149
|
namespace :version do
|
142
|
-
desc
|
150
|
+
desc 'Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH. Also recognizes BUILD, which defaults to nil'
|
143
151
|
task :write do
|
144
|
-
major
|
145
|
-
|
152
|
+
major = ENV['MAJOR'].to_i
|
153
|
+
minor = ENV['MINOR'].to_i
|
154
|
+
patch = ENV['PATCH'].to_i
|
155
|
+
build = (ENV['BUILD'] || nil)
|
156
|
+
jeweler.write_version(major, minor, patch, build, announce: false, commit: false)
|
146
157
|
$stdout.puts "Updated version: #{jeweler.version}"
|
147
158
|
end
|
148
159
|
|
149
160
|
namespace :bump do
|
150
|
-
desc
|
151
|
-
task :
|
161
|
+
desc 'Bump the major version by 1'
|
162
|
+
task major: [:version_required, :version] do
|
152
163
|
jeweler.bump_major_version
|
153
164
|
$stdout.puts "Updated version: #{jeweler.version}"
|
154
165
|
end
|
155
166
|
|
156
|
-
desc
|
157
|
-
task :
|
167
|
+
desc 'Bump the a minor version by 1'
|
168
|
+
task minor: [:version_required, :version] do
|
158
169
|
jeweler.bump_minor_version
|
159
170
|
$stdout.puts "Updated version: #{jeweler.version}"
|
160
171
|
end
|
161
172
|
|
162
|
-
desc
|
163
|
-
task :
|
173
|
+
desc 'Bump the patch version by 1'
|
174
|
+
task patch: [:version_required, :version] do
|
164
175
|
jeweler.bump_patch_version
|
165
176
|
$stdout.puts "Updated version: #{jeweler.version}"
|
166
177
|
end
|
@@ -168,45 +179,44 @@ class Jeweler
|
|
168
179
|
end
|
169
180
|
end
|
170
181
|
|
171
|
-
|
172
182
|
namespace :git do
|
173
|
-
desc
|
183
|
+
desc 'Tag and push release to git. (happens by default with `rake release`)'
|
174
184
|
task :release do
|
175
|
-
jeweler.release_to_git
|
185
|
+
jeweler.release_to_git(release_args)
|
176
186
|
end
|
177
187
|
end
|
178
188
|
|
179
|
-
task :
|
189
|
+
task release: 'git:release'
|
180
190
|
|
181
191
|
unless File.exist?('Gemfile')
|
182
|
-
desc
|
192
|
+
desc 'Check that runtime and development dependencies are installed'
|
183
193
|
task :check_dependencies do
|
184
194
|
jeweler.check_dependencies
|
185
195
|
end
|
186
196
|
|
187
197
|
namespace :check_dependencies do
|
188
|
-
desc
|
189
|
-
task :runtime
|
198
|
+
desc 'Check that runtime dependencies are installed'
|
199
|
+
task :runtime do
|
190
200
|
jeweler.check_dependencies(:runtime)
|
191
201
|
end
|
192
202
|
|
193
|
-
desc
|
203
|
+
desc'Check that development dependencies are installed'
|
194
204
|
task :development do
|
195
205
|
jeweler.check_dependencies(:development)
|
196
206
|
end
|
197
207
|
end
|
198
208
|
end
|
199
209
|
|
200
|
-
desc
|
201
|
-
task :console, [:script] do |
|
202
|
-
# TODO move to a command
|
203
|
-
dirs =
|
210
|
+
desc 'Start IRB with all runtime dependencies loaded'
|
211
|
+
task :console, [:script] do |_t, args|
|
212
|
+
# TODO: move to a command
|
213
|
+
dirs = %w(ext lib).select { |dir| File.directory?(dir) }
|
204
214
|
|
205
215
|
original_load_path = $LOAD_PATH
|
206
216
|
|
207
|
-
|
208
|
-
|
209
|
-
|
217
|
+
_cmd = if File.exist?('Gemfile')
|
218
|
+
require 'bundler'
|
219
|
+
Bundler.setup(:default)
|
210
220
|
end
|
211
221
|
|
212
222
|
# add the project code directories
|
@@ -222,9 +232,8 @@ class Jeweler
|
|
222
232
|
IRB.start
|
223
233
|
|
224
234
|
# return the $LOAD_PATH to it's original state
|
225
|
-
$LOAD_PATH.reject! { |path| !
|
235
|
+
$LOAD_PATH.reject! { |path| !original_load_path.include?(path) }
|
226
236
|
end
|
227
|
-
|
228
237
|
end
|
229
238
|
end
|
230
239
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
5
|
-
should.flunk
|
3
|
+
describe '<%= constant_name %>' do
|
4
|
+
it 'fails' do
|
5
|
+
should.flunk 'hey buddy, you should probably rename this file and start specing for real'
|
6
6
|
end
|
7
7
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'jeweler'
|
2
2
|
Jeweler::Tasks.new do |gem|
|
3
|
-
# gem is a Gem::Specification... see http://
|
3
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
4
4
|
gem.name = "<%= project_name %>"
|
5
5
|
gem.homepage = "<%= homepage %>"
|
6
6
|
gem.license = "MIT"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'example_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
5
|
-
fail
|
3
|
+
describe '<%= constant_name %>' do
|
4
|
+
it 'fails' do
|
5
|
+
fail 'hey buddy, you should probably rename this file and start specing for real'
|
6
6
|
end
|
7
7
|
end
|
@@ -1,12 +1,13 @@
|
|
1
|
+
<%= render_template 'simplecov.erb' %>
|
1
2
|
require 'rubygems'
|
2
3
|
<%= render_template 'bundler_setup.erb' %>
|
3
|
-
require 'minitest/
|
4
|
+
require 'minitest/test'
|
4
5
|
|
5
6
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
7
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
8
|
require '<%= require_name %>'
|
8
9
|
|
9
|
-
class MiniTest::
|
10
|
+
class MiniTest::Test
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
+
require 'minitest/autorun'
|
@@ -23,27 +23,11 @@ Rake::TestTask.new(:<%= test_task %>) do |<%= test_task %>|
|
|
23
23
|
end
|
24
24
|
<% end %>
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
spec.rcov = true
|
26
|
+
desc "Code coverage detail"
|
27
|
+
task :simplecov do
|
28
|
+
ENV['COVERAGE'] = "true"
|
29
|
+
Rake::Task['<%= test_task %>'].execute
|
31
30
|
end
|
32
|
-
<% when :micronaut %>
|
33
|
-
Micronaut::RakeTask.new(:rcov) do |examples|
|
34
|
-
examples.pattern = '<%= test_pattern %>'
|
35
|
-
examples.rcov_opts = '-Ilib -I<%= test_dir %>'
|
36
|
-
examples.rcov = true
|
37
|
-
end
|
38
|
-
<% else %>
|
39
|
-
require 'rcov/rcovtask'
|
40
|
-
Rcov::RcovTask.new do |<%= test_task %>|
|
41
|
-
<%= test_task %>.libs << '<%= test_dir %>'
|
42
|
-
<%= test_task %>.pattern = '<%= test_pattern %>'
|
43
|
-
<%= test_task %>.verbose = true
|
44
|
-
<%= test_task %>.rcov_opts << '--exclude "gems/*"'
|
45
|
-
end
|
46
|
-
<% end %>
|
47
31
|
|
48
32
|
<% if should_use_cucumber %>
|
49
33
|
require 'cucumber/rake/task'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
5
|
-
fail
|
3
|
+
describe '<%= constant_name %>' do
|
4
|
+
it 'fails' do
|
5
|
+
fail 'hey buddy, you should probably rename this file and start specing for real'
|
6
6
|
end
|
7
7
|
end
|
@@ -1,5 +1,7 @@
|
|
1
|
+
<%= render_template 'simplecov.erb' %>
|
1
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
|
3
5
|
require 'rspec'
|
4
6
|
require '<%= require_name %>'
|
5
7
|
|
@@ -8,5 +10,5 @@ require '<%= require_name %>'
|
|
8
10
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
11
|
|
10
12
|
RSpec.configure do |config|
|
11
|
-
|
13
|
+
|
12
14
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/tests_helper')
|
2
2
|
|
3
|
-
Shindo.tests(
|
4
|
-
test(
|
5
|
-
|
3
|
+
Shindo.tests('<%= constant_name %>') do
|
4
|
+
test('fails') do
|
5
|
+
'hey buddy, you should probably rename this file and start specing for real'
|
6
6
|
false
|
7
7
|
end
|
8
8
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_adapter 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
+
add_filter "/.rvm/"
|
16
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
5
|
-
fail
|
3
|
+
describe '<%= constant_name %>' do
|
4
|
+
it 'fails' do
|
5
|
+
fail 'hey buddy, you should probably rename this file and start specing for real'
|
6
6
|
end
|
7
7
|
end
|
data/lib/jeweler/version.rb
CHANGED
@@ -13,16 +13,16 @@ class Jeweler
|
|
13
13
|
module YamlExtension
|
14
14
|
def write
|
15
15
|
File.open(yaml_path, 'w+') do |f|
|
16
|
-
YAML.dump(
|
16
|
+
YAML.dump(to_hash, f)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_hash
|
21
21
|
{
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
22
|
+
major: major,
|
23
|
+
minor: minor,
|
24
|
+
patch: patch,
|
25
|
+
build: build
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
@@ -39,7 +39,7 @@ class Jeweler
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def read_yaml
|
42
|
-
if File.
|
42
|
+
if File.exist?(yaml_path)
|
43
43
|
YAML.load_file(yaml_path)
|
44
44
|
else
|
45
45
|
raise VersionYmlError, "#{yaml_path} does not exist!"
|
@@ -86,14 +86,12 @@ class Jeweler
|
|
86
86
|
def initialize(base_dir)
|
87
87
|
self.base_dir = base_dir
|
88
88
|
|
89
|
-
if File.
|
89
|
+
if File.exist?(yaml_path)
|
90
90
|
extend YamlExtension
|
91
91
|
parse_yaml
|
92
92
|
else
|
93
93
|
extend PlaintextExtension
|
94
|
-
if File.
|
95
|
-
parse_plaintext
|
96
|
-
end
|
94
|
+
parse_plaintext if File.exist?(plaintext_path)
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
@@ -115,7 +113,7 @@ class Jeweler
|
|
115
113
|
@build = nil
|
116
114
|
end
|
117
115
|
|
118
|
-
def update_to(major, minor, patch, build=nil)
|
116
|
+
def update_to(major, minor, patch, build = nil)
|
119
117
|
@major = major
|
120
118
|
@minor = minor
|
121
119
|
@patch = patch
|
@@ -127,15 +125,20 @@ class Jeweler
|
|
127
125
|
end
|
128
126
|
|
129
127
|
def yaml_path
|
130
|
-
|
131
|
-
absolute_path = File.expand_path(denormalized_path)
|
132
|
-
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
128
|
+
path_to_version_file('VERSION.yml')
|
133
129
|
end
|
134
130
|
|
135
131
|
def plaintext_path
|
136
|
-
|
132
|
+
path_to_version_file('VERSION')
|
133
|
+
end
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def path_to_version_file(filename)
|
138
|
+
denormalized_path = File.join(@base_dir, filename)
|
137
139
|
absolute_path = File.expand_path(denormalized_path)
|
138
140
|
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
139
141
|
end
|
142
|
+
|
140
143
|
end
|
141
144
|
end
|