version_bumper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.md +44 -0
- data/lib/bumper/version.rb +48 -0
- data/lib/version_bumper.rb +50 -0
- data/test/helper.rb +19 -0
- data/test/test_version_bumper.rb +43 -0
- metadata +133 -0
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 jondot
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
version_bumper
|
2
|
+
==============
|
3
|
+
|
4
|
+
Simple. Bump your versions.
|
5
|
+
|
6
|
+
$ gem install version_bumper
|
7
|
+
|
8
|
+
In your Rakefile `require 'version_bumper'` and you're done.
|
9
|
+
|
10
|
+
$ rake -T
|
11
|
+
rake bump:build # bump build
|
12
|
+
rake bump:init # write a blank version to VERSION
|
13
|
+
rake bump:major # bump major
|
14
|
+
rake bump:minor # bump minor
|
15
|
+
rake bump:revision # bump revision
|
16
|
+
|
17
|
+
|
18
|
+
$ rake bump:init
|
19
|
+
version: 0.0.0.0
|
20
|
+
$ rake bump:revision
|
21
|
+
version: 0.0.1.0
|
22
|
+
$ rake bump:major
|
23
|
+
version: 1.0.0.0
|
24
|
+
|
25
|
+
You can optionally use `bumper_file 'version.txt'` in your rake file to switch from the default `VERSION` file name.
|
26
|
+
Use `bumper_version` anywhere you need access to the current version in your rake script.
|
27
|
+
|
28
|
+
Contributing to version_bumper
|
29
|
+
------------------------------
|
30
|
+
|
31
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
32
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
33
|
+
* Fork the project
|
34
|
+
* Start a feature/bugfix branch
|
35
|
+
* Commit and push until you are happy with your contribution
|
36
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
37
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
38
|
+
|
39
|
+
Copyright
|
40
|
+
---------
|
41
|
+
|
42
|
+
Copyright (c) 2011 Dotan Nahum. See LICENSE.txt for
|
43
|
+
further details.
|
44
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Bumper
|
2
|
+
class Version
|
3
|
+
|
4
|
+
['major', 'minor', 'revision', 'build'].each do |part|
|
5
|
+
define_method part do
|
6
|
+
@v[part]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(v)
|
11
|
+
@v= {}
|
12
|
+
if v =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
|
13
|
+
@v['major'] = $1.to_i
|
14
|
+
@v['minor'] = $2.to_i
|
15
|
+
@v['revision'] = $3.to_i
|
16
|
+
@v['build'] = $4
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def bump(part)
|
21
|
+
@v[part] = @v[part].succ
|
22
|
+
|
23
|
+
return @v[part] if part == 'build'
|
24
|
+
@v['build'] = '0'
|
25
|
+
return @v[part] if part == 'revision'
|
26
|
+
@v['revision'] = 0
|
27
|
+
return @v[part] if part == 'minor'
|
28
|
+
@v['minor'] = 0
|
29
|
+
@v[part]
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_missing(m, *args, &block)
|
33
|
+
if(m.to_s =~ /^bump_(.*)$/)
|
34
|
+
if @v.has_key? $1
|
35
|
+
return send(:bump, $1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
super
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
"#{major}.#{minor}.#{revision}" + (build.nil? ? "" : ".#{build}")
|
43
|
+
end
|
44
|
+
def write(f)
|
45
|
+
File.open(f,'w'){ |h| h.write(self.to_s) }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'bumper/version'
|
3
|
+
|
4
|
+
@vfile = 'VERSION'
|
5
|
+
|
6
|
+
def bumper_file(file)
|
7
|
+
@vfile = file
|
8
|
+
end
|
9
|
+
|
10
|
+
def bumper_version
|
11
|
+
@version ||= Bumper::Version.new(File.read(@vfile))
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
namespace :bump do
|
16
|
+
desc "create a blank version file"
|
17
|
+
task :init do
|
18
|
+
@version = Bumper::Version.new('0.0.0.0')
|
19
|
+
@version.write(@vfile)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "bump major"
|
23
|
+
task :major do
|
24
|
+
bumper_version.bump_major
|
25
|
+
persist!
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "bump minor"
|
29
|
+
task :minor do
|
30
|
+
bumper_version.bump_minor
|
31
|
+
persist!
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "bump revision"
|
35
|
+
task :revision do
|
36
|
+
bumper_version.bump_revision
|
37
|
+
persist!
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "bump build"
|
41
|
+
task :build do
|
42
|
+
bumper_version.bump_build
|
43
|
+
persist!
|
44
|
+
end
|
45
|
+
|
46
|
+
def persist!
|
47
|
+
bumper_version.write(@vfile)
|
48
|
+
puts "version: #{bumper_version}"
|
49
|
+
end
|
50
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'minitest/unit'
|
11
|
+
|
12
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
require 'version_bumper'
|
15
|
+
|
16
|
+
class MiniTest::Unit::TestCase
|
17
|
+
end
|
18
|
+
|
19
|
+
MiniTest::Unit.autorun
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestVersionBumper < MiniTest::Unit::TestCase
|
4
|
+
def test_that_it_should_represent_correctly_test
|
5
|
+
v = Bumper::Version.new('0.0.0.0')
|
6
|
+
assert_equal '0.0.0.0', v.to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_it_should_have_correct_properties_test
|
10
|
+
v = Bumper::Version.new('0.0.0.0')
|
11
|
+
assert_equal 0, v.major
|
12
|
+
assert_equal 0, v.minor
|
13
|
+
assert_equal 0, v.revision
|
14
|
+
assert_equal '0', v.build
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_that_it_should_bump_versions
|
18
|
+
v = Bumper::Version.new('0.0.0.0')
|
19
|
+
assert_equal '1', v.bump_build
|
20
|
+
assert_equal 1, v.bump_revision
|
21
|
+
assert_equal 1, v.bump_minor
|
22
|
+
assert_equal 1, v.bump_major
|
23
|
+
assert_equal '1.0.0.0', v.to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_that_it_should_bump_versions_alt
|
27
|
+
v = Bumper::Version.new('0.0.0.0')
|
28
|
+
assert_equal 1, v.bump_major
|
29
|
+
assert_equal 1, v.bump_minor
|
30
|
+
assert_equal 1, v.bump_revision
|
31
|
+
assert_equal '1', v.bump_build
|
32
|
+
assert_equal '1.1.1.1', v.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_that_when_bumping_reset_smaller_versions
|
36
|
+
v = Bumper::Version.new('1.1.1.1')
|
37
|
+
assert_equal 2, v.bump_major
|
38
|
+
assert_equal 0, v.minor
|
39
|
+
assert_equal 0, v.revision
|
40
|
+
assert_equal '0', v.build
|
41
|
+
assert_equal '2.0.0.0', v.to_s
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: version_bumper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Dotan Nahum
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-05 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
name: minitest
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
- 0
|
48
|
+
version: 1.0.0
|
49
|
+
name: bundler
|
50
|
+
requirement: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
type: :development
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 7
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 5
|
63
|
+
- 2
|
64
|
+
version: 1.5.2
|
65
|
+
name: jeweler
|
66
|
+
requirement: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
name: rcov
|
80
|
+
requirement: *id004
|
81
|
+
description: Simply bump your versions
|
82
|
+
email: jondotan@gmail.com
|
83
|
+
executables: []
|
84
|
+
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files:
|
88
|
+
- LICENSE.txt
|
89
|
+
- README.md
|
90
|
+
files:
|
91
|
+
- lib/bumper/version.rb
|
92
|
+
- lib/version_bumper.rb
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- test/helper.rb
|
96
|
+
- test/test_version_bumper.rb
|
97
|
+
has_rdoc: true
|
98
|
+
homepage: http://github.com/jondot/version_bumper
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
hash: 3
|
121
|
+
segments:
|
122
|
+
- 0
|
123
|
+
version: "0"
|
124
|
+
requirements: []
|
125
|
+
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.3.7
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Rake task to bump your versions
|
131
|
+
test_files:
|
132
|
+
- test/helper.rb
|
133
|
+
- test/test_version_bumper.rb
|