Class: VersionTracker::Bumper
- Inherits:
-
Object
- Object
- VersionTracker::Bumper
- Defined in:
- lib/version_tracker/bumper.rb
Defined Under Namespace
Modules: PARTS
Constant Summary collapse
- DELIMITER =
'.'- INITIAL_VERSION =
'0.0.0'- BASIC_FORMAT =
/^\d+\.\d+\.\d+$/
Instance Attribute Summary collapse
-
#parts ⇒ Object
Returns the value of attribute parts.
Instance Method Summary collapse
-
#bump(options = {}) ⇒ Object
Options: :part :value.
- #init(version = nil) ⇒ Object
- #version ⇒ Object
Instance Attribute Details
#parts ⇒ Object
Returns the value of attribute parts.
16 17 18 |
# File 'lib/version_tracker/bumper.rb', line 16 def parts @parts end |
Instance Method Details
#bump(options = {}) ⇒ Object
Options:
:part
:value
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/version_tracker/bumper.rb', line 45 def bump = {} raise VersionTrackerError, 'Version File is not initialized' unless FileManager.initialized? part = [:part] || :patch unless [:major, :minor, :patch].include?(part) raise VersionTrackerError, 'Invalid Part Parameter.' end value = [:value] if value && !value.is_a?(Integer) raise VersionTrackerError, 'Value should be of Integer Type' end self.send "bump_#{part}".to_sym, value end |
#init(version = nil) ⇒ Object
31 32 33 34 35 |
# File 'lib/version_tracker/bumper.rb', line 31 def init version = nil raise VersionTrackerError, 'Version format is invalid' if version && !(BASIC_FORMAT =~ version) FileManager.write(version || INITIAL_VERSION) end |
#version ⇒ Object
64 65 66 67 68 |
# File 'lib/version_tracker/bumper.rb', line 64 def version raise VersionTrackerError, 'Version File is not initialized' unless FileManager.initialized? FileManager.read end |