technicalpickles-jeweler 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -1
- data/VERSION.yml +3 -3
- data/lib/jeweler.rb +202 -9
- data/lib/jeweler/gemspec.rb +25 -37
- data/lib/jeweler/tasks.rb +41 -35
- data/lib/jeweler/version.rb +81 -0
- data/test/gemspec_test.rb +32 -0
- data/test/generators/initialization_test.rb +2 -2
- data/test/jeweler_test.rb +17 -14
- data/test/shoulda_macros/jeweler_macros.rb +0 -3
- data/test/test_helper.rb +13 -0
- data/test/version_test.rb +116 -0
- metadata +7 -5
- data/lib/jeweler/bumping.rb +0 -61
- data/lib/jeweler/release.rb +0 -31
- data/lib/jeweler/versioning.rb +0 -50
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
---
|
2
|
-
patch:
|
3
|
-
major: 0
|
4
|
-
minor: 6
|
2
|
+
:patch: 3
|
3
|
+
:major: 0
|
4
|
+
:minor: 6
|
data/lib/jeweler.rb
CHANGED
@@ -1,20 +1,15 @@
|
|
1
1
|
require 'date'
|
2
|
+
require 'rubygems/builder'
|
2
3
|
|
3
|
-
require 'jeweler/
|
4
|
-
require 'jeweler/versioning'
|
4
|
+
require 'jeweler/version'
|
5
5
|
require 'jeweler/gemspec'
|
6
6
|
require 'jeweler/errors'
|
7
7
|
require 'jeweler/generator'
|
8
|
-
require 'jeweler/release'
|
9
8
|
|
10
9
|
require 'jeweler/tasks'
|
11
10
|
|
12
11
|
# A Jeweler helps you craft the perfect Rubygem. Give him a gemspec, and he takes care of the rest.
|
13
12
|
class Jeweler
|
14
|
-
include Jeweler::Bumping
|
15
|
-
include Jeweler::Versioning
|
16
|
-
include Jeweler::Gemspec
|
17
|
-
include Jeweler::Release
|
18
13
|
|
19
14
|
attr_reader :gemspec
|
20
15
|
attr_accessor :base_dir
|
@@ -23,12 +18,210 @@ class Jeweler
|
|
23
18
|
raise(GemspecError, "Can't create a Jeweler with a nil gemspec") if gemspec.nil?
|
24
19
|
@gemspec = gemspec
|
25
20
|
@base_dir = base_dir
|
26
|
-
|
27
|
-
@gemspec.files
|
21
|
+
|
22
|
+
if @gemspec.files.nil? || @gemspec.files.empty?
|
23
|
+
@gemspec.files = FileList["[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"]
|
24
|
+
end
|
28
25
|
|
29
26
|
if File.exists?(File.join(base_dir, '.git'))
|
30
27
|
@repo = Git.open(base_dir)
|
31
28
|
end
|
29
|
+
|
30
|
+
@version = Jeweler::Version.new(@base_dir)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Major version, as defined by the gemspec's Version module.
|
34
|
+
# For 1.5.3, this would return 1.
|
35
|
+
def major_version
|
36
|
+
@version.major
|
37
|
+
end
|
38
|
+
|
39
|
+
# Minor version, as defined by the gemspec's Version module.
|
40
|
+
# For 1.5.3, this would return 5.
|
41
|
+
def minor_version
|
42
|
+
@version.minor
|
43
|
+
end
|
44
|
+
|
45
|
+
# Patch version, as defined by the gemspec's Version module.
|
46
|
+
# For 1.5.3, this would return 5.
|
47
|
+
def patch_version
|
48
|
+
@version.patch
|
49
|
+
end
|
50
|
+
|
51
|
+
# Human readable version, which is used in the gemspec.
|
52
|
+
def version
|
53
|
+
@version.to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
# Writes out the gemspec
|
57
|
+
def write_gemspec
|
58
|
+
self.refresh_version
|
59
|
+
|
60
|
+
helper = gemspec_helper do |s|
|
61
|
+
s.version = self.version
|
62
|
+
s.date = Time.now
|
63
|
+
end
|
64
|
+
|
65
|
+
helper.write
|
66
|
+
|
67
|
+
puts "Generated: #{helper.path}"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Validates the project's gemspec from disk in an environment similar to how
|
71
|
+
# GitHub would build from it. See http://gist.github.com/16215
|
72
|
+
def validate_gemspec
|
73
|
+
begin
|
74
|
+
gemspec_helper.parse
|
75
|
+
puts "#{gemspec_path} is valid."
|
76
|
+
rescue Exception => e
|
77
|
+
puts "#{gemspec_path} is invalid. See the backtrace for more details."
|
78
|
+
raise
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# is the project's gemspec from disk valid?
|
84
|
+
def valid_gemspec?
|
85
|
+
gemspec_helper.valid?
|
86
|
+
end
|
87
|
+
|
88
|
+
# parses the project's gemspec from disk without extra sanity checks
|
89
|
+
def unsafe_parse_gemspec(data = nil)
|
90
|
+
data ||= File.read(gemspec_path)
|
91
|
+
eval(data, binding, gemspec_path)
|
92
|
+
end
|
93
|
+
|
94
|
+
def build_gem
|
95
|
+
parsed_gemspec = unsafe_parse_gemspec()
|
96
|
+
Gem::Builder.new(parsed_gemspec).build
|
97
|
+
|
98
|
+
pkg_dir = File.join(@base_dir, 'pkg')
|
99
|
+
FileUtils.mkdir_p pkg_dir
|
100
|
+
|
101
|
+
gem_filename = File.join(@base_dir, parsed_gemspec.file_name)
|
102
|
+
FileUtils.mv gem_filename, pkg_dir
|
103
|
+
end
|
104
|
+
|
105
|
+
def install_gem
|
106
|
+
command = "sudo gem install #{gem_path}"
|
107
|
+
$stdout.puts "Executing #{command.inspect}:"
|
108
|
+
sh command
|
109
|
+
end
|
110
|
+
|
111
|
+
# Bumps the patch version.
|
112
|
+
#
|
113
|
+
# 1.5.1 -> 1.5.2
|
114
|
+
def bump_patch_version(options = {})
|
115
|
+
options = version_writing_options(options)
|
116
|
+
|
117
|
+
@version.bump_patch
|
118
|
+
@version.write
|
119
|
+
|
120
|
+
commit_version if options[:commit]
|
121
|
+
end
|
122
|
+
|
123
|
+
# Bumps the minor version.
|
124
|
+
#
|
125
|
+
# 1.5.1 -> 1.6.0
|
126
|
+
def bump_minor_version(options = {})
|
127
|
+
options = version_writing_options(options)
|
128
|
+
|
129
|
+
@version.bump_minor
|
130
|
+
@version.write
|
131
|
+
|
132
|
+
commit_version if options[:commit]
|
133
|
+
end
|
134
|
+
|
135
|
+
# Bumps the major version.
|
136
|
+
#
|
137
|
+
# 1.5.1 -> 2.0.0
|
138
|
+
def bump_major_version(options = {})
|
139
|
+
options = version_writing_options(options)
|
140
|
+
|
141
|
+
@version.bump_major
|
142
|
+
@version.write
|
143
|
+
|
144
|
+
commit_version if options[:commit]
|
145
|
+
end
|
146
|
+
|
147
|
+
# Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
|
148
|
+
def write_version(major, minor, patch, options = {})
|
149
|
+
options = version_writing_options(options)
|
150
|
+
|
151
|
+
@version.update_to major, minor, patch
|
152
|
+
@version.write
|
153
|
+
|
154
|
+
@gemspec.version = @version.to_s
|
155
|
+
|
156
|
+
commit_version if options[:commit]
|
157
|
+
end
|
158
|
+
|
159
|
+
|
160
|
+
def release
|
161
|
+
@repo.checkout('master')
|
162
|
+
|
163
|
+
raise "Hey buddy, try committing them files first" if any_pending_changes?
|
164
|
+
|
165
|
+
write_gemspec()
|
166
|
+
|
167
|
+
@repo.add(gemspec_path)
|
168
|
+
$stdout.puts "Committing #{gemspec_path}"
|
169
|
+
@repo.commit("Regenerated gemspec for version #{version}")
|
170
|
+
|
171
|
+
$stdout.puts "Pushing master to origin"
|
172
|
+
@repo.push
|
173
|
+
|
174
|
+
$stdout.puts "Tagging #{release_tag}"
|
175
|
+
@repo.add_tag(release_tag)
|
176
|
+
|
177
|
+
$stdout.puts "Pushing #{release_tag} to origin"
|
178
|
+
@repo.push('origin', release_tag)
|
179
|
+
end
|
180
|
+
|
181
|
+
def release_tag
|
182
|
+
@release_tag ||= "v#{version}"
|
183
|
+
end
|
184
|
+
|
185
|
+
protected
|
186
|
+
|
187
|
+
def version_writing_options(options)
|
188
|
+
{:commit => true}.merge(options)
|
189
|
+
end
|
190
|
+
|
191
|
+
def commit_version
|
192
|
+
if @repo
|
193
|
+
@repo.add('VERSION.yml')
|
194
|
+
@repo.commit("Version bump to #{version}", 'VERSION.yml')
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def refresh_version
|
199
|
+
@version.refresh
|
200
|
+
end
|
201
|
+
|
202
|
+
def gemspec_helper(&block)
|
203
|
+
GemSpecHelper.new(@gemspec, @base_dir, &block)
|
32
204
|
end
|
205
|
+
|
206
|
+
def gemspec_path
|
207
|
+
gemspec_helper.path
|
208
|
+
end
|
209
|
+
|
210
|
+
def gem_path
|
211
|
+
parsed_gemspec = unsafe_parse_gemspec()
|
212
|
+
File.join(@base_dir, 'pkg', parsed_gemspec.file_name)
|
213
|
+
end
|
214
|
+
|
215
|
+
def any_pending_changes?
|
216
|
+
unless ENV['JEWELER_DEBUG'].nil? || ENV['JEWELER_DEBUG'].squeeze == ''
|
217
|
+
require 'ruby-debug'; breakpoint
|
218
|
+
end
|
219
|
+
!(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
|
220
|
+
end
|
221
|
+
|
222
|
+
protected
|
223
|
+
def any_pending_changes?
|
224
|
+
!(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
|
225
|
+
end
|
33
226
|
end
|
34
227
|
|
data/lib/jeweler/gemspec.rb
CHANGED
@@ -1,53 +1,41 @@
|
|
1
1
|
class Jeweler
|
2
|
-
module Gemspec
|
3
|
-
# Writes out the gemspec
|
4
|
-
def write_gemspec
|
5
|
-
self.refresh_version
|
6
|
-
@gemspec.version = self.version
|
7
|
-
@gemspec.date = Time.now
|
8
|
-
File.open(gemspec_path, 'w') do |f|
|
9
|
-
f.write @gemspec.to_ruby
|
10
|
-
end
|
11
|
-
puts "Generated: #{gemspec_path}"
|
12
|
-
end
|
13
2
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
begin
|
18
|
-
parse_gemspec
|
19
|
-
puts "#{gemspec_path} is valid."
|
20
|
-
rescue Exception => e
|
21
|
-
puts "#{gemspec_path} is invalid. See the backtrace for more details."
|
22
|
-
raise
|
23
|
-
end
|
24
|
-
end
|
3
|
+
class GemSpecHelper
|
4
|
+
|
5
|
+
attr_accessor :spec, :base_dir
|
25
6
|
|
7
|
+
def initialize(spec, base_dir = nil)
|
8
|
+
self.spec = spec
|
9
|
+
self.base_dir = base_dir || ''
|
26
10
|
|
27
|
-
|
11
|
+
yield spec if block_given?
|
12
|
+
end
|
13
|
+
|
14
|
+
def valid?
|
28
15
|
begin
|
29
|
-
|
16
|
+
parse
|
30
17
|
true
|
31
|
-
rescue
|
18
|
+
rescue
|
32
19
|
false
|
33
20
|
end
|
34
21
|
end
|
35
|
-
|
36
|
-
def
|
37
|
-
|
38
|
-
|
22
|
+
|
23
|
+
def write
|
24
|
+
File.open(path, 'w') do |f|
|
25
|
+
f.write @spec.to_ruby
|
26
|
+
end
|
39
27
|
end
|
40
28
|
|
41
|
-
def
|
42
|
-
|
43
|
-
|
29
|
+
def path
|
30
|
+
denormalized_path = File.join(@base_dir, "#{@spec.name}.gemspec")
|
31
|
+
absolute_path = File.expand_path(denormalized_path)
|
32
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
44
33
|
end
|
45
34
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
absolute_path = File.expand_path(denormalized_path)
|
50
|
-
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
35
|
+
def parse
|
36
|
+
data = File.read(path)
|
37
|
+
Thread.new { eval("$SAFE = 3\n#{data}", binding, path) }.join
|
51
38
|
end
|
39
|
+
|
52
40
|
end
|
53
41
|
end
|
data/lib/jeweler/tasks.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/tasklib'
|
3
|
-
require 'rubygems/builder'
|
4
3
|
|
5
4
|
class Jeweler
|
6
5
|
class Tasks < ::Rake::TaskLib
|
@@ -16,18 +15,27 @@ class Jeweler
|
|
16
15
|
end
|
17
16
|
|
18
17
|
private
|
19
|
-
def
|
20
|
-
|
21
|
-
|
18
|
+
def define
|
19
|
+
desc "Setup initial version of 0.0.0"
|
20
|
+
file "VERSION.yml" do
|
21
|
+
@jeweler.write_version 0, 0, 0, :commit => false
|
22
|
+
$stdout.puts "Created VERSION.yml: 0.0.0"
|
22
23
|
end
|
23
|
-
block.call if block
|
24
|
-
end
|
25
24
|
|
26
|
-
|
27
|
-
desc "
|
28
|
-
task :gem => :'
|
29
|
-
|
30
|
-
|
25
|
+
|
26
|
+
desc "Build gem"
|
27
|
+
task :gem => :'gem:build'
|
28
|
+
|
29
|
+
namespace :gem do
|
30
|
+
desc "Install gem using sudo"
|
31
|
+
task :install => :build do
|
32
|
+
@jeweler.install_gem
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Build gem"
|
36
|
+
task :build => :'gemspec:validate' do
|
37
|
+
@jeweler.build_gem
|
38
|
+
end
|
31
39
|
end
|
32
40
|
|
33
41
|
desc "Generate and validates gemspec"
|
@@ -35,15 +43,13 @@ class Jeweler
|
|
35
43
|
|
36
44
|
namespace :gemspec do
|
37
45
|
desc "Validates the gemspec"
|
38
|
-
task :validate do
|
46
|
+
task :validate => 'VERSION.yml' do
|
39
47
|
@jeweler.validate_gemspec
|
40
48
|
end
|
41
49
|
|
42
|
-
desc "Generates the gemspec"
|
43
|
-
task :generate do
|
44
|
-
|
45
|
-
@jeweler.write_gemspec
|
46
|
-
end
|
50
|
+
desc "Generates the gemspec, using version from VERSION.yml"
|
51
|
+
task :generate => 'VERSION.yml' do
|
52
|
+
@jeweler.write_gemspec
|
47
53
|
end
|
48
54
|
end
|
49
55
|
|
@@ -51,38 +57,38 @@ class Jeweler
|
|
51
57
|
task :version => 'version:display'
|
52
58
|
|
53
59
|
namespace :version do
|
54
|
-
desc "
|
60
|
+
desc "Setup initial version of 0.0.0"
|
61
|
+
task :setup => "VERSION.yml"
|
62
|
+
|
63
|
+
desc "Writes out an explicit version. Respects the following environment variables, or defaults to 0: MAJOR, MINOR, PATCH"
|
55
64
|
task :write do
|
56
|
-
|
65
|
+
major, minor, patch = ENV['MAJOR'].to_i, ENV['MINOR'].to_i, ENV['PATCH'].to_i
|
66
|
+
@jeweler.write_version(major, minor, patch, :announce => false, :commit => false)
|
67
|
+
$stdout.puts "Updated version: #{@jeweler.version}"
|
57
68
|
end
|
58
69
|
|
59
70
|
desc "Displays the current version"
|
60
|
-
task :display do
|
61
|
-
|
62
|
-
puts "Current version: #{@jeweler.version}"
|
63
|
-
end
|
71
|
+
task :display => :setup do
|
72
|
+
$stdout.puts "Current version: #{@jeweler.version}"
|
64
73
|
end
|
65
74
|
|
66
75
|
namespace :bump do
|
67
76
|
desc "Bump the gemspec by a major version."
|
68
|
-
task :major => '
|
69
|
-
|
70
|
-
|
71
|
-
end
|
77
|
+
task :major => ['VERSION.yml', :display] do
|
78
|
+
@jeweler.bump_major_version
|
79
|
+
$stdout.puts "Updated version: #{@jeweler.version}"
|
72
80
|
end
|
73
81
|
|
74
82
|
desc "Bump the gemspec by a minor version."
|
75
|
-
task :minor => 'version:display' do
|
76
|
-
|
77
|
-
|
78
|
-
end
|
83
|
+
task :minor => ['VERSION.yml', 'version:display'] do
|
84
|
+
@jeweler.bump_minor_version
|
85
|
+
$stdout.puts "Updated version: #{@jeweler.version}"
|
79
86
|
end
|
80
87
|
|
81
88
|
desc "Bump the gemspec by a patch version."
|
82
|
-
task :patch => 'version:display' do
|
83
|
-
|
84
|
-
|
85
|
-
end
|
89
|
+
task :patch => ['VERSION.yml', 'version:display'] do
|
90
|
+
@jeweler.bump_patch_version
|
91
|
+
$stdout.puts "Updated version: #{@jeweler.version}"
|
86
92
|
end
|
87
93
|
end
|
88
94
|
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class Jeweler
|
2
|
+
class Version
|
3
|
+
attr_accessor :base_dir
|
4
|
+
attr_reader :major, :minor, :patch
|
5
|
+
|
6
|
+
def initialize(base_dir)
|
7
|
+
self.base_dir = base_dir
|
8
|
+
|
9
|
+
if File.exists?(yaml_path)
|
10
|
+
parse_yaml
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def bump_major
|
15
|
+
@major += 1
|
16
|
+
@minor = 0
|
17
|
+
@patch = 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def bump_minor
|
21
|
+
@minor += 1
|
22
|
+
@patch = 0
|
23
|
+
end
|
24
|
+
|
25
|
+
def bump_patch
|
26
|
+
@patch += 1
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_to(major, minor, patch)
|
30
|
+
@major = major
|
31
|
+
@minor = minor
|
32
|
+
@patch = patch
|
33
|
+
end
|
34
|
+
|
35
|
+
def write
|
36
|
+
File.open(yaml_path, 'w+') do |f|
|
37
|
+
YAML.dump(self.to_hash, f)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
"#{major}.#{minor}.#{patch}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_hash
|
46
|
+
{
|
47
|
+
:major => major,
|
48
|
+
:minor => minor,
|
49
|
+
:patch => patch
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def refresh
|
54
|
+
parse_yaml
|
55
|
+
end
|
56
|
+
|
57
|
+
def yaml_path
|
58
|
+
denormalized_path = File.join(@base_dir, 'VERSION.yml')
|
59
|
+
absolute_path = File.expand_path(denormalized_path)
|
60
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
61
|
+
end
|
62
|
+
|
63
|
+
protected
|
64
|
+
|
65
|
+
def parse_yaml
|
66
|
+
yaml = read_yaml
|
67
|
+
@major = (yaml['major'] || yaml[:major]).to_i
|
68
|
+
@minor = (yaml['minor'] || yaml[:minor]).to_i
|
69
|
+
@patch = (yaml['patch'] || yaml[:patch]).to_i
|
70
|
+
end
|
71
|
+
|
72
|
+
def read_yaml
|
73
|
+
if File.exists?(yaml_path)
|
74
|
+
YAML.load_file(yaml_path)
|
75
|
+
else
|
76
|
+
raise VersionYmlError, "#{yaml_path} does not exist!"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class GemspecTest < Test::Unit::TestCase
|
4
|
+
context "A Jeweler::GemSpec, given a gemspec" do
|
5
|
+
setup do
|
6
|
+
@spec = build_spec
|
7
|
+
@helper = Jeweler::GemSpecHelper.new(@spec, File.dirname(__FILE__))
|
8
|
+
end
|
9
|
+
|
10
|
+
should 'have sane gemspec path' do
|
11
|
+
assert_equal "test/#{@spec.name}.gemspec", @helper.path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "Jeweler::GemSpec#write" do
|
16
|
+
setup do
|
17
|
+
@spec = build_spec
|
18
|
+
@helper = Jeweler::GemSpecHelper.new(@spec)
|
19
|
+
FileUtils.rm_f(@helper.path)
|
20
|
+
|
21
|
+
@helper.write
|
22
|
+
end
|
23
|
+
|
24
|
+
should "create gemspec file" do
|
25
|
+
assert File.exists?(@helper.path)
|
26
|
+
end
|
27
|
+
|
28
|
+
should "make valid spec" do
|
29
|
+
assert @helper.valid?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -68,7 +68,7 @@ class JewelerGeneratorInitializerTest < Test::Unit::TestCase
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
context "without github
|
71
|
+
context "without github token set" do
|
72
72
|
setup do
|
73
73
|
Jeweler::Generator.any_instance.stubs(:read_git_config).
|
74
74
|
returns({'user.email' => 'bar@example.com', 'user.name' => 'foo', 'github.user' => 'technicalpickles'})
|
@@ -143,4 +143,4 @@ class JewelerGeneratorInitializerTest < Test::Unit::TestCase
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
-
end
|
146
|
+
end
|
data/test/jeweler_test.rb
CHANGED
@@ -12,18 +12,6 @@ class JewelerTest < Test::Unit::TestCase
|
|
12
12
|
FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
|
13
13
|
end
|
14
14
|
|
15
|
-
def build_spec
|
16
|
-
Gem::Specification.new do |s|
|
17
|
-
s.name = "bar"
|
18
|
-
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
19
|
-
s.email = "josh@technicalpickles.com"
|
20
|
-
s.homepage = "http://github.com/technicalpickles/jeweler"
|
21
|
-
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
22
|
-
s.authors = ["Josh Nichols", "Dan Croak"]
|
23
|
-
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
15
|
context "A jeweler without a VERSION.yml" do
|
28
16
|
setup do
|
29
17
|
FileUtils.mkdir_p(tmp_dir)
|
@@ -31,7 +19,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
31
19
|
end
|
32
20
|
|
33
21
|
should "not have VERSION.yml" do
|
34
|
-
assert ! File.exists?(File.join(tmp_dir, '
|
22
|
+
assert ! File.exists?(File.join(tmp_dir, 'VERSION.yml'))
|
35
23
|
end
|
36
24
|
end
|
37
25
|
|
@@ -39,7 +27,7 @@ class JewelerTest < Test::Unit::TestCase
|
|
39
27
|
context "A Jeweler with a VERSION.yml" do
|
40
28
|
setup do
|
41
29
|
FileUtils.cp_r(fixture_dir, tmp_dir)
|
42
|
-
|
30
|
+
|
43
31
|
@jeweler = Jeweler.new(build_spec, tmp_dir)
|
44
32
|
end
|
45
33
|
|
@@ -71,6 +59,21 @@ class JewelerTest < Test::Unit::TestCase
|
|
71
59
|
should_bump_version 2, 0, 0
|
72
60
|
end
|
73
61
|
|
62
|
+
should "should find files" do
|
63
|
+
assert ! @jeweler.gemspec.files.empty?
|
64
|
+
end
|
65
|
+
|
66
|
+
context "with standard 'files' specified" do
|
67
|
+
setup do
|
68
|
+
@alt_jeweler = Jeweler.new(build_spec("[A-Z]*.*", "{bin,generators,lib,test,spec}/**/*"), tmp_dir)
|
69
|
+
end
|
70
|
+
|
71
|
+
should "have the same files as when no 'files' are specified" do
|
72
|
+
assert_equal @jeweler.gemspec.files, @alt_jeweler.gemspec.files
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
74
77
|
context "writing the gemspec" do
|
75
78
|
setup do
|
76
79
|
@output = catch_out { @jeweler.write_gemspec }
|
data/test/test_helper.rb
CHANGED
@@ -27,6 +27,7 @@ require 'jeweler'
|
|
27
27
|
# Fake out FileList from Rake
|
28
28
|
class FileList
|
29
29
|
def self.[](*args)
|
30
|
+
TMP_DIR.entries - ['.','..','.DS_STORE']
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -47,4 +48,16 @@ class Test::Unit::TestCase
|
|
47
48
|
def tmp_dir
|
48
49
|
File.join(File.dirname(__FILE__), 'tmp')
|
49
50
|
end
|
51
|
+
|
52
|
+
def build_spec(*files)
|
53
|
+
Gem::Specification.new do |s|
|
54
|
+
s.name = "bar"
|
55
|
+
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
56
|
+
s.email = "josh@technicalpickles.com"
|
57
|
+
s.homepage = "http://github.com/technicalpickles/jeweler"
|
58
|
+
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
59
|
+
s.authors = ["Josh Nichols", "Dan Croak"]
|
60
|
+
s.files = FileList[*files] unless files.empty?
|
61
|
+
end
|
62
|
+
end
|
50
63
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class VersionTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
VERSION_TMP_DIR = File.dirname(__FILE__) + '/version_tmp'
|
6
|
+
|
7
|
+
|
8
|
+
def self.should_have_version(major, minor, patch)
|
9
|
+
should "have major version #{major}" do
|
10
|
+
assert_equal major, @version.major
|
11
|
+
end
|
12
|
+
|
13
|
+
should "have minor version #{minor}" do
|
14
|
+
assert_equal minor, @version.minor
|
15
|
+
end
|
16
|
+
|
17
|
+
should "have patch version #{patch}" do
|
18
|
+
assert_equal patch, @version.patch
|
19
|
+
end
|
20
|
+
|
21
|
+
version_s = "#{major}.#{minor}.#{patch}"
|
22
|
+
should "render string as #{version_s.inspect}" do
|
23
|
+
assert_equal version_s, @version.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
version_hash = {:major => major, :minor => minor, :patch => patch}
|
27
|
+
should "render hash as #{version_hash.inspect}" do
|
28
|
+
assert_equal version_hash, @version.to_hash
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
context "VERSION.yml with 3.5.4" do
|
34
|
+
setup do
|
35
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
36
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
37
|
+
|
38
|
+
build_version_yml VERSION_TMP_DIR, 3, 5, 4
|
39
|
+
|
40
|
+
@version = Jeweler::Version.new VERSION_TMP_DIR
|
41
|
+
end
|
42
|
+
|
43
|
+
should_have_version 3, 5, 4
|
44
|
+
|
45
|
+
context "bumping major version" do
|
46
|
+
setup { @version.bump_major }
|
47
|
+
should_have_version 4, 0, 0
|
48
|
+
end
|
49
|
+
|
50
|
+
context "bumping the minor version" do
|
51
|
+
setup { @version.bump_minor }
|
52
|
+
should_have_version 3, 6, 0
|
53
|
+
end
|
54
|
+
|
55
|
+
context "bumping the patch version" do
|
56
|
+
setup { @version.bump_patch }
|
57
|
+
should_have_version 3, 5, 5
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "Non-existant VERSION.yml" do
|
62
|
+
setup do
|
63
|
+
FileUtils.rm_rf VERSION_TMP_DIR
|
64
|
+
FileUtils.mkdir_p VERSION_TMP_DIR
|
65
|
+
end
|
66
|
+
|
67
|
+
should "not raise error if the VERSION.yml doesn't exist" do
|
68
|
+
assert_nothing_raised Jeweler::VersionYmlError do
|
69
|
+
Jeweler::Version.new(VERSION_TMP_DIR)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "setting an initial version" do
|
74
|
+
setup do
|
75
|
+
@version = Jeweler::Version.new(VERSION_TMP_DIR)
|
76
|
+
@version.update_to 0, 0, 1
|
77
|
+
end
|
78
|
+
|
79
|
+
should_have_version 0, 0, 1
|
80
|
+
should "not create VERSION.yml" do
|
81
|
+
assert ! File.exists?(File.join(VERSION_TMP_DIR, 'VERSION.yml'))
|
82
|
+
end
|
83
|
+
|
84
|
+
context "outputting" do
|
85
|
+
setup do
|
86
|
+
@version.write
|
87
|
+
end
|
88
|
+
|
89
|
+
should "create VERSION.yml" do
|
90
|
+
assert File.exists?(File.join(VERSION_TMP_DIR, 'VERSION.yml'))
|
91
|
+
end
|
92
|
+
|
93
|
+
context "re-reading VERSION.yml" do
|
94
|
+
setup do
|
95
|
+
@version = Jeweler::Version.new(VERSION_TMP_DIR)
|
96
|
+
end
|
97
|
+
|
98
|
+
should_have_version 0, 0, 1
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def build_version_yml(base_dir, major, minor, patch)
|
105
|
+
version_yaml_path = File.join(base_dir, 'VERSION.yml')
|
106
|
+
|
107
|
+
File.open(version_yaml_path, 'w+') do |f|
|
108
|
+
version_hash = {
|
109
|
+
'major' => major.to_i,
|
110
|
+
'minor' => minor.to_i,
|
111
|
+
'patch' => patch.to_i
|
112
|
+
}
|
113
|
+
YAML.dump(version_hash, f)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technicalpickles-jeweler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-27 00:00:00 -08:00
|
13
13
|
default_executable: jeweler
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -36,11 +36,9 @@ files:
|
|
36
36
|
- VERSION.yml
|
37
37
|
- bin/jeweler
|
38
38
|
- lib/jeweler
|
39
|
-
- lib/jeweler/bumping.rb
|
40
39
|
- lib/jeweler/errors.rb
|
41
40
|
- lib/jeweler/gemspec.rb
|
42
41
|
- lib/jeweler/generator.rb
|
43
|
-
- lib/jeweler/release.rb
|
44
42
|
- lib/jeweler/tasks.rb
|
45
43
|
- lib/jeweler/templates
|
46
44
|
- lib/jeweler/templates/bacon
|
@@ -52,11 +50,12 @@ files:
|
|
52
50
|
- lib/jeweler/templates/shoulda
|
53
51
|
- lib/jeweler/templates/shoulda/flunking_test.rb
|
54
52
|
- lib/jeweler/templates/shoulda/test_helper.rb
|
55
|
-
- lib/jeweler/
|
53
|
+
- lib/jeweler/version.rb
|
56
54
|
- lib/jeweler.rb
|
57
55
|
- test/fixtures
|
58
56
|
- test/fixtures/bar
|
59
57
|
- test/fixtures/bar/VERSION.yml
|
58
|
+
- test/gemspec_test.rb
|
60
59
|
- test/generators
|
61
60
|
- test/generators/initialization_test.rb
|
62
61
|
- test/jeweler_generator_test.rb
|
@@ -65,6 +64,9 @@ files:
|
|
65
64
|
- test/shoulda_macros/jeweler_macros.rb
|
66
65
|
- test/tasks_test.rb
|
67
66
|
- test/test_helper.rb
|
67
|
+
- test/version_test.rb
|
68
|
+
- test/version_tmp
|
69
|
+
- test/version_tmp/VERSION.yml
|
68
70
|
- lib/jeweler/templates/.gitignore
|
69
71
|
has_rdoc: false
|
70
72
|
homepage: http://github.com/technicalpickles/jeweler
|
data/lib/jeweler/bumping.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
class Jeweler
|
2
|
-
module Bumping
|
3
|
-
# Bumps the patch version.
|
4
|
-
#
|
5
|
-
# 1.5.1 -> 1.5.2
|
6
|
-
def bump_patch_version()
|
7
|
-
patch = self.patch_version.to_i + 1
|
8
|
-
|
9
|
-
write_version(major_version, minor_version, patch)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Bumps the minor version.
|
13
|
-
#
|
14
|
-
# 1.5.1 -> 1.6.0
|
15
|
-
def bump_minor_version()
|
16
|
-
minor = minor_version.to_i + 1
|
17
|
-
|
18
|
-
write_version(major_version, minor)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Bumps the major version.
|
22
|
-
#
|
23
|
-
# 1.5.1 -> 2.0.0
|
24
|
-
def bump_major_version()
|
25
|
-
major = major_version.to_i + 1
|
26
|
-
|
27
|
-
write_version(major)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
|
31
|
-
def write_version(major = 0, minor = 0, patch = 0)
|
32
|
-
major ||= 0
|
33
|
-
minor ||= 0
|
34
|
-
patch ||= 0
|
35
|
-
|
36
|
-
File.open(version_yaml_path, 'w+') do |f|
|
37
|
-
version_hash = {
|
38
|
-
'major' => major.to_i,
|
39
|
-
'minor' => minor.to_i,
|
40
|
-
'patch' => patch.to_i
|
41
|
-
}
|
42
|
-
YAML.dump(version_hash, f)
|
43
|
-
end
|
44
|
-
|
45
|
-
refresh_version
|
46
|
-
|
47
|
-
@gemspec.version = version
|
48
|
-
|
49
|
-
puts "Wrote to #{version_yaml_path}: #{version}"
|
50
|
-
|
51
|
-
commit_version
|
52
|
-
end
|
53
|
-
|
54
|
-
def commit_version
|
55
|
-
if @repo
|
56
|
-
@repo.add('VERSION.yml')
|
57
|
-
@repo.commit("Version bump to #{version}", 'VERSION.yml')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/lib/jeweler/release.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
class Jeweler
|
2
|
-
module Release
|
3
|
-
|
4
|
-
def release
|
5
|
-
@repo.checkout('master')
|
6
|
-
|
7
|
-
raise "Hey buddy, try committing them files first" if any_pending_changes?
|
8
|
-
|
9
|
-
write_gemspec()
|
10
|
-
|
11
|
-
@repo.add(gemspec_path)
|
12
|
-
@repo.commit("Regenerated gemspec for version #{version}")
|
13
|
-
@repo.push
|
14
|
-
|
15
|
-
@repo.add_tag(release_tag)
|
16
|
-
@repo.push('origin', release_tag)
|
17
|
-
end
|
18
|
-
|
19
|
-
def release_tag
|
20
|
-
@release_tag ||= "v#{version}"
|
21
|
-
end
|
22
|
-
|
23
|
-
protected
|
24
|
-
def any_pending_changes?
|
25
|
-
unless ENV['JEWELER_DEBUG'].nil? || ENV['JEWELER_DEBUG'].squeeze == ''
|
26
|
-
require 'ruby-debug'; breakpoint
|
27
|
-
end
|
28
|
-
!(@repo.status.added.empty? && @repo.status.deleted.empty? && @repo.status.changed.empty?)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/jeweler/versioning.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
class Jeweler
|
3
|
-
module Versioning
|
4
|
-
# Major version, as defined by the gemspec's Version module.
|
5
|
-
# For 1.5.3, this would return 1.
|
6
|
-
def major_version
|
7
|
-
version_yaml['major']
|
8
|
-
end
|
9
|
-
|
10
|
-
# Minor version, as defined by the gemspec's Version module.
|
11
|
-
# For 1.5.3, this would return 5.
|
12
|
-
def minor_version
|
13
|
-
version_yaml['minor']
|
14
|
-
end
|
15
|
-
|
16
|
-
# Patch version, as defined by the gemspec's Version module.
|
17
|
-
# For 1.5.3, this would return 5.
|
18
|
-
def patch_version
|
19
|
-
version_yaml['patch']
|
20
|
-
end
|
21
|
-
|
22
|
-
# Human readable version, which is used in the gemspec.
|
23
|
-
def version
|
24
|
-
"#{major_version}.#{minor_version}.#{patch_version}"
|
25
|
-
end
|
26
|
-
|
27
|
-
protected
|
28
|
-
def version_yaml_path
|
29
|
-
denormalized_path = File.join(@base_dir, 'VERSION.yml')
|
30
|
-
absolute_path = File.expand_path(denormalized_path)
|
31
|
-
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
32
|
-
end
|
33
|
-
|
34
|
-
def version_yaml
|
35
|
-
@version_yaml ||= read_version_yaml
|
36
|
-
end
|
37
|
-
|
38
|
-
def read_version_yaml
|
39
|
-
if File.exists?(version_yaml_path)
|
40
|
-
YAML.load_file(version_yaml_path)
|
41
|
-
else
|
42
|
-
raise VersionYmlError, "#{version_yaml_path} does not exist!"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def refresh_version
|
47
|
-
@version_yaml = read_version_yaml
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|