technicalpickles-jeweler 0.1.1 → 0.2.0

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/TODO CHANGED
@@ -1,7 +1,5 @@
1
- * Move away from having a version module to having version.yml in top level directory
2
1
  * Generator for making new Jeweler projects
3
2
  * Rails generator for making a plugin that's Jeweler enabled
4
3
  * Git tagging/branching
5
4
  * Make sure everything is pushed/committed before bumping (controlled by a Jeweler.strict perhaps)
6
- * Have version:bump:xxx do a commit with an appropriate message
7
- * Capture stdout during testing
5
+ * Have version:bump:xxx do a commit with an appropriate message
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- patch: 1
2
+ patch: 0
3
3
  major: 0
4
- minor: 1
4
+ minor: 2
data/lib/jeweler.rb CHANGED
@@ -24,13 +24,7 @@ class Jeweler
24
24
  @gemspec = gemspec
25
25
  @base_dir = base_dir
26
26
 
27
- # @gemspec.version = version
28
27
  @gemspec.files ||= FileList["[A-Z]*.*", "{generators,lib,test,spec}/**/*"]
29
28
  end
30
-
31
- private
32
- def main_module_name
33
- camelize(@gemspec.name)
34
- end
35
29
  end
36
30
 
@@ -14,9 +14,7 @@ class Jeweler
14
14
  # it. See http://gist.github.com/16215
15
15
  def validate_gemspec
16
16
  begin
17
- data = File.read(gemspec_path)
18
- Thread.new { spec = parse_gemspec(data) }.join
19
-
17
+ parse_gemspec
20
18
  puts "#{gemspec_path} is valid."
21
19
  rescue Exception => e
22
20
  puts "#{gemspec_path} is invalid. See the backtrace for more details."
@@ -26,11 +24,8 @@ class Jeweler
26
24
 
27
25
 
28
26
  def valid_gemspec?
29
- # gah, so wet...
30
27
  begin
31
- data = File.read(gemspec_path)
32
-
33
- Thread.new { spec = parse_gemspec(data) }.join
28
+ parse_gemspec
34
29
  true
35
30
  rescue Exception => e
36
31
  false
@@ -39,7 +34,7 @@ class Jeweler
39
34
 
40
35
  def parse_gemspec(data = nil)
41
36
  data ||= File.read(gemspec_path)
42
- eval("$SAFE = 3\n#{data}", binding, gemspec_path)
37
+ Thread.new { eval("$SAFE = 3\n#{data}", binding, gemspec_path) }.join
43
38
  end
44
39
 
45
40
  protected
data/lib/jeweler/tasks.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'ruby-debug'
2
1
  desc "Generate and validates gemspec"
3
2
  task :gemspec => ['gemspec:generate', 'gemspec:validate']
4
3
 
@@ -0,0 +1,4 @@
1
+ ---
2
+ major: 1
3
+ minor: 5
4
+ patch: 2
data/test/jeweler_test.rb CHANGED
@@ -2,11 +2,25 @@ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class JewelerTest < Test::Unit::TestCase
4
4
 
5
+ def setup
6
+ @now = Time.now
7
+ Time.stubs(:now).returns(@now)
8
+ end
9
+
5
10
  def teardown
6
- FileUtils.rm_rf("#{File.dirname(__FILE__)}/lib")
7
- FileUtils.rm_f("#{File.dirname(__FILE__)}/foo.gemspec")
8
- FileUtils.rm_f("#{File.dirname(__FILE__)}/bar.gemspec")
9
- FileUtils.rm_f("#{File.dirname(__FILE__)}/VERSION.yml")
11
+ FileUtils.rm_rf("#{File.dirname(__FILE__)}/tmp")
12
+ end
13
+
14
+ def build_spec
15
+ Gem::Specification.new do |s|
16
+ s.name = "bar"
17
+ s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
18
+ s.email = "josh@technicalpickles.com"
19
+ s.homepage = "http://github.com/technicalpickles/jeweler"
20
+ s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
21
+ s.authors = ["Josh Nichols", "Dan Croak"]
22
+ s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
23
+ end
10
24
  end
11
25
 
12
26
  class << self
