technicalpickles-jeweler 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +10 -1
- data/lib/jeweler/tasks.rb +3 -13
- data/lib/jeweler/version.rb +1 -1
- data/lib/jeweler.rb +14 -95
- data/test/jeweler_test.rb +174 -0
- data/test/test_helper.rb +17 -0
- metadata +3 -1
data/Rakefile
CHANGED
@@ -16,4 +16,13 @@ begin
|
|
16
16
|
end
|
17
17
|
rescue LoadError
|
18
18
|
puts "Jeweler not available. Try installing technicalpickles-jeweler."
|
19
|
-
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Rake::TestTask.new do |t|
|
22
|
+
t.libs << 'lib'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Run the test suite"
|
28
|
+
task :default => :test
|
data/lib/jeweler/tasks.rb
CHANGED
@@ -19,30 +19,20 @@ namespace :version do
|
|
19
19
|
jeweler.bump_version(major, 0, 0)
|
20
20
|
jeweler.write_gemspec
|
21
21
|
|
22
|
-
puts "Version bumped to #{
|
22
|
+
puts "Version bumped to #{jeweler.version}"
|
23
23
|
end
|
24
24
|
|
25
25
|
desc "Bump the gemspec a minor version."
|
26
26
|
task :minor do
|
27
27
|
jeweler = Jeweler.instance
|
28
|
-
|
29
|
-
minor = jeweler.minor_version + 1
|
30
|
-
|
31
|
-
jeweler.bump_version(jeweler.major_version, minor, 0)
|
32
|
-
jeweler.write_gemspec
|
33
|
-
|
28
|
+
jeweler.bump_minor_version
|
34
29
|
puts "Version bumped to #{jeweler.version}"
|
35
30
|
end
|
36
31
|
|
37
32
|
desc "Bump the gemspec a patch version."
|
38
33
|
task :patch do
|
39
34
|
jeweler = Jeweler.instance
|
40
|
-
|
41
|
-
patch = jeweler.patch_version + 1
|
42
|
-
|
43
|
-
jeweler.bump_version(jeweler.major_version, jeweler.minor_version, patch)
|
44
|
-
jeweler.write_gemspec
|
45
|
-
|
35
|
+
jeweler.bump_patch_version
|
46
36
|
puts "Version bumped to #{jeweler.version}"
|
47
37
|
end
|
48
38
|
end
|
data/lib/jeweler/version.rb
CHANGED
data/lib/jeweler.rb
CHANGED
@@ -1,17 +1,22 @@
|
|
1
1
|
require 'date'
|
2
2
|
|
3
|
+
require 'jeweler/bumping'
|
4
|
+
require 'jeweler/versioning'
|
5
|
+
require 'jeweler/singleton'
|
6
|
+
require 'jeweler/gemspec'
|
7
|
+
|
3
8
|
class Jeweler
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def self.instance
|
9
|
-
@@instance
|
10
|
-
end
|
9
|
+
include Jeweler::Singleton
|
10
|
+
include Jeweler::Bumping
|
11
|
+
include Jeweler::Versioning
|
12
|
+
include Jeweler::Gemspec
|
11
13
|
|
12
14
|
attr_reader :gemspec
|
13
|
-
|
15
|
+
attr_accessor :base_dir
|
16
|
+
|
17
|
+
def initialize(gemspec, base_dir = '.')
|
14
18
|
@gemspec = gemspec
|
19
|
+
@base_dir = base_dir
|
15
20
|
|
16
21
|
load_version()
|
17
22
|
|
@@ -19,96 +24,10 @@ class Jeweler
|
|
19
24
|
@gemspec.files ||= FileList["[A-Z]*", "{generators,lib,test,spec}/**/*"]
|
20
25
|
end
|
21
26
|
|
22
|
-
|
23
|
-
version_module.const_get(:MAJOR)
|
24
|
-
end
|
25
|
-
|
26
|
-
def minor_version
|
27
|
-
version_module.const_get(:MINOR)
|
28
|
-
end
|
29
|
-
|
30
|
-
def patch_version
|
31
|
-
version_module.const_get(:PATCH)
|
32
|
-
end
|
33
|
-
|
34
|
-
def version
|
35
|
-
"#{major_version}.#{minor_version}.#{patch_version}"
|
36
|
-
end
|
37
|
-
|
38
|
-
def date
|
39
|
-
date = DateTime.now
|
40
|
-
"#{date.year}-#{date.month}-#{date.day}"
|
41
|
-
end
|
42
|
-
|
43
|
-
def bump_version(major, minor, patch)
|
44
|
-
main_module_or_class = constantize(main_module_name)
|
45
|
-
keyword = top_level_keyword
|
46
|
-
|
47
|
-
File.open(version_module_path, 'w') do |file|
|
48
|
-
file.write <<-END
|
49
|
-
#{keyword} #{main_module_name}
|
50
|
-
module Version
|
51
|
-
MAJOR = #{major}
|
52
|
-
MINOR = #{minor}
|
53
|
-
PATCH = #{patch}
|
54
|
-
end
|
55
|
-
end
|
56
|
-
END
|
57
|
-
end
|
58
|
-
@gemspec.version = "#{major}.#{minor}.#{patch}"
|
59
|
-
refresh_version
|
60
|
-
end
|
61
|
-
|
62
|
-
def write_gemspec
|
63
|
-
@gemspec.date = self.date
|
64
|
-
File.open(gemspec_path, 'w') do |f|
|
65
|
-
f.write @gemspec.to_ruby
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
private
|
70
|
-
|
71
|
-
def top_level_keyword
|
72
|
-
main_module_or_class = constantize(main_module_name)
|
73
|
-
case main_module_or_class
|
74
|
-
when Class
|
75
|
-
'class'
|
76
|
-
when Module
|
77
|
-
'module'
|
78
|
-
else
|
79
|
-
raise "Uh, main_module_name should be a class or module, but was a #{main_module_or_class.class}"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def gemspec_path
|
84
|
-
"#{@gemspec.name}.gemspec"
|
85
|
-
end
|
86
|
-
|
87
|
-
def version_module_path
|
88
|
-
"lib/#{@gemspec.name}/version.rb"
|
89
|
-
end
|
90
|
-
|
91
|
-
def version_module
|
92
|
-
constantize("#{main_module_name}::Version")
|
93
|
-
end
|
94
|
-
|
27
|
+
private
|
95
28
|
def main_module_name
|
96
29
|
camelize(@gemspec.name)
|
97
30
|
end
|
98
|
-
|
99
|
-
def refresh_version
|
100
|
-
# Remove the constants, so we can reload the version_module
|
101
|
-
version_module.module_eval do
|
102
|
-
remove_const(:MAJOR) if const_defined?(:MAJOR)
|
103
|
-
remove_const(:MINOR) if const_defined?(:MINOR)
|
104
|
-
remove_const(:PATCH) if const_defined?(:PATCH)
|
105
|
-
end
|
106
|
-
load_version
|
107
|
-
end
|
108
|
-
|
109
|
-
def load_version
|
110
|
-
load version_module_path
|
111
|
-
end
|
112
31
|
end
|
113
32
|
|
114
33
|
require 'jeweler/active_support' # Adds the stolen camelize and constantize
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
class JewelerTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def write_version_file(name, keyword, const_name, major, minor, patch)
|
6
|
+
dir = "#{File.dirname(__FILE__)}/lib/#{name}"
|
7
|
+
FileUtils.mkdir_p(dir)
|
8
|
+
File.open("#{dir}/version.rb", 'w+') do |file|
|
9
|
+
file.write <<-END
|
10
|
+
#{keyword} #{const_name}
|
11
|
+
module Version
|
12
|
+
MAJOR = #{major}
|
13
|
+
MINOR = #{minor}
|
14
|
+
PATCH = #{patch}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
END
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
FileUtils.rm_rf("#{File.dirname(__FILE__)}/lib")
|
23
|
+
FileUtils.rm_f("#{File.dirname(__FILE__)}/foo.gemspec")
|
24
|
+
FileUtils.rm_f("#{File.dirname(__FILE__)}/bar.gemspec")
|
25
|
+
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
def should_have_major_version(version)
|
29
|
+
should "have major version of #{version}" do
|
30
|
+
assert_equal version, @jeweler.major_version
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def should_have_minor_version(version)
|
35
|
+
should "have minor version of #{version}" do
|
36
|
+
assert_equal version, @jeweler.minor_version
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def should_have_patch_version(version)
|
41
|
+
should "have patch version of #{version}" do
|
42
|
+
assert_equal version, @jeweler.patch_version
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def should_be_version(version)
|
47
|
+
should "be version #{version}" do
|
48
|
+
assert_equal version, @jeweler.version
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def should_have_toplevel_keyword(keyword)
|
53
|
+
should "have '#{keyword}' top level keyword" do
|
54
|
+
assert_equal keyword, @jeweler.send(:top_level_keyword)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'A gem, with top level module,' do
|
60
|
+
setup do
|
61
|
+
write_version_file('foo', 'module', 'Foo', 0, 1, 0)
|
62
|
+
@spec = Gem::Specification.new do |s|
|
63
|
+
s.name = 'foo'
|
64
|
+
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
65
|
+
s.email = "josh@technicalpickles.com"
|
66
|
+
s.homepage = "http://github.com/technicalpickles/jeweler"
|
67
|
+
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
68
|
+
s.authors = ["Josh Nichols", "Dan Croak"]
|
69
|
+
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
70
|
+
end
|
71
|
+
@jeweler = Jeweler.new(@spec, File.dirname(__FILE__))
|
72
|
+
end
|
73
|
+
|
74
|
+
teardown do
|
75
|
+
@jeweler.send(:undefine_versions) if @jeweler
|
76
|
+
end
|
77
|
+
|
78
|
+
should_have_major_version 0
|
79
|
+
should_have_minor_version 1
|
80
|
+
should_have_patch_version 0
|
81
|
+
should_be_version '0.1.0'
|
82
|
+
|
83
|
+
should_have_toplevel_keyword 'module'
|
84
|
+
|
85
|
+
context "bumping the patch version" do
|
86
|
+
setup do
|
87
|
+
@jeweler.bump_patch_version
|
88
|
+
end
|
89
|
+
|
90
|
+
should_have_major_version 0
|
91
|
+
should_have_minor_version 1
|
92
|
+
should_have_patch_version 1
|
93
|
+
should_be_version '0.1.1'
|
94
|
+
|
95
|
+
should "still have module Foo" do
|
96
|
+
# do some regexp of version.rb
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "bumping the minor version" do
|
101
|
+
setup do
|
102
|
+
@jeweler.bump_minor_version
|
103
|
+
end
|
104
|
+
|
105
|
+
should_have_major_version 0
|
106
|
+
should_have_minor_version 2
|
107
|
+
should_have_patch_version 0
|
108
|
+
should_be_version '0.2.0'
|
109
|
+
|
110
|
+
should "still have module Foo" do
|
111
|
+
# do some regexp of version.rb
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "bumping the major version" do
|
116
|
+
setup do
|
117
|
+
@jeweler.bump_major_version
|
118
|
+
end
|
119
|
+
|
120
|
+
should_have_major_version 1
|
121
|
+
should_have_minor_version 0
|
122
|
+
should_have_patch_version 0
|
123
|
+
should_be_version '1.0.0'
|
124
|
+
|
125
|
+
should "still have module Foo" do
|
126
|
+
# do some regexp of version.rb
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
context "A gem, with top level class," do
|
133
|
+
setup do
|
134
|
+
write_version_file('bar', 'class', 'Bar', 1, 5, 2)
|
135
|
+
|
136
|
+
@spec = Gem::Specification.new do |s|
|
137
|
+
s.name = "bar"
|
138
|
+
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
139
|
+
s.email = "josh@technicalpickles.com"
|
140
|
+
s.homepage = "http://github.com/technicalpickles/jeweler"
|
141
|
+
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
142
|
+
s.authors = ["Josh Nichols", "Dan Croak"]
|
143
|
+
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
144
|
+
end
|
145
|
+
@jeweler = Jeweler.new(@spec, File.dirname(__FILE__))
|
146
|
+
end
|
147
|
+
|
148
|
+
teardown do
|
149
|
+
@jeweler.send(:undefine_versions) if @jeweler
|
150
|
+
end
|
151
|
+
|
152
|
+
should_have_major_version 1
|
153
|
+
should_have_minor_version 5
|
154
|
+
should_have_patch_version 2
|
155
|
+
should_be_version '1.5.2'
|
156
|
+
should_have_toplevel_keyword 'class'
|
157
|
+
|
158
|
+
context "bumping the patch version" do
|
159
|
+
setup do
|
160
|
+
@jeweler.bump_patch_version
|
161
|
+
end
|
162
|
+
|
163
|
+
should_have_major_version 1
|
164
|
+
should_have_minor_version 5
|
165
|
+
should_have_patch_version 3
|
166
|
+
should_be_version '1.5.3'
|
167
|
+
|
168
|
+
should_eventually "still have class Bar" do
|
169
|
+
# do some regexp of version.rb
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
gem 'thoughtbot-shoulda'
|
5
|
+
require 'shoulda'
|
6
|
+
gem 'ruby-debug'
|
7
|
+
require 'ruby-debug'
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
+
require 'jeweler'
|
12
|
+
|
13
|
+
# Fake out FileList from Rake
|
14
|
+
class FileList
|
15
|
+
def self.[](*args)
|
16
|
+
end
|
17
|
+
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.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -31,6 +31,8 @@ files:
|
|
31
31
|
- lib/jeweler/tasks.rb
|
32
32
|
- lib/jeweler/version.rb
|
33
33
|
- lib/jeweler.rb
|
34
|
+
- test/jeweler_test.rb
|
35
|
+
- test/test_helper.rb
|
34
36
|
has_rdoc: false
|
35
37
|
homepage: http://github.com/technicalpickles/jeweler
|
36
38
|
post_install_message:
|