Class: Bozo::Versioning::Version
- Inherits:
-
Object
- Object
- Bozo::Versioning::Version
- Defined in:
- lib/bozo/versioning/version.rb
Class Method Summary collapse
-
.load_from_file ⇒ Object
Loads the version from the VERSION file.
-
.parse(version) ⇒ Object
Parses a version string to create a Version instance.
Instance Method Summary collapse
-
#bump(part) ⇒ Object
Bumps the part of the version.
- #extension ⇒ Object
-
#initialize(major, minor, patch, extension = nil) ⇒ Version
constructor
A new instance of Version.
- #major ⇒ Object
- #minor ⇒ Object
- #patch ⇒ Object
- #to_s ⇒ Object
-
#write_to_file(filename = "VERSION") ⇒ Object
Writes the version from the VERSION file.
Constructor Details
#initialize(major, minor, patch, extension = nil) ⇒ Version
Returns a new instance of Version.
9 10 11 12 13 14 |
# File 'lib/bozo/versioning/version.rb', line 9 def initialize(major, minor, patch, extension = nil) @major = major @minor = minor @patch = patch @extension = extension end |
Class Method Details
.load_from_file ⇒ Object
Loads the version from the VERSION file
17 18 19 20 21 22 |
# File 'lib/bozo/versioning/version.rb', line 17 def self.load_from_file raise no_version_file unless File.exist? 'VERSION' version = File.read('VERSION').strip raise no_version if version.empty? parse version end |
Instance Method Details
#bump(part) ⇒ Object
Bumps the part of the version
56 57 58 |
# File 'lib/bozo/versioning/version.rb', line 56 def bump(part) send "bump_#{part}".to_sym end |
#extension ⇒ Object
44 45 46 |
# File 'lib/bozo/versioning/version.rb', line 44 def extension @extension end |
#major ⇒ Object
32 33 34 |
# File 'lib/bozo/versioning/version.rb', line 32 def major @major end |
#minor ⇒ Object
36 37 38 |
# File 'lib/bozo/versioning/version.rb', line 36 def minor @minor end |
#patch ⇒ Object
40 41 42 |
# File 'lib/bozo/versioning/version.rb', line 40 def patch @patch end |
#to_s ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/bozo/versioning/version.rb', line 60 def to_s if @extension.nil? "#{@major}.#{@minor}.#{@patch}" else "#{@major}.#{@minor}.#{@patch}-#{@extension}" end end |
#write_to_file(filename = "VERSION") ⇒ Object
Writes the version from the VERSION file
49 50 51 |
# File 'lib/bozo/versioning/version.rb', line 49 def write_to_file filename="VERSION" File.open(filename, 'w') { |f| f << to_s } end |