technicalpickles-jeweler 0.0.7 → 0.1.1
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/README.markdown +63 -29
- data/Rakefile +1 -1
- data/TODO +3 -4
- data/VERSION.yml +4 -0
- data/lib/jeweler.rb +2 -4
- data/lib/jeweler/bumping.rb +22 -39
- data/lib/jeweler/errors.rb +3 -0
- data/lib/jeweler/gemspec.rb +25 -18
- data/lib/jeweler/tasks.rb +42 -20
- data/lib/jeweler/versioning.rb +20 -24
- data/test/jeweler_test.rb +50 -47
- data/test/test_helper.rb +16 -0
- metadata +3 -3
- data/lib/jeweler/version.rb +0 -7
data/README.markdown
CHANGED
@@ -6,18 +6,18 @@ Trouble is when developing your Rubygems on GitHub, you generally do one of the
|
|
6
6
|
|
7
7
|
* Manage the gemspec by hand
|
8
8
|
* ... why bother doing something by hand when you can automate it?
|
9
|
-
* Write your own
|
9
|
+
* Write your own Rake stuff to create the Gem::Specification and output it to a gemspec file, and deal with keeping the Rakefile and gemspec in sync
|
10
10
|
* ... why keep reinventing the wheel?
|
11
|
-
*
|
11
|
+
* Use hoe or echoe for generating the gemspec
|
12
12
|
* ... why use utilities made for the days before GitHub existed?
|
13
13
|
* ... why have extra stuff you aren't going to use?
|
14
14
|
|
15
|
-
Jeweler was created with
|
15
|
+
Jeweler was created with a few intentions:
|
16
16
|
|
17
17
|
* The only configuration should be providing a Gem::Specification to Jeweler
|
18
18
|
* Version bumping should only be one command away
|
19
|
-
* Authoritative version information should stored in one place
|
20
|
-
* Jeweler should only concern itself with versioning and gems
|
19
|
+
* Authoritative version information should stored in one place
|
20
|
+
* Jeweler should only concern itself with versioning and gems
|
21
21
|
* Your Rakefile should be usable when Jeweler isn't installed (you just wouldn't be able to version bump or generate a gemspec)
|
22
22
|
* Jeweler should use Jeweler. Oh the meta!
|
23
23
|
|
@@ -58,38 +58,20 @@ Install the gem:
|
|
58
58
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
59
59
|
end
|
60
60
|
rescue LoadError
|
61
|
-
puts "Jeweler not available.
|
61
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
62
62
|
end
|
63
63
|
|
64
64
|
Note, we don't include 'date', or 'version'. Jeweler handles filing these in when it needs them.
|
65
65
|
|
66
|
-
If you don't specify `s.files`, it will use `s.files = FileList["[A-Z]
|
67
|
-
|
68
|
-
For now, `s.name` should be lower-cased and underscored, without hyphens. That's because Jeweler camelizes and constantizes this value internally. For example, `ruby-debug` would be camelized/constanized to `Ruby-debug`, which isn't a valid constant. Use `ruby_debug` instead (for now).
|
66
|
+
If you don't specify `s.files`, it will use `s.files = FileList["[A-Z]*.*", "{generators,lib,test,spec}/**/*"]`.
|
69
67
|
|
70
68
|
### Create a version file
|
71
69
|
|
72
|
-
|
70
|
+
Create an initial `VERSION.yml`. It will by default to 0.0.0, but you can specify MAJOR, MINOR, and PATCH to tweak it:
|
73
71
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
MINOR = 0
|
78
|
-
PATCH = 0
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
OR
|
83
|
-
|
84
|
-
module Jeweler
|
85
|
-
module Version
|
86
|
-
MAJOR = 0
|
87
|
-
MINOR = 0
|
88
|
-
PATCH = 0
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
Which you use depends on how you want to organize your gem. If you have a top-level class, like Jeweler, use the first. If you have a top level module, like ActiveRecord, use the latter.
|
72
|
+
$ rake version:write MAJOR=1 MINOR=5 PATCH=2
|
73
|
+
(in /Users/nichoj/Projects/jeweler)
|
74
|
+
Wrote to VERSION.yml: 1.5.2
|
93
75
|
|
94
76
|
### Generate the gemspec
|
95
77
|
|
@@ -122,6 +104,10 @@ You have a few rake tasks for doing the version bump:
|
|
122
104
|
$ rake version:bump:minor # 1.5.1 -> 1.6.0
|
123
105
|
$ rake version:bump:major # 1.5.1 -> 2.0.0
|
124
106
|
|
107
|
+
If you need to do an arbitrary bump, use the same task you used to create `VERSION.yml`:
|
108
|
+
|
109
|
+
$ rake version:write MAJOR=6 MINOR=0 PATCH=3
|
110
|
+
|
125
111
|
After that, commit and push it:
|
126
112
|
|
127
113
|
$ git commit -a -m "Version bump, yo."
|
@@ -130,3 +116,51 @@ After that, commit and push it:
|
|
130
116
|
### Play the waiting game
|
131
117
|
|
132
118
|
Wander over to [Has My Gem Built Yet](http://hasmygembuiltyet.org/) to play the waiting game.
|
119
|
+
|
120
|
+
## Extra stuff you might want to for your RubyGem project
|
121
|
+
|
122
|
+
As was mentioned, Jeweler tries to only do versioning and gem stuff. Most projects have a few other needs:
|
123
|
+
|
124
|
+
* Testing
|
125
|
+
* RDoc
|
126
|
+
* Default task
|
127
|
+
|
128
|
+
Jeweler doesn't provide these. But it's easy enough to use Rake's built in tasks:
|
129
|
+
|
130
|
+
require 'rake'
|
131
|
+
require 'rake/testtask'
|
132
|
+
require 'rake/rdoctask'
|
133
|
+
|
134
|
+
begin
|
135
|
+
require 'rubygems'
|
136
|
+
require 'jeweler'
|
137
|
+
Jeweler.gemspec = Gem::Specification.new do |s|
|
138
|
+
s.name = "jeweler"
|
139
|
+
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
140
|
+
s.email = "josh@technicalpickles.com"
|
141
|
+
s.homepage = "http://github.com/technicalpickles/jeweler"
|
142
|
+
s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
143
|
+
s.authors = ["Josh Nichols", "Dan Croak"]
|
144
|
+
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
145
|
+
end
|
146
|
+
rescue LoadError
|
147
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
148
|
+
end
|
149
|
+
|
150
|
+
Rake::TestTask.new do |t|
|
151
|
+
t.libs << 'lib'
|
152
|
+
t.pattern = 'test/**/*_test.rb'
|
153
|
+
t.verbose = false
|
154
|
+
end
|
155
|
+
|
156
|
+
desc 'Generate documentation for the safety_valve plugin.'
|
157
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
158
|
+
rdoc.rdoc_dir = 'rdoc'
|
159
|
+
rdoc.title = 'Jeweler'
|
160
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
161
|
+
rdoc.rdoc_files.include('README.*')
|
162
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
163
|
+
end
|
164
|
+
|
165
|
+
desc "Run the test suite"
|
166
|
+
task :default => :test
|
data/Rakefile
CHANGED
@@ -16,7 +16,7 @@ begin
|
|
16
16
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
17
17
|
end
|
18
18
|
rescue LoadError
|
19
|
-
puts "Jeweler not available.
|
19
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
20
20
|
end
|
21
21
|
|
22
22
|
Rake::TestTask.new do |t|
|
data/TODO
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
*
|
2
|
-
* ruby-debug -> Ruby::Debug
|
3
|
-
* safety_valve -> SafetyValve
|
1
|
+
* Move away from having a version module to having version.yml in top level directory
|
4
2
|
* Generator for making new Jeweler projects
|
5
3
|
* Rails generator for making a plugin that's Jeweler enabled
|
6
4
|
* Git tagging/branching
|
7
5
|
* Make sure everything is pushed/committed before bumping (controlled by a Jeweler.strict perhaps)
|
8
|
-
* Have version:bump:xxx do a commit with an appropriate message
|
6
|
+
* Have version:bump:xxx do a commit with an appropriate message
|
7
|
+
* Capture stdout during testing
|
data/VERSION.yml
ADDED
data/lib/jeweler.rb
CHANGED
@@ -24,10 +24,8 @@ class Jeweler
|
|
24
24
|
@gemspec = gemspec
|
25
25
|
@base_dir = base_dir
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
@gemspec.version = version
|
30
|
-
@gemspec.files ||= FileList["[A-Z]*", "{generators,lib,test,spec}/**/*"]
|
27
|
+
# @gemspec.version = version
|
28
|
+
@gemspec.files ||= FileList["[A-Z]*.*", "{generators,lib,test,spec}/**/*"]
|
31
29
|
end
|
32
30
|
|
33
31
|
private
|
data/lib/jeweler/bumping.rb
CHANGED
@@ -4,65 +4,48 @@ class Jeweler
|
|
4
4
|
#
|
5
5
|
# 1.5.1 -> 1.5.2
|
6
6
|
def bump_patch_version()
|
7
|
-
patch = self.patch_version + 1
|
7
|
+
patch = self.patch_version.to_i + 1
|
8
8
|
|
9
|
-
|
10
|
-
write_gemspec
|
9
|
+
write_version(major_version, minor_version, patch)
|
11
10
|
end
|
12
11
|
|
13
12
|
# Bumps the minor version.
|
14
13
|
#
|
15
14
|
# 1.5.1 -> 1.6.0
|
16
15
|
def bump_minor_version()
|
17
|
-
minor = minor_version + 1
|
16
|
+
minor = minor_version.to_i + 1
|
18
17
|
|
19
|
-
|
20
|
-
write_gemspec
|
18
|
+
write_version(major_version, minor)
|
21
19
|
end
|
22
20
|
|
23
21
|
# Bumps the major version.
|
24
22
|
#
|
25
23
|
# 1.5.1 -> 2.0.0
|
26
24
|
def bump_major_version()
|
27
|
-
major = major_version + 1
|
25
|
+
major = major_version.to_i + 1
|
28
26
|
|
29
|
-
|
30
|
-
write_gemspec
|
27
|
+
write_version(major)
|
31
28
|
end
|
32
29
|
|
33
30
|
# Bumps the version, to the specific major/minor/patch version, writing out the appropriate version.rb, and then reloads it.
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
END
|
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)
|
48
43
|
end
|
49
|
-
@gemspec.version = "#{major}.#{minor}.#{patch}"
|
50
44
|
refresh_version
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
# module. This should be 'module' or 'class', and is used for rewriting the version.rb.
|
56
|
-
def top_level_keyword
|
57
|
-
main_module_or_class = constantize(main_module_name)
|
58
|
-
case main_module_or_class
|
59
|
-
when Class
|
60
|
-
'class'
|
61
|
-
when Module
|
62
|
-
'module'
|
63
|
-
else
|
64
|
-
raise "Uh, main_module_name should be a class or module, but was a #{main_module_or_class.class}"
|
65
|
-
end
|
45
|
+
|
46
|
+
@gemspec.version = version
|
47
|
+
|
48
|
+
puts "Wrote to #{version_yaml_path}: #{version}"
|
66
49
|
end
|
67
50
|
end
|
68
51
|
end
|
data/lib/jeweler/errors.rb
CHANGED
data/lib/jeweler/gemspec.rb
CHANGED
@@ -1,34 +1,21 @@
|
|
1
1
|
class Jeweler
|
2
2
|
module Gemspec
|
3
|
-
# Generates a date for stuffing in the gemspec
|
4
|
-
def date
|
5
|
-
date = DateTime.now
|
6
|
-
"#{date.year}-#{date.month}-#{date.day}"
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
3
|
# Writes out the gemspec
|
11
4
|
def write_gemspec
|
12
|
-
@gemspec.
|
5
|
+
@gemspec.version = self.version
|
6
|
+
@gemspec.date = Time.now
|
13
7
|
File.open(gemspec_path, 'w') do |f|
|
14
8
|
f.write @gemspec.to_ruby
|
15
9
|
end
|
16
|
-
puts "Generated #{gemspec_path}
|
10
|
+
puts "Generated: #{gemspec_path}"
|
17
11
|
end
|
18
12
|
|
19
13
|
# Validates the gemspec in an environment similar to how GitHub would build
|
20
14
|
# it. See http://gist.github.com/16215
|
21
15
|
def validate_gemspec
|
22
16
|
begin
|
23
|
-
# Snippet borrowed from http://gist.github.com/16215
|
24
17
|
data = File.read(gemspec_path)
|
25
|
-
|
26
|
-
spec = nil
|
27
|
-
if data !~ %r{!ruby/object:Gem::Specification}
|
28
|
-
Thread.new { spec = eval("$SAFE = 3\n#{data}", binding, gemspec_path) }.join
|
29
|
-
else
|
30
|
-
spec = YAML.load(data)
|
31
|
-
end
|
18
|
+
Thread.new { spec = parse_gemspec(data) }.join
|
32
19
|
|
33
20
|
puts "#{gemspec_path} is valid."
|
34
21
|
rescue Exception => e
|
@@ -37,9 +24,29 @@ class Jeweler
|
|
37
24
|
end
|
38
25
|
end
|
39
26
|
|
27
|
+
|
28
|
+
def valid_gemspec?
|
29
|
+
# gah, so wet...
|
30
|
+
begin
|
31
|
+
data = File.read(gemspec_path)
|
32
|
+
|
33
|
+
Thread.new { spec = parse_gemspec(data) }.join
|
34
|
+
true
|
35
|
+
rescue Exception => e
|
36
|
+
false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_gemspec(data = nil)
|
41
|
+
data ||= File.read(gemspec_path)
|
42
|
+
eval("$SAFE = 3\n#{data}", binding, gemspec_path)
|
43
|
+
end
|
44
|
+
|
40
45
|
protected
|
41
46
|
def gemspec_path
|
42
|
-
File.join(@base_dir, "#{@gemspec.name}.gemspec")
|
47
|
+
denormalized_path = File.join(@base_dir, "#{@gemspec.name}.gemspec")
|
48
|
+
absolute_path = File.expand_path(denormalized_path)
|
49
|
+
absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
|
43
50
|
end
|
44
51
|
end
|
45
52
|
end
|
data/lib/jeweler/tasks.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ruby-debug'
|
1
2
|
desc "Generate and validates gemspec"
|
2
3
|
task :gemspec => ['gemspec:generate', 'gemspec:validate']
|
3
4
|
|
@@ -14,36 +15,57 @@ namespace :gemspec do
|
|
14
15
|
end
|
15
16
|
|
16
17
|
desc "Displays the current version"
|
17
|
-
task :version
|
18
|
-
puts Jeweler.instance.version
|
19
|
-
end
|
18
|
+
task :version => 'version:display'
|
20
19
|
|
21
20
|
namespace :version do
|
21
|
+
|
22
|
+
desc "Creates an initial version file"
|
23
|
+
task :write do
|
24
|
+
jeweler = Jeweler.instance
|
25
|
+
jeweler.write_version(ENV['MAJOR'], ENV['MINOR'], ENV['PATCH'])
|
26
|
+
end
|
27
|
+
|
28
|
+
def ensure_version_yml(&block)
|
29
|
+
if File.exists? 'VERSION.yml'
|
30
|
+
block.call
|
31
|
+
else
|
32
|
+
abort "VERSION.yml is needed for this operation, but it doesn't exist. Try running 'rake version:write' first."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Displays the current version"
|
37
|
+
task :display do
|
38
|
+
ensure_version_yml do
|
39
|
+
puts "Current version: #{Jeweler.instance.version}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
22
43
|
namespace :bump do
|
23
44
|
desc "Bump the gemspec by a major version."
|
24
|
-
task :major do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
jeweler.write_gemspec
|
31
|
-
|
32
|
-
puts "Version bumped to #{jeweler.version}"
|
45
|
+
task :major => 'version:display' do
|
46
|
+
ensure_version_yml do
|
47
|
+
jeweler = Jeweler.instance
|
48
|
+
jeweler.bump_major_version
|
49
|
+
jeweler.write_gemspec
|
50
|
+
end
|
33
51
|
end
|
34
52
|
|
35
53
|
desc "Bump the gemspec by a minor version."
|
36
|
-
task :minor do
|
37
|
-
|
38
|
-
|
39
|
-
|
54
|
+
task :minor => 'version:display' do
|
55
|
+
ensure_version_yml do
|
56
|
+
jeweler = Jeweler.instance
|
57
|
+
jeweler.bump_minor_version
|
58
|
+
jeweler.write_gemspec
|
59
|
+
end
|
40
60
|
end
|
41
61
|
|
42
62
|
desc "Bump the gemspec by a patch version."
|
43
|
-
task :patch do
|
44
|
-
|
45
|
-
|
46
|
-
|
63
|
+
task :patch => 'version:display' do
|
64
|
+
ensure_version_yml do
|
65
|
+
jeweler = Jeweler.instance
|
66
|
+
jeweler.bump_patch_version
|
67
|
+
jeweler.write_gemspec
|
68
|
+
end
|
47
69
|
end
|
48
70
|
end
|
49
71
|
end
|
data/lib/jeweler/versioning.rb
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
+
require 'yaml'
|
1
2
|
class Jeweler
|
2
3
|
module Versioning
|
3
4
|
# Major version, as defined by the gemspec's Version module.
|
4
5
|
# For 1.5.3, this would return 1.
|
5
6
|
def major_version
|
6
|
-
|
7
|
+
version_yaml['major']
|
7
8
|
end
|
8
9
|
|
9
10
|
# Minor version, as defined by the gemspec's Version module.
|
10
11
|
# For 1.5.3, this would return 5.
|
11
12
|
def minor_version
|
12
|
-
|
13
|
+
version_yaml['minor']
|
13
14
|
end
|
14
15
|
|
15
16
|
# Patch version, as defined by the gemspec's Version module.
|
16
17
|
# For 1.5.3, this would return 5.
|
17
18
|
def patch_version
|
18
|
-
|
19
|
+
version_yaml['patch']
|
19
20
|
end
|
20
21
|
|
21
22
|
# Human readable version, which is used in the gemspec.
|
@@ -24,31 +25,26 @@ class Jeweler
|
|
24
25
|
end
|
25
26
|
|
26
27
|
protected
|
27
|
-
def
|
28
|
-
File.join(@base_dir, '
|
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, '')
|
29
32
|
end
|
30
|
-
|
31
|
-
def
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
def refresh_version
|
37
|
-
undefine_versions()
|
38
|
-
load_version()
|
33
|
+
|
34
|
+
def version_yaml
|
35
|
+
@version_yaml ||= read_version_yaml
|
39
36
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
remove_const(:PATCH) if const_defined?(:PATCH)
|
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!"
|
47
43
|
end
|
48
44
|
end
|
49
|
-
|
50
|
-
def
|
51
|
-
|
45
|
+
|
46
|
+
def refresh_version
|
47
|
+
@version_yaml = read_version_yaml
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|
data/test/jeweler_test.rb
CHANGED
@@ -2,26 +2,11 @@ require File.dirname(__FILE__) + '/test_helper'
|
|
2
2
|
|
3
3
|
class JewelerTest < Test::Unit::TestCase
|
4
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
5
|
def teardown
|
22
6
|
FileUtils.rm_rf("#{File.dirname(__FILE__)}/lib")
|
23
7
|
FileUtils.rm_f("#{File.dirname(__FILE__)}/foo.gemspec")
|
24
8
|
FileUtils.rm_f("#{File.dirname(__FILE__)}/bar.gemspec")
|
9
|
+
FileUtils.rm_f("#{File.dirname(__FILE__)}/VERSION.yml")
|
25
10
|
end
|
26
11
|
|
27
12
|
class << self
|
@@ -48,18 +33,11 @@ end
|
|
48
33
|
assert_equal version, @jeweler.version
|
49
34
|
end
|
50
35
|
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
36
|
end
|
58
37
|
|
59
38
|
context 'A jeweler (with a gemspec with top level module)' do
|
60
39
|
setup do
|
61
|
-
|
62
|
-
@spec = Gem::Specification.new do |s|
|
40
|
+
spec = Gem::Specification.new do |s|
|
63
41
|
s.name = 'foo'
|
64
42
|
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
65
43
|
s.email = "josh@technicalpickles.com"
|
@@ -68,11 +46,12 @@ end
|
|
68
46
|
s.authors = ["Josh Nichols", "Dan Croak"]
|
69
47
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
70
48
|
end
|
71
|
-
@jeweler = Jeweler.new(
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
49
|
+
@jeweler = Jeweler.new(spec, File.dirname(__FILE__))
|
50
|
+
|
51
|
+
catch_out do
|
52
|
+
@jeweler.write_version(0, 1, 0)
|
53
|
+
end
|
54
|
+
@jeweler = Jeweler.new(spec, File.dirname(__FILE__))
|
76
55
|
end
|
77
56
|
|
78
57
|
should_have_major_version 0
|
@@ -80,11 +59,9 @@ end
|
|
80
59
|
should_have_patch_version 0
|
81
60
|
should_be_version '0.1.0'
|
82
61
|
|
83
|
-
should_have_toplevel_keyword 'module'
|
84
|
-
|
85
62
|
context "bumping the patch version" do
|
86
63
|
setup do
|
87
|
-
@jeweler.bump_patch_version
|
64
|
+
@output = catch_out { @jeweler.bump_patch_version }
|
88
65
|
end
|
89
66
|
|
90
67
|
should_have_major_version 0
|
@@ -99,7 +76,7 @@ end
|
|
99
76
|
|
100
77
|
context "bumping the minor version" do
|
101
78
|
setup do
|
102
|
-
@jeweler.bump_minor_version
|
79
|
+
@output = catch_out { @jeweler.bump_minor_version }
|
103
80
|
end
|
104
81
|
|
105
82
|
should_have_major_version 0
|
@@ -114,7 +91,7 @@ end
|
|
114
91
|
|
115
92
|
context "bumping the major version" do
|
116
93
|
setup do
|
117
|
-
@jeweler.bump_major_version
|
94
|
+
@output = catch_out { @jeweler.bump_major_version }
|
118
95
|
end
|
119
96
|
|
120
97
|
should_have_major_version 1
|
@@ -131,9 +108,7 @@ end
|
|
131
108
|
|
132
109
|
context "A Jeweler (with a gemspec with top level class)" do
|
133
110
|
setup do
|
134
|
-
|
135
|
-
|
136
|
-
@spec = Gem::Specification.new do |s|
|
111
|
+
spec = Gem::Specification.new do |s|
|
137
112
|
s.name = "bar"
|
138
113
|
s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
|
139
114
|
s.email = "josh@technicalpickles.com"
|
@@ -142,31 +117,59 @@ end
|
|
142
117
|
s.authors = ["Josh Nichols", "Dan Croak"]
|
143
118
|
s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
|
144
119
|
end
|
145
|
-
@jeweler = Jeweler.new(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
120
|
+
@jeweler = Jeweler.new(spec, File.dirname(__FILE__))
|
121
|
+
|
122
|
+
@now = Time.now
|
123
|
+
Time.stubs(:now).returns(@now)
|
124
|
+
|
125
|
+
@output = catch_out { @jeweler.write_version(1, 5, 2) }
|
126
|
+
@jeweler = Jeweler.new(spec, File.dirname(__FILE__))
|
127
|
+
end
|
151
128
|
|
152
129
|
should_have_major_version 1
|
153
130
|
should_have_minor_version 5
|
154
131
|
should_have_patch_version 2
|
155
132
|
should_be_version '1.5.2'
|
156
|
-
should_have_toplevel_keyword 'class'
|
157
133
|
|
158
134
|
context "bumping the patch version" do
|
159
135
|
setup do
|
160
|
-
@jeweler.bump_patch_version
|
136
|
+
@output = catch_out { @jeweler.bump_patch_version }
|
161
137
|
end
|
162
138
|
|
163
139
|
should_have_major_version 1
|
164
140
|
should_have_minor_version 5
|
165
141
|
should_have_patch_version 3
|
166
142
|
should_be_version '1.5.3'
|
143
|
+
end
|
144
|
+
|
145
|
+
context "writing the gemspec" do
|
146
|
+
setup do
|
147
|
+
@output = catch_out { @jeweler.write_gemspec }
|
148
|
+
end
|
167
149
|
|
168
|
-
|
169
|
-
|
150
|
+
should "create bar.gemspec" do
|
151
|
+
assert File.exists?(File.join(File.dirname(__FILE__), 'bar.gemspec'))
|
152
|
+
end
|
153
|
+
|
154
|
+
should "have created a valid gemspec" do
|
155
|
+
assert @jeweler.valid_gemspec?
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
context "re-reading the gemspec" do
|
160
|
+
setup do
|
161
|
+
data = File.read(File.join(File.dirname(__FILE__), 'bar.gemspec'))
|
162
|
+
|
163
|
+
@parsed_spec = eval("$SAFE = 3\n#{data}", binding, File.join(File.dirname(__FILE__), 'bar.gemspec'))
|
164
|
+
end
|
165
|
+
|
166
|
+
should "have version 1.5.2" do
|
167
|
+
assert_equal '1.5.2', @parsed_spec.version.version
|
168
|
+
end
|
169
|
+
|
170
|
+
should "have date filled in" do
|
171
|
+
assert_equal Time.local(@now.year, @now.month, @now.day), @parsed_spec.date
|
172
|
+
end
|
170
173
|
end
|
171
174
|
end
|
172
175
|
end
|
data/test/test_helper.rb
CHANGED
@@ -5,6 +5,13 @@ gem 'thoughtbot-shoulda'
|
|
5
5
|
require 'shoulda'
|
6
6
|
gem 'ruby-debug'
|
7
7
|
require 'ruby-debug'
|
8
|
+
gem 'mocha'
|
9
|
+
require 'mocha'
|
10
|
+
|
11
|
+
gem 'mhennemeyer-output_catcher'
|
12
|
+
require 'output_catcher'
|
13
|
+
|
14
|
+
require 'time'
|
8
15
|
|
9
16
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
10
17
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
@@ -14,4 +21,13 @@ require 'jeweler'
|
|
14
21
|
class FileList
|
15
22
|
def self.[](*args)
|
16
23
|
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Test::Unit::TestCase
|
27
|
+
|
28
|
+
def catch_out(&block)
|
29
|
+
OutputCatcher.catch_out do
|
30
|
+
block.call
|
31
|
+
end
|
32
|
+
end
|
17
33
|
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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Nichols
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-10-
|
13
|
+
date: 2008-10-14 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- README.markdown
|
28
28
|
- TODO
|
29
|
+
- VERSION.yml
|
29
30
|
- lib/jeweler
|
30
31
|
- lib/jeweler/active_support.rb
|
31
32
|
- lib/jeweler/bumping.rb
|
@@ -33,7 +34,6 @@ files:
|
|
33
34
|
- lib/jeweler/gemspec.rb
|
34
35
|
- lib/jeweler/singleton.rb
|
35
36
|
- lib/jeweler/tasks.rb
|
36
|
-
- lib/jeweler/version.rb
|
37
37
|
- lib/jeweler/versioning.rb
|
38
38
|
- lib/jeweler.rb
|
39
39
|
- test/jeweler_test.rb
|