@@ -33,113 +47,64 @@ class JewelerTest < Test::Unit::TestCase
33
47
  assert_equal version, @jeweler.version
34
48
  end
35
49
  end
50
+
51
+ def should_bump_version(major, minor, patch)
52
+ version = "#{major}.#{minor}.#{patch}"
53
+ should_have_major_version major
54
+ should_have_minor_version minor
55
+ should_have_patch_version patch
56
+ should_be_version version
57
+ should "output the new version, #{version}" do
58
+ assert_match version, @output
59
+ end
60
+ end
36
61
  end
37
62
 
38
- context 'A jeweler (with a gemspec with top level module)' do
63
+ context "A jeweler without a VERSION.yml" do
39
64
  setup do
40
- spec = Gem::Specification.new do |s|
41
- s.name = 'foo'
42
- s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
43
- s.email = "josh@technicalpickles.com"
44
- s.homepage = "http://github.com/technicalpickles/jeweler"
45
- s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
46
- s.authors = ["Josh Nichols", "Dan Croak"]
47
- s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
48
- end
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__))
65
+ FileUtils.mkdir_p(tmp_dir)
66
+ @jeweler = Jeweler.new(build_spec, tmp_dir)
55
67
  end
56
68
 
57
- should_have_major_version 0
58
- should_have_minor_version 1
59
- should_have_patch_version 0
60
- should_be_version '0.1.0'
69
+ should "not have VERSION.yml" do
70
+ assert ! File.exists?(File.join(tmp_dir, 'bar.gemspec'))
71
+ end
72
+ end
73
+
74
+
75
+ context "A Jeweler with a VERSION.yml" do
76
+ setup do
77
+ FileUtils.cp_r(fixture_dir, tmp_dir)
78
+
79
+ @jeweler = Jeweler.new(build_spec, tmp_dir)
80
+ end
81
+
82
+ should_have_major_version 1
83
+ should_have_minor_version 5
84
+ should_have_patch_version 2
85
+ should_be_version '1.5.2'
61
86
 
62
87
  context "bumping the patch version" do
63
88
  setup do
64
89
  @output = catch_out { @jeweler.bump_patch_version }
65
90
  end
66
-
67
- should_have_major_version 0
68
- should_have_minor_version 1
69
- should_have_patch_version 1
70
- should_be_version '0.1.1'
71
-
72
- should "still have module Foo" do
73
- # do some regexp of version.rb
74
- end
91
+ should_bump_version 1, 5, 3
75
92
  end
76
93
 
77
94
  context "bumping the minor version" do
78
95
  setup do
79
96
  @output = catch_out { @jeweler.bump_minor_version }
80
97
  end
81
-
82
- should_have_major_version 0
83
- should_have_minor_version 2
84
- should_have_patch_version 0
85
- should_be_version '0.2.0'
86
-
87
- should "still have module Foo" do
88
- # do some regexp of version.rb
89
- end
98
+
99
+ should_bump_version 1, 6, 0
90
100
  end
91
101
 
92
102
  context "bumping the major version" do
93
103
  setup do
94
- @output = catch_out { @jeweler.bump_major_version }
95
- end
96
-
97
- should_have_major_version 1
98
- should_have_minor_version 0
99
- should_have_patch_version 0
100
- should_be_version '1.0.0'
101
-
102
- should "still have module Foo" do
103
- # do some regexp of version.rb
104
- end
105
- end
106
-
107
- end
108
-
109
- context "A Jeweler (with a gemspec with top level class)" do
110
- setup do
111
- spec = Gem::Specification.new do |s|
112
- s.name = "bar"
113
- s.summary = "Simple and opinionated helper for creating Rubygem projects on GitHub"
114
- s.email = "josh@technicalpickles.com"
115
- s.homepage = "http://github.com/technicalpickles/jeweler"
116
- s.description = "Simple and opinionated helper for creating Rubygem projects on GitHub"
117
- s.authors = ["Josh Nichols", "Dan Croak"]
118
- s.files = FileList["[A-Z]*", "{generators,lib,test}/**/*"]
104
+ @output = catch_out { @jeweler.bump_major_version}
119
105
  end
