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.
-
#initialize(major, minor, patch) ⇒ Version
constructor
A new instance of Version.
- #major ⇒ Object
- #minor ⇒ Object
- #patch ⇒ Object
- #to_s ⇒ Object
-
#write_to_file ⇒ Object
Writes the version from the VERSION file.
Constructor Details
#initialize(major, minor, patch) ⇒ Version
Returns a new instance of Version.
8 9 10 11 12 |
# File 'lib/bozo/versioning/version.rb', line 8 def initialize(major, minor, patch) @major = major @minor = minor @patch = patch end |
Class Method Details
.load_from_file ⇒ Object
Loads the version from the VERSION file
15 16 17 18 19 20 |
# File 'lib/bozo/versioning/version.rb', line 15 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
50 51 52 |
# File 'lib/bozo/versioning/version.rb', line 50 def bump(part) send "bump_#{part}".to_sym end |
#major ⇒ Object
30 31 32 |
# File 'lib/bozo/versioning/version.rb', line 30 def major @major end |
#minor ⇒ Object
34 35 36 |
# File 'lib/bozo/versioning/version.rb', line 34 def minor @minor end |
#patch ⇒ Object
38 39 40 |
# File 'lib/bozo/versioning/version.rb', line 38 def patch @patch end |
#to_s ⇒ Object
54 55 56 |
# File 'lib/bozo/versioning/version.rb', line 54 def to_s "#{@major}.#{@minor}.#{@patch}" end |
#write_to_file ⇒ Object
Writes the version from the VERSION file
43 44 45 |
# File 'lib/bozo/versioning/version.rb', line 43 def write_to_file File.open("VERSION", 'w') { |f| f << to_s } end |