Class: FlexmlsGems::VersionHelper
- Inherits:
-
Object
- Object
- FlexmlsGems::VersionHelper
- Defined in:
- lib/flexmls_gems/version_helper.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Instance Method Summary collapse
- #bump_build(tag = "pre") ⇒ Object
- #bump_major ⇒ Object
- #bump_minor ⇒ Object
- #bump_patch ⇒ Object
-
#initialize(pwd = Dir.pwd) ⇒ VersionHelper
constructor
A new instance of VersionHelper.
- #load ⇒ Object
- #parse(string) ⇒ Object
- #path ⇒ Object
- #reset(major = 0, minor = 0, patch = 0, build = nil) ⇒ Object
- #save ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(pwd = Dir.pwd) ⇒ VersionHelper
Returns a new instance of VersionHelper.
4 5 6 7 |
# File 'lib/flexmls_gems/version_helper.rb', line 4 def initialize(pwd=Dir.pwd) @pwd = pwd reset end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
9 10 11 |
# File 'lib/flexmls_gems/version_helper.rb', line 9 def build @build end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
9 10 11 |
# File 'lib/flexmls_gems/version_helper.rb', line 9 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
9 10 11 |
# File 'lib/flexmls_gems/version_helper.rb', line 9 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
9 10 11 |
# File 'lib/flexmls_gems/version_helper.rb', line 9 def patch @patch end |
Instance Method Details
#bump_build(tag = "pre") ⇒ Object
49 50 51 52 |
# File 'lib/flexmls_gems/version_helper.rb', line 49 def bump_build(tag="pre") @build = tag self end |
#bump_major ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/flexmls_gems/version_helper.rb', line 28 def bump_major @major += 1 @minor = 0 @patch = 0 @build = nil self end |
#bump_minor ⇒ Object
36 37 38 39 40 41 |
# File 'lib/flexmls_gems/version_helper.rb', line 36 def bump_minor @minor += 1 @patch = 0 @build = nil self end |
#bump_patch ⇒ Object
43 44 45 46 47 |
# File 'lib/flexmls_gems/version_helper.rb', line 43 def bump_patch @patch += 1 @build = nil self end |
#load ⇒ Object
11 12 13 14 15 |
# File 'lib/flexmls_gems/version_helper.rb', line 11 def load parse(File.read(path)) rescue reset end |
#parse(string) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/flexmls_gems/version_helper.rb', line 17 def parse(string) version_string = string.chomp if version_string =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ reset($1.to_i, $2.to_i, $3.to_i, $4) end end |
#path ⇒ Object
24 25 26 |
# File 'lib/flexmls_gems/version_helper.rb', line 24 def path File.join(@pwd,'VERSION') end |
#reset(major = 0, minor = 0, patch = 0, build = nil) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/flexmls_gems/version_helper.rb', line 54 def reset(major=0, minor=0, patch=0, build=nil) @major = major @minor = minor @patch = patch @build = build self end |
#save ⇒ Object
66 67 68 |
# File 'lib/flexmls_gems/version_helper.rb', line 66 def save File.open(path,'w') { |f| f.write to_s } end |
#to_s ⇒ Object
62 63 64 |
# File 'lib/flexmls_gems/version_helper.rb', line 62 def to_s [major,minor,patch,build].compact.join('.') end |