gem_version 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/README.rdoc +5 -3
- data/Rakefile +1 -0
- data/lib/gem_version.rb +21 -3
- data/lib/tasks/gem_version.rake +18 -0
- metadata +4 -3
data/.gitignore
CHANGED
data/README.rdoc
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
=
|
1
|
+
= GemVersion
|
2
2
|
|
3
3
|
Automated version management for your Gem builds.
|
4
4
|
|
@@ -46,13 +46,15 @@ Everytime you build your gem (this example uses Gemcutter):
|
|
46
46
|
rake gemspec
|
47
47
|
gem build your_gem_name.gemspec
|
48
48
|
|
49
|
-
|
49
|
+
GemVersion provides the next version for each build.
|
50
50
|
|
51
|
+
See my Rakefile[http://github.com/jeffp/gem_version/blob/master/Rakefile] for an example.
|
51
52
|
|
52
53
|
== Bumping or resetting the next gem version
|
53
54
|
|
54
|
-
|
55
|
+
GemVersion creates a file named 'next_gem_version' in the root directory of your project which contains the 'next' gem version. Edit the version in this file to bump or reset the version for the next build.
|
55
56
|
|
57
|
+
GemVersion increments the last component of your version. If you need to bump from 0.1.x to 0.2.x, you'll need to make the change in the file.
|
56
58
|
|
57
59
|
== Dependencies
|
58
60
|
|
data/Rakefile
CHANGED
data/lib/gem_version.rb
CHANGED
@@ -14,26 +14,44 @@ module GemVersion
|
|
14
14
|
init_version_file unless File.exist?(@@gem_version_file)
|
15
15
|
file = File.new(@@gem_version_file, 'r')
|
16
16
|
version = file.gets.chomp
|
17
|
-
raise "#{@@gem_version_file} file corrupt" unless (version
|
17
|
+
raise "#{@@gem_version_file} file corrupt" unless self.version_format_valid?(version)
|
18
18
|
file.close
|
19
19
|
version
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.set_version(version)
|
23
|
+
raise "Invalid version format" unless self.version_format_valid?(version)
|
24
|
+
update_version(version)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.version_format_valid?(version)
|
28
|
+
(version && version =~ /^\d+\.\d+[\.\d+]+$/)
|
29
|
+
end
|
30
|
+
|
22
31
|
def self.init_version_file
|
23
32
|
file = File.new(@@gem_version_file, 'w')
|
24
33
|
file.puts '0.0.1'
|
25
34
|
file.close
|
26
35
|
end
|
27
36
|
|
37
|
+
def self.increment_and_push
|
38
|
+
self.increment_version
|
39
|
+
self.commit_and_push
|
40
|
+
end
|
41
|
+
|
28
42
|
def self.increment_version
|
29
43
|
version = self.next_version
|
30
44
|
components = version.split('.')
|
31
45
|
components.push((components.pop.to_i + 1).to_s)
|
32
46
|
new_version = components.join('.')
|
47
|
+
update_version(new_version)
|
48
|
+
version
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.update_version(new_version)
|
33
52
|
file = File.new(@@gem_version_file, 'w')
|
34
53
|
file.puts new_version
|
35
|
-
file.close
|
36
|
-
version
|
54
|
+
file.close
|
37
55
|
end
|
38
56
|
|
39
57
|
def self.commit_and_push(project_directory = nil, msg = nil)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
namespace :gem do
|
3
|
+
task :clean do
|
4
|
+
FileUtils.rm_f Dir.glob('*.gem*')
|
5
|
+
end
|
6
|
+
task :version do
|
7
|
+
if (ENV.include?("set"))
|
8
|
+
version = ENV['set'].gsub(/'/, '')
|
9
|
+
unless GemVersion.version_format_valid?(version)
|
10
|
+
raise "Version '#{version}' format invalid. Must only contain digits separated by decimal points."
|
11
|
+
end
|
12
|
+
GemVersion.set_version(version)
|
13
|
+
puts "Next version set at '#{version}'"
|
14
|
+
else
|
15
|
+
puts GemVersion.next_version
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jeff Patmon
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-30 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -40,6 +40,7 @@ extensions: []
|
|
40
40
|
extra_rdoc_files: []
|
41
41
|
|
42
42
|
files:
|
43
|
+
- lib/tasks/gem_version.rake
|
43
44
|
- lib/gem_version.rb
|
44
45
|
- spec/next_gem_version
|
45
46
|
- spec/spec.opts
|