versionifier 0.0.3
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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.rdoc +23 -0
- data/Rakefile +2 -0
- data/bin/v+ +64 -0
- data/lib/versionifier/version.rb +3 -0
- data/lib/versionifier.rb +3 -0
- data/versionifier.gemspec +21 -0
- metadata +56 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +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
|
+
|
23
|
+
GPL License
|
data/Rakefile
ADDED
data/bin/v+
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
the_project = { :name => Dir.pwd.split("/").last }
|
4
|
+
|
5
|
+
the_version_file = {
|
6
|
+
:path => Dir.pwd + "/lib/" + the_project[:name] + "/version.rb"
|
7
|
+
}
|
8
|
+
|
9
|
+
raise ArgumentError, "Version file not found on #{the_version_file[:path]}" unless File.exists? the_version_file[:path]
|
10
|
+
|
11
|
+
the_version_file[:content] = File.read the_version_file[:path]
|
12
|
+
|
13
|
+
the_matches = the_version_file[:content].match /VERSION\s+=\s+"(\d+?)\.(\d+?)\.(\d+?)"/
|
14
|
+
|
15
|
+
the_version = {
|
16
|
+
:major => the_matches[1].to_i,
|
17
|
+
:regular => the_matches[2].to_i,
|
18
|
+
:minor => the_matches[3].to_i
|
19
|
+
}
|
20
|
+
|
21
|
+
if ARGV.empty?
|
22
|
+
puts ""
|
23
|
+
puts "Working on #{the_project[:name]} (#{the_version[:major]}.#{the_version[:regular]}.#{the_version[:minor]})"
|
24
|
+
puts ""
|
25
|
+
puts "Usage: "
|
26
|
+
puts " v+ 1 # 0.0.4 -> 0.0.5"
|
27
|
+
puts " v+ 1.0 # 0.0.4 -> 0.1.4"
|
28
|
+
puts " v+ 1.0.0 # 0.0.4 -> 1.0.4"
|
29
|
+
puts ""
|
30
|
+
puts "Any combination is valid. For example:"
|
31
|
+
puts " v+ 1.0.2 # 0.0.4 -> 1.0.6"
|
32
|
+
|
33
|
+
else
|
34
|
+
|
35
|
+
the_argument = { :raw => ARGV.shift }
|
36
|
+
the_new_version = the_version.clone
|
37
|
+
|
38
|
+
if the_match = the_argument[:raw].match(/^\d+$/)
|
39
|
+
the_argument.merge! :major => 0, :regular => 0, :minor => the_match[0].to_i
|
40
|
+
elsif the_match = the_argument[:raw].match(/^(\d+?)\.(\d+)$/)
|
41
|
+
the_argument.merge! :major => 0, :regular => the_match[1].to_i, :minor => the_match[2].to_i
|
42
|
+
elsif the_match = the_argument[:raw].match(/^(\d+?)\.(\d+?)\.(\d+)$/)
|
43
|
+
the_argument.merge! :major => the_match[1].to_i,
|
44
|
+
:regular => the_match[2].to_i,
|
45
|
+
:minor => the_match[3].to_i
|
46
|
+
else
|
47
|
+
raise ArgumentError, "The argument must follow the format <number>[.<number>[.<number>]]"
|
48
|
+
end
|
49
|
+
|
50
|
+
the_new_version[:major] += the_argument[:major]
|
51
|
+
the_new_version[:regular] += the_argument[:regular]
|
52
|
+
the_new_version[:minor] += the_argument[:minor]
|
53
|
+
|
54
|
+
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]}\"")
|
55
|
+
|
56
|
+
# Save the file
|
57
|
+
File.open the_version_file[:path], "w" do |file|
|
58
|
+
file.write the_final_file
|
59
|
+
end
|
60
|
+
|
61
|
+
puts "In #{the_project[:name]} (#{the_version[:major]}.#{the_version[:regular]}.#{the_version[:minor]}) "
|
62
|
+
puts " - Version number updated to (#{the_new_version[:major]}.#{the_new_version[:regular]}.#{the_new_version[:minor]})"
|
63
|
+
|
64
|
+
end
|
data/lib/versionifier.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "versionifier/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "versionifier"
|
7
|
+
s.version = Versionifier::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Xavier Via"]
|
10
|
+
s.email = ["xavier.via.canel@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Version number update gem}
|
13
|
+
s.description = %q{Version number update gem}
|
14
|
+
|
15
|
+
s.rubyforge_project = "versionifier"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: versionifier
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Xavier Via
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-04 00:00:00.000000000 -03:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
description: Version number update gem
|
16
|
+
email:
|
17
|
+
- xavier.via.canel@gmail.com
|
18
|
+
executables:
|
19
|
+
- v+
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- .gitignore
|
24
|
+
- Gemfile
|
25
|
+
- README.rdoc
|
26
|
+
- Rakefile
|
27
|
+
- bin/v+
|
28
|
+
- lib/versionifier.rb
|
29
|
+
- lib/versionifier/version.rb
|
30
|
+
- versionifier.gemspec
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: ''
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project: versionifier
|
52
|
+
rubygems_version: 1.5.2
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: Version number update gem
|
56
|
+
test_files: []
|