versionifier 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,23 +1,23 @@
1
- = Versionifier
2
-
3
- A silly Ruby gem for modifying the version number of a project from the shell.
4
-
5
- == Installation
6
-
7
- gem install versionifier
8
-
9
- == Sample Usage
10
-
11
- /home/your_project$ v+ 0.1.0
12
- In your_project (0.0.3)
13
- - Version number updated to (0.1.3)
14
-
15
- <tt>Versionifier</tt> assumes that the project name is the same as the folder you are working on, and that you're using the gem folder setup shipped default by the Bundler gem generator.
16
-
17
- Which is the same as saying that assumes that your version file will be located in:
18
-
19
- /your_project/lib/your_project/version.rb
20
-
21
- Copyright 2011 Xavier Via
22
-
1
+ = Versionifier
2
+
3
+ A silly Ruby gem for modifying the version number of a project from the shell.
4
+
5
+ == Installation
6
+
7
+ gem install versionifier
8
+
9
+ == Sample Usage
10
+
11
+ /home/your_project$ v+ 0.1.0
12
+ In your_project (0.0.3)
13
+ - Version number updated to (0.1.3)
14
+
15
+ <tt>Versionifier</tt> assumes that the project name is the same as the folder you are working on, and that you're using the gem folder setup shipped default by the Bundler gem generator.
16
+
17
+ Which is the same as saying that assumes that your version file will be located in:
18
+
19
+ /your_project/lib/your_project/version.rb
20
+
21
+ Copyright 2011 Xavier Via
22
+
23
23
  GPL License
