namelessjon-jeweler 0.6.2 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
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: namelessjon-jeweler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.5
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-16 00:00:00 -08:00
12
+ date: 2009-01-14 00:00:00 -08:00
13
13
  default_executable: jeweler
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -30,17 +30,16 @@ extensions: []
30
30
  extra_rdoc_files: []
31
31
 
32
32
  files:
33
+ - ChangeLog.markdown
33
34
  - Rakefile
34
35
  - README.markdown
35
36
  - TODO
36
37
  - VERSION.yml
37
38
  - bin/jeweler
38
39
  - lib/jeweler
39
- - lib/jeweler/bumping.rb
40
40
  - lib/jeweler/errors.rb
41
41
  - lib/jeweler/gemspec.rb
42
42
  - lib/jeweler/generator.rb
43
- - lib/jeweler/release.rb
44
43
  - lib/jeweler/tasks.rb
45
44
  - lib/jeweler/templates
46
45
  - lib/jeweler/templates/bacon
@@ -52,11 +51,12 @@ files:
52
51
  - lib/jeweler/templates/shoulda
53
52
  - lib/jeweler/templates/shoulda/flunking_test.rb
54
53
  - lib/jeweler/templates/shoulda/test_helper.rb
55
- - lib/jeweler/versioning.rb
54
+ - lib/jeweler/version.rb
56
55
  - lib/jeweler.rb
57
56
  - test/fixtures
58
57
  - test/fixtures/bar
59
58
  - test/fixtures/bar/VERSION.yml
59
+ - test/gemspec_test.rb
60
60
  - test/generators
61
61
  - test/generators/initialization_test.rb
62
62
  - test/jeweler_generator_test.rb
@@ -65,12 +65,16 @@ files:
65
65
  - test/shoulda_macros/jeweler_macros.rb
66
66
  - test/tasks_test.rb
67
67
  - test/test_helper.rb
68
+ - test/version_test.rb
69
+ - test/version_tmp
70
+ - test/version_tmp/VERSION.yml
68
71
  - lib/jeweler/templates/.gitignore
69
- has_rdoc: false
72
+ has_rdoc: true
70
73
  homepage: http://github.com/technicalpickles/jeweler
71
74
  post_install_message:
72
- rdoc_options: []
73
-
75
+ rdoc_options:
76
+ - --inline-source
77
+ - --charset=UTF-8
74
78
  require_paths:
75
79
  - lib
76
80
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -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
@@ -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
@@ -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