120
- @jeweler = Jeweler.new(spec, File.dirname(__FILE__))
121
-
122
- @now = Time.now
123
- Time.stubs(:now).returns(@now)
124
106
 
125
- @output = catch_out { @jeweler.write_version(1, 5, 2) }
126
- @jeweler = Jeweler.new(spec, File.dirname(__FILE__))
127
- end
128
-
129
- should_have_major_version 1
130
- should_have_minor_version 5
131
- should_have_patch_version 2
132
- should_be_version '1.5.2'
133
-
134
- context "bumping the patch version" do
135
- setup do
136
- @output = catch_out { @jeweler.bump_patch_version }
137
- end
138
-
139
- should_have_major_version 1
140
- should_have_minor_version 5
141
- should_have_patch_version 3
142
- should_be_version '1.5.3'
107
+ should_bump_version 2, 0, 0
143
108
  end
144
109
 
145
110
  context "writing the gemspec" do
@@ -148,19 +113,24 @@ class JewelerTest < Test::Unit::TestCase
148
113
  end
149
114
 
150
115
  should "create bar.gemspec" do
151
- assert File.exists?(File.join(File.dirname(__FILE__), 'bar.gemspec'))
116
+ assert File.exists?(File.join(tmp_dir, 'bar.gemspec'))
152
117
  end
153
118
 
154
119
  should "have created a valid gemspec" do
155
120
  assert @jeweler.valid_gemspec?
156
121
  end
122
+
123
+ should "output the name of the gemspec" do
124
+ assert_match 'bar.gemspec', @output
125
+ end
157
126
 
158
127
 
159
128
  context "re-reading the gemspec" do
160
129
  setup do
161
- data = File.read(File.join(File.dirname(__FILE__), 'bar.gemspec'))
130
+ gemspec_path = File.join(tmp_dir, 'bar.gemspec')
131
+ data = File.read(gemspec_path)
162
132
 
163
- @parsed_spec = eval("$SAFE = 3\n#{data}", binding, File.join(File.dirname(__FILE__), 'bar.gemspec'))
133
+ @parsed_spec = eval("$SAFE = 3\n#{data}", binding, gemspec_path)
164
134
  end
165
135
 
166
136
  should "have version 1.5.2" do
@@ -176,7 +146,7 @@ class JewelerTest < Test::Unit::TestCase
176
146
 
177
147
  should "raise an exception when created with a nil gemspec" do
178
148
  assert_raises Jeweler::GemspecError do
179
- @jeweler = Jeweler.new(nil, File.dirname(__FILE__))
149
+ @jeweler = Jeweler.new(nil, tmp_dir)
180
150
  end
181
151
  end
182
152
 
data/test/test_helper.rb CHANGED
@@ -8,7 +8,12 @@ require 'ruby-debug'
8
8
  gem 'mocha'
9
9
  require 'mocha'
10
10
 
11
- gem 'mhennemeyer-output_catcher'
11
+ # Use vendored gem because of limited gem availability on runcoderun
12
+ # This is loosely based on 'vendor everything'.
13
+ Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', '**')].each do |dir|
14
+ lib = "#{dir}/lib"
15
+ $LOAD_PATH.unshift(lib) if File.directory?(lib)
16
+ end
12
17
  require 'output_catcher'
13
18
 
14
19
  require 'time'
@@ -30,4 +35,12 @@ class Test::Unit::TestCase
30
35
  block.call
31
36
  end
32
37
  end
38
+
39
+ def fixture_dir
40
+ File.join(File.dirname(__FILE__), 'fixtures', 'bar')
41
+ end
42
+
43
+ def tmp_dir
44
+ File.join(File.dirname(__FILE__), 'tmp')
45
+ end
33
46
  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.1.1
4
+ version: 0.2.0
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-14 00:00:00 -07:00
13
+ date: 2008-10-21 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -36,6 +36,9 @@ files:
36
36
  - lib/jeweler/tasks.rb
37
37
  - lib/jeweler/versioning.rb
38
38
  - lib/jeweler.rb
39
+ - test/fixtures
40
+ - test/fixtures/bar
41
+ - test/fixtures/bar/VERSION.yml
39
42
  - test/jeweler_test.rb
40
43
  - test/test_helper.rb
41
44
  has_rdoc: false