data/bin/v+ CHANGED
@@ -1,83 +1,83 @@
1
- #!/usr/bin/env ruby
2
- require "versionifier"
3
-
4
- # Get the project name and the version file path
5
- the_project = {
6
- :name => Dir.pwd.split("/").last }
7
- the_version_file = {
8
- :path => Dir.pwd + "/lib/" + the_project[:name] + "/version.rb" }
9
-
10
- # Exit if version file not found
11
- raise ArgumentError, "Version file not found on #{the_version_file[:path]}" unless File.exists? the_version_file[:path]
12
-
13
- # Read the current version from the version file
14
- the_version_file[:content] = File.read the_version_file[:path]
15
- the_matches = the_version_file[:content].match /VERSION\s+=\s+"(\d+?\.\d+?\.\d+?)"/
16
-
17
- # Create a version from the data
18
- current_version = Versionifier::Version.new the_matches[1]
19
-
20
- instructions = <<-INST
21
-
22
- Working on #{the_project[:name]} (#{current_version})"
23
-
24
- Usage:
25
- v+ 1 # 0.0.4 -> 0.0.5
26
- v+ 1.x # 0.0.4 -> 0.1.4
27
- v+ 1.x.x # 0.0.4 -> 1.0.4
28
-
29
- '!' at the end of the argument resets minor version numbers:
30
- v+ 1.x! # 0.0.4 -> 0.1.0
31
- v+ 2.x.x! # 0.0.4 -> 2.0.0
32
- INST
33
-
34
- # Depending on the arguments...
35
- unless ARGV.empty?
36
- the_argument = ARGV.shift
37
-
38
- # Check if argument is reset
39
- if the_argument.end_with? "!"
40
- the_argument = the_argument[0..the_argument.length-2]
41
- options = :reset
42
- else
43
- options = nil
44
- end
45
-
46
- incrementation = 0
47
- which = nil
48
- # Check if argument is properly formed
49
- if matches = the_argument.match(/^(\d+)\.x\.x$|^(\d+)\.x$|^(\d+)$/)
50
- if matches[1]
51
- incrementation = matches[1].to_i
52
- which = :major
53
- elsif matches[2]
54
- incrementation = matches[2].to_i
55
- which = :regular
56
- elsif matches[3]
57
- incrementation = matches[3].to_i
58
- which = :minor
59
- end
60
- else
61
- puts "Malformed argument. Please follow usage instructions:"
62
- puts instructions
63
- Process.exit!
64
- end
65
-
66
- # Get the final file
67
- the_final_version = current_version.increment which, incrementation, options
68
- the_final_file = the_version_file[:content].gsub(/VERSION\s+=\s+"\d+?\.\d+?\.\d+?"/, "VERSION = \"#{the_final_version}\"")
69
-
70
- # Save the file
71
- File.open the_version_file[:path], "w" do |file|
72
- file.write the_final_file
73
- end
74
-
75
- puts "In #{the_project[:name]} (#{current_version}) "
76
- puts " - Version number updated to (#{the_final_version})"
77
-
78
- else
79
-
80
- # Print instructions
81
- puts instructions
82
-
83
- end
1
+ #!/usr/bin/env ruby
2
+ require "versionifier"
3
+
4
+ # Get the project name and the version file path
5
+ the_project = {
6
+ :name => Dir.pwd.split("/").last }
7
+ the_version_file = {
8
+ :path => Dir.pwd + "/lib/" + the_project[:name] + "/version.rb" }
9
+
10
+ # Exit if version file not found
11
+ raise ArgumentError, "Version file not found on #{the_version_file[:path]}" unless File.exists? the_version_file[:path]
12
+
13
+ # Read the current version from the version file
14
+ the_version_file[:content] = File.read the_version_file[:path]
15
+ the_matches = the_version_file[:content].match /VERSION\s+=\s+["'](\d+?\.\d+?\.\d+?)["']/
16
+
17
+ # Create a version from the data
18
+ current_version = Versionifier::Version.new the_matches[1]
19
+
20
+ instructions = <<-INST
21
+
22
+ Working on #{the_project[:name]} (#{current_version})
23
+
24
+ Usage:
25
+ v+ 1 # 0.0.4 -> 0.0.5
26
+ v+ 1.x # 0.0.4 -> 0.1.4
27
+ v+ 1.x.x # 0.0.4 -> 1.0.4
28
+
29
+ '!' at the end of the argument resets minor version numbers:
30
+ v+ 1.x! # 0.0.4 -> 0.1.0
31
+ v+ 2.x.x! # 0.0.4 -> 2.0.0
32
+ INST
33
+
34
+ # Depending on the arguments...
35
+ unless ARGV.empty?
36
+ the_argument = ARGV.shift
37
+
38
+ # Check if argument is reset
39
+ if the_argument.end_with? "!"
40
+ the_argument = the_argument[0..the_argument.length-2]
41
+ options = :reset
42
+ else
43
+ options = nil
44
+ end
45
+
46
+ incrementation = 0
47
+ which = nil
48
+ # Check if argument is properly formed
49
+ if matches = the_argument.match(/^(\d+)\.x\.x$|^(\d+)\.x$|^(\d+)$/)
50
+ if matches[1]
51
+ incrementation = matches[1].to_i
52
+ which = :major
53
+ elsif matches[2]
54
+ incrementation = matches[2].to_i
55
+ which = :regular
56
+ elsif matches[3]
57
+ incrementation = matches[3].to_i
58
+ which = :minor
59
+ end
60
+ else
61
+ puts "Malformed argument. Please follow usage instructions:"
62
+ puts instructions
63
+ Process.exit!
64
+ end
65
+
66
+ # Get the final file
67
+ the_final_version = current_version.increment which, incrementation, options
68
+ the_final_file = the_version_file[:content].gsub(/VERSION\s+=\s+["']\d+?\.\d+?\.\d+?["']/, "VERSION = \"#{the_final_version}\"")
69
+
70
+ # Save the file
71
+ File.open the_version_file[:path], "w" do |file|
72
+ file.write the_final_file
73
+ end
74
+
75
+ puts "In #{the_project[:name]} (#{current_version}) "
76
+ puts " - Version number updated to (#{the_final_version})"
77
+
78
+ else
79
+
80
+ # Print instructions
81
+ puts instructions
82
+
83
+ end
data/bin/v+.bck CHANGED
@@ -1,66 +1,66 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Get the project name and the version file path
4
- the_project = {
5
- :name => Dir.pwd.split("/").last }
6
- the_version_file = {
7
- :path => Dir.pwd + "/lib/" + the_project[:name] + "/version.rb" }
8
-
9
- # Exit if version file not found
10
- raise ArgumentError, "Version file not found on #{the_version_file[:path]}" unless File.exists? the_version_file[:path]
11
-
12
- # Read the version file
13
- the_version_file[:content] = File.read the_version_file[:path]
14
-
15
- the_matches = the_version_file[:content].match /VERSION\s+=\s+"(\d+?)\.(\d+?)\.(\d+?)"/
16
-
17
- the_version = {
18
- :major => the_matches[1].to_i,
19
- :regular => the_matches[2].to_i,
20
- :minor => the_matches[3].to_i
21
- }
22
-
23
- if ARGV.empty?
24
- puts ""
25
- puts "Working on #{the_project[:name]} (#{the_version[:major]}.#{the_version[:regular]}.#{the_version[:minor]})"
26
- puts ""
27
- puts "Usage: "
28
- puts " v+ 1 # 0.0.4 -> 0.0.5"
29
- puts " v+ 1.0 # 0.0.4 -> 0.1.4"
30
- puts " v+ 1.0.0 # 0.0.4 -> 1.0.4"
31
- puts ""
32
- puts "Any combination is valid. For example:"
33
- puts " v+ 1.0.2 # 0.0.4 -> 1.0.6"
34
-
35
- else
36
-
37
- the_argument = { :raw => ARGV.shift }
38
- the_new_version = the_version.clone
39
-
40
- if the_match = the_argument[:raw].match(/^\d+$/)
41
- the_argument.merge! :major => 0, :regular => 0, :minor => the_match[0].to_i
42
- elsif the_match = the_argument[:raw].match(/^(\d+?)\.(\d+)$/)
43
- the_argument.merge! :major => 0, :regular => the_match[1].to_i, :minor => the_match[2].to_i
44
- elsif the_match = the_argument[:raw].match(/^(\d+?)\.(\d+?)\.(\d+)$/)
45
- the_argument.merge! :major => the_match[1].to_i,
46
- :regular => the_match[2].to_i,
47
- :minor => the_match[3].to_i
48
- else
49
- raise ArgumentError, "The argument must follow the format <number>[.<number>[.<number>]]"
50
- end
51
-
52
- the_new_version[:major] += the_argument[:major]
53
- the_new_version[:regular] += the_argument[:regular]
54
- the_new_version[:minor] += the_argument[:minor]
55
-
56
- the_final_file = the_version_file[:content].gsub(/VERSION\s+=\s+"\d+?\.\d+?\.\d+?"/, "VERSION = \"#{the_new_version[:major]}.#{the_new_version[:regular]}.#{the_new_version[:minor]}\"")
57
-
58
- # Save the file
59
- File.open the_version_file[:path], "w" do |file|
60
- file.write the_final_file
61
- end
62
-
63
- puts "In #{the_project[:name]} (#{the_version[:major]}.#{the_version[:regular]}.#{the_version[:minor]}) "
64
- puts " - Version number updated to (#{the_new_version[:major]}.#{the_new_version[:regular]}.#{the_new_version[:minor]})"
65
-
1
+ #!/usr/bin/env ruby
2
+
3
+ # Get the project name and the version file path
4
+ the_project = {
5
+ :name => Dir.pwd.split("/").last }
6
+ the_version_file = {
7
+ :path => Dir.pwd + "/lib/" + the_project[:name] + "/version.rb" }
8
+
9
+ # Exit if version file not found
10
+ raise ArgumentError, "Version file not found on #{the_version_file[:path]}" unless File.exists? the_version_file[:path]
11
+
12
+ # Read the version file
13
+ the_version_file[:content] = File.read the_version_file[:path]
14
+
15
+ the_matches = the_version_file[:content].match /VERSION\s+=\s+"(\d+?)\.(\d+?)\.(\d+?)"/
16
+
17
+ the_version = {
18
+ :major => the_matches[1].to_i,
19
+ :regular => the_matches[2].to_i,
20
+ :minor => the_matches[3].to_i
21
+ }
22
+
23
+ if ARGV.empty?
24
+ puts ""
25
+ puts "Working on #{the_project[:name]} (#{the_version[:major]}.#{the_version[:regular]}.#{the_version[:minor]})"
26
+ puts ""
27
+ puts "Usage: "
28
+ puts " v+ 1 # 0.0.4 -> 0.0.5"
29
+ puts " v+ 1.0 # 0.0.4 -> 0.1.4"
30
+ puts " v+ 1.0.0 # 0.0.4 -> 1.0.4"
31
+ puts ""
32
+ puts "Any combination is valid. For example:"
33
+ puts " v+ 1.0.2 # 0.0.4 -> 1.0.6"
34
+
35
+ else
36
+
37
+ the_argument = { :raw => ARGV.shift }
38
+ the_new_version = the_version.clone
39
+
40
+ if the_match = the_argument[:raw].match(/^\d+$/)
41
+ the_argument.merge! :major => 0, :regular => 0, :minor => the_match[0].to_i
42
+ elsif the_match = the_argument[:raw].match(/^(\d+?)\.(\d+)$/)
43
+ the_argument.merge! :major => 0, :regular => the_match[1].to_i, :minor => the_match[2].to_i
44
+ elsif the_match = the_argument[:raw].match(/^(\d+?)\.(\d+?)\.(\d+)$/)
45
+ the_argument.merge! :major => the_match[1].to_i,
46
+ :regular => the_match[2].to_i,
47
+ :minor => the_match[3].to_i
48
+ else
49
+ raise ArgumentError, "The argument must follow the format <number>[.<number>[.<number>]]"
50
+ end
51
+
52
+ the_new_version[:major] += the_argument[:major]
53
+ the_new_version[:regular] += the_argument[:regular]
54
+ the_new_version[:minor] += the_argument[:minor]
55
+
56
+ the_final_file = the_version_file[:content].gsub(/VERSION\s+=\s+"\d+?\.\d+?\.\d+?"/, "VERSION = \"#{the_new_version[:major]}.#{the_new_version[:regular]}.#{the_new_version[:minor]}\"")
57
+
58
+ # Save the file
59
+ File.open the_version_file[:path], "w" do |file|
60
+ file.write the_final_file
61
+ end
62
+
63
+ puts "In #{the_project[:name]} (#{the_version[:major]}.#{the_version[:regular]}.#{the_version[:minor]}) "
64
+ puts " - Version number updated to (#{the_new_version[:major]}.#{the_new_version[:regular]}.#{the_new_version[:minor]})"
65
+
66
66
  end
@@ -1,15 +1,15 @@
1
- Given /the version number (.+?)$/ do |full_version|
2
- @original_version = Versionifier::Version.new full_version
3
- end
4
-
5
- When /I increment (.+?) by (\d+?)$/ do |which, quant|
6
- @final_version = @original_version.increment which.to_sym, quant.to_i
7
- end
8
-
9
- When /I increment (.+?) by (\d+?) and reset everything under/ do |which, quant|
10
- @final_version = @original_version.increment which.to_sym, quant.to_i, :reset
11
- end
12
-
13
- Then /I should get (.+?)$/ do |final_version|
14
- @final_version.should == final_version
1
+ Given /the version number (.+?)$/ do |full_version|
2
+ @original_version = Versionifier::Version.new full_version
3
+ end
4
+
5
+ When /I increment (.+?) by (\d+?)$/ do |which, quant|
6
+ @final_version = @original_version.increment which.to_sym, quant.to_i
7
+ end
8
+
9
+ When /I increment (.+?) by (\d+?) and reset everything under/ do |which, quant|
10
+ @final_version = @original_version.increment which.to_sym, quant.to_i, :reset
11
+ end
12
+
13
+ Then /I should get (.+?)$/ do |final_version|
14
+ @final_version.should == final_version
15
15
  end
@@ -1,2 +1,2 @@
1
- $LOAD_PATH << File.expand_path("../../../lib", __FILE__)
1
+ $LOAD_PATH << File.expand_path("../../../lib", __FILE__)
2
2
  require "versionifier"
@@ -1,27 +1,27 @@
1
- Feature: Easily update version number
2
- In order to manage version numbers from shell
3
- As a lazy gem developer
4
- I want to have convenience methods to update version numbers
5
-
6
- Scenario Outline: Incrementing numbers
7
- Given the version number <input>
8
- When I increment <which> by <quant>
9
- Then I should get <out>
10
-
11
- Scenarios: Regular incrementations
12
- | input | which | quant | out |
13
- | 0.0.4 | major | 1 | 1.0.4 |
14
- | 0.2.5 | regular | 4 | 0.6.5 |
15
- | 1.5.3 | minor | 3 | 1.5.6 |
16
-
17
- Scenario Outline: Reseting minor and regular
18
- Given the version number <input>
19
- When I increment <which> by <quant> and reset everything under
20
- Then I should get <out>
21
-
22
- Scenarios: Incrementations with reset
23
- | input | which | quant | out |
24
- | 0.0.5 | regular | 1 | 0.1.0 |
25
- | 0.3.9 | major | 2 | 2.0.0 |
26
- | 4.5.2 | regular | 5 | 4.10.0 |
1
+ Feature: Easily update version number
2
+ In order to manage version numbers from shell
3
+ As a lazy gem developer
4
+ I want to have convenience methods to update version numbers
5
+
6
+ Scenario Outline: Incrementing numbers
7
+ Given the version number <input>
8
+ When I increment <which> by <quant>
9
+ Then I should get <out>
10
+
11
+ Scenarios: Regular incrementations
12
+ | input | which | quant | out |
13
+ | 0.0.4 | major | 1 | 1.0.4 |
14
+ | 0.2.5 | regular | 4 | 0.6.5 |
15
+ | 1.5.3 | minor | 3 | 1.5.6 |
16
+
17
+ Scenario Outline: Reseting minor and regular
18
+ Given the version number <input>
19
+ When I increment <which> by <quant> and reset everything under
20
+ Then I should get <out>
21
+
22
+ Scenarios: Incrementations with reset
23
+ | input | which | quant | out |
24
+ | 0.0.5 | regular | 1 | 0.1.0 |
25
+ | 0.3.9 | major | 2 | 2.0.0 |
26
+ | 4.5.2 | regular | 5 | 4.10.0 |
27
27
  | 3.7.1 | major | 1 | 4.0.0 |
@@ -1,40 +1,40 @@
1
- module Versionifier
2
- VERSION = "0.1.0"
3
-
4
- class Version
5
- attr_accessor :major, :regular, :minor
6
- def initialize(the_version)
7
- splitted = the_version.split "."
8
- @major = splitted[0].to_i
9
- @regular = splitted[1].to_i
10
- @minor = splitted[2].to_i
11
- end
12
-
13
- def increment(which, quant, options = nil)
14
- new_version = self.clone
15
- new_version.send "#{which}=".to_sym, self.send(which) + quant
16
- if options == :reset
17
- case which
18
- when :major
19
- new_version.regular = 0; new_version.minor = 0
20
- when :regular
21
- new_version.minor = 0
22
- end
23
- end
24
- new_version
25
- end
26
-
27
- def to_s; "#{@major}.#{@regular}.#{@minor}"; end
28
- def eql?(other)
29
- if other.is_a? String
30
- return other == self.to_s
31
- else
32
- return super other
33
- end
34
- end
35
-
36
- def ==(other)
37
- return self.eql? other
38
- end
39
- end
40
- end
1
+ module Versionifier
2
+ VERSION = "0.1.1"
3
+
4
+ class Version
5
+ attr_accessor :major, :regular, :minor
6
+ def initialize(the_version)
7
+ splitted = the_version.split "."
8
+ @major = splitted[0].to_i
9
+ @regular = splitted[1].to_i
10
+ @minor = splitted[2].to_i
11
+ end
12
+
13
+ def increment(which, quant, options = nil)
14
+ new_version = self.clone
15
+ new_version.send "#{which}=".to_sym, self.send(which) + quant
16
+ if options == :reset
17
+ case which
18
+ when :major
19
+ new_version.regular = 0; new_version.minor = 0
20
+ when :regular
21
+ new_version.minor = 0
22
+ end
23
+ end
24
+ new_version
25
+ end
26
+
27
+ def to_s; "#{@major}.#{@regular}.#{@minor}"; end
28
+ def eql?(other)
29
+ if other.is_a? String
30
+ return other == self.to_s
31
+ else
32
+ return super other
33
+ end
34
+ end
35
+
36
+ def ==(other)
37
+ return self.eql? other
38
+ end
39
+ end
40
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: versionifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-08 00:00:00.000000000 -03:00
13
- default_executable:
12
+ date: 2012-07-31 00:00:00.000000000 Z
14
13
  dependencies: []
15
14
  description: Version number update gem
16
15
  email:
@@ -33,7 +32,6 @@ files:
33
32
  - lib/versionifier.rb
34
33
  - lib/versionifier/version.rb
35
34
  - versionifier.gemspec
36
- has_rdoc: true
37
35
  homepage: ''
38
36
  licenses: []
39
37
  post_install_message:
@@ -54,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
52
  version: '0'
55
53
  requirements: []
56
54
  rubyforge_project: versionifier
57
- rubygems_version: 1.5.2
55
+ rubygems_version: 1.8.21
58
56
  signing_key:
59
57
  specification_version: 3
60
58
  summary: Version number update gem