versionr 0.0.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/lib/versionr.rb +45 -0
- metadata +46 -0
data/lib/versionr.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
class Versionr
|
4
|
+
|
5
|
+
attr_reader :major
|
6
|
+
attr_reader :minor
|
7
|
+
attr_reader :patch
|
8
|
+
|
9
|
+
def initialize(version_dir = Dir.pwd)
|
10
|
+
@version_dir = "#{version_dir}VERSION"
|
11
|
+
version = YAML.load_file(@version_dir)
|
12
|
+
@major = version['version']['major']
|
13
|
+
@minor = version['version']['minor']
|
14
|
+
@patch = version['version']['patch']
|
15
|
+
rescue abort("Can't open %s" % version_dir)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write_version
|
19
|
+
data = {"version" => { "major" => @major, "minor" => @minor, "patch" => @patch } }
|
20
|
+
File.open(@version_dir, 'w+') { |f| f.write(data.to_yaml) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def bump_major
|
24
|
+
@major += 1
|
25
|
+
write_version
|
26
|
+
end
|
27
|
+
|
28
|
+
def bump_minor
|
29
|
+
@minor += 1
|
30
|
+
write_version
|
31
|
+
end
|
32
|
+
|
33
|
+
def bump_patch
|
34
|
+
@patch += 1
|
35
|
+
write_version
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
v = Versionr.new('../')
|
41
|
+
puts "#{v.major}.#{v.minor}.#{v.patch}"
|
42
|
+
v.bump_major
|
43
|
+
v.bump_minor
|
44
|
+
v.bump_patch
|
45
|
+
puts "#{v.major}.#{v.minor}.#{v.patch}"
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: versionr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- TJ Biddle
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Versionr is used to bump the version number of your application. This
|
15
|
+
will be used by another gem to manage gemspec files.
|
16
|
+
email: me@thomasbiddle.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/versionr.rb
|
22
|
+
homepage: http://github.com/thomasbiddle
|
23
|
+
licenses: []
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 1.8.11
|
43
|
+
signing_key:
|
44
|
+
specification_version: 3
|
45
|
+
summary: Versionr
|
46
|
+
test_files: []
|