bump 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +0 -0
- data/bin/bump +5 -0
- data/bump.gemspec +21 -0
- data/lib/bump.rb +79 -0
- metadata +70 -0
data/README.textile
ADDED
File without changes
|
data/bin/bump
ADDED
data/bump.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "bump"
|
3
|
+
s.version = "0.1.0"
|
4
|
+
s.author = "Gregory Marcilhacy"
|
5
|
+
s.email = "g.marcilhacy@gmail.com"
|
6
|
+
s.homepage = "http://github.com/gregorymp/bump"
|
7
|
+
s.summary = "Bump your gem version file"
|
8
|
+
|
9
|
+
s.files = %w(
|
10
|
+
README.textile
|
11
|
+
bump.gemspec
|
12
|
+
bin/bump
|
13
|
+
lib/bump.rb
|
14
|
+
)
|
15
|
+
|
16
|
+
s.require_path = "lib"
|
17
|
+
s.executables = ["bump"]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
data/lib/bump.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
module Bump
|
2
|
+
|
3
|
+
class Bump
|
4
|
+
|
5
|
+
BUMPS = %w(major minor tiny)
|
6
|
+
VERSION_REGEX = /version\s*=\s*["|'](\d.\d.\d)["|']/
|
7
|
+
|
8
|
+
class InvalidBumpError < StandardError; end
|
9
|
+
class UnfoundVersionError < StandardError; end
|
10
|
+
class TooManyGemspecsFoundError < StandardError; end
|
11
|
+
class UnfoundGemspecError < StandardError; end
|
12
|
+
|
13
|
+
def initialize(bump)
|
14
|
+
begin
|
15
|
+
bump = bump.is_a?(Array) ? bump.first : bump
|
16
|
+
raise InvalidBumpError unless BUMPS.include?(bump)
|
17
|
+
@bump = bump
|
18
|
+
|
19
|
+
rescue InvalidBumpError
|
20
|
+
display_message "Invalid bump. Choose between #{BUMPS.join(',')}."
|
21
|
+
rescue Exception
|
22
|
+
display_message "Something wrong happened"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
begin
|
28
|
+
gemspec = find_gemspec_file
|
29
|
+
current_version = find_current_version(gemspec)
|
30
|
+
next_version = find_next_version(current_version)
|
31
|
+
system(%(ruby -i -pe "gsub(/#{current_version}/, '#{next_version}')" #{gemspec}))
|
32
|
+
display_message "Bump version #{current_version} to #{next_version}"
|
33
|
+
|
34
|
+
rescue UnfoundVersionError
|
35
|
+
display_message "Unable to find your gem version"
|
36
|
+
rescue UnfoundGemspecError
|
37
|
+
display_message "Unable to find gemspec file"
|
38
|
+
rescue TooManyGemspecsFoundError
|
39
|
+
display_message "More than one gemspec file"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def find_current_version(file)
|
46
|
+
match = File.read(file).match VERSION_REGEX
|
47
|
+
if match.nil?
|
48
|
+
raise UnfoundVersionError
|
49
|
+
else
|
50
|
+
match[1]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def find_gemspec_file
|
55
|
+
gemspecs = Dir.glob("*.gemspec")
|
56
|
+
raise UnfoundGemspecError if gemspecs.size.zero?
|
57
|
+
raise TooManyGemspecsFoundError if gemspecs.size > 1
|
58
|
+
gemspecs.first
|
59
|
+
end
|
60
|
+
|
61
|
+
def find_next_version(current_version)
|
62
|
+
match = current_version.match /(\d).(\d).(\d)/
|
63
|
+
case @bump
|
64
|
+
when "major"
|
65
|
+
"#{match[1].to_i + 1}.0.0"
|
66
|
+
when "minor"
|
67
|
+
"#{match[1]}.#{match[2].to_i + 1}.0"
|
68
|
+
when "tiny"
|
69
|
+
"#{match[1]}.#{match[2]}.#{match[3].to_i + 1}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def display_message(message)
|
74
|
+
print(message); puts;
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bump
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gregory Marcilhacy
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-07-12 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email: g.marcilhacy@gmail.com
|
24
|
+
executables:
|
25
|
+
- bump
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- README.textile
|
32
|
+
- bump.gemspec
|
33
|
+
- bin/bump
|
34
|
+
- lib/bump.rb
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/gregorymp/bump
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 3
|
50
|
+
segments:
|
51
|
+
- 0
|
52
|
+
version: "0"
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.4.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Bump your gem version file
|
69
|
+
test_files: []
|
70
|
+
|