Class: StiDeploy::Version
- Inherits:
-
Object
- Object
- StiDeploy::Version
- Defined in:
- lib/sti_deploy/version.rb
Constant Summary collapse
- FULL_VERSION_REGEX =
/[\d]+.[\d]+.[\d]+(rc[\d]+)?(pre[\d]+)?/
Instance Attribute Summary collapse
-
#hotfix ⇒ Object
Returns the value of attribute hotfix.
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#pre ⇒ Object
Returns the value of attribute pre.
-
#rc ⇒ Object
Returns the value of attribute rc.
Class Method Summary collapse
Instance Method Summary collapse
- #bump(deploy_type) ⇒ Object
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
- #update_file! ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
42 43 44 45 46 47 |
# File 'lib/sti_deploy/version.rb', line 42 def initialize(version) @major, @minor, @hotfix = version[/[\d]+.[\d]+.[\d]+/].split('.') .map(&:to_i) self.rc = version[/rc[\d]+/].to_s.tr('rc', '').to_i self.pre = version[/pre[\d]+/].to_s.tr('pre', '').to_i end |
Instance Attribute Details
#hotfix ⇒ Object
Returns the value of attribute hotfix.
5 6 7 |
# File 'lib/sti_deploy/version.rb', line 5 def hotfix @hotfix end |
#major ⇒ Object
Returns the value of attribute major.
5 6 7 |
# File 'lib/sti_deploy/version.rb', line 5 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
5 6 7 |
# File 'lib/sti_deploy/version.rb', line 5 def minor @minor end |
#pre ⇒ Object
Returns the value of attribute pre.
5 6 7 |
# File 'lib/sti_deploy/version.rb', line 5 def pre @pre end |
#rc ⇒ Object
Returns the value of attribute rc.
5 6 7 |
# File 'lib/sti_deploy/version.rb', line 5 def rc @rc end |
Class Method Details
.load_version ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/sti_deploy/version.rb', line 10 def load_version validate_version_file version = read_current_version validate_version(version) Messages.puts('version.detected', version: version, color: :green) version end |
Instance Method Details
#bump(deploy_type) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/sti_deploy/version.rb', line 49 def bump(deploy_type) old = to_s send("bump_#{deploy_type}") Messages.puts('version.increment', old: old, new: to_s, color: :green) to_s end |
#to_s ⇒ Object
62 63 64 65 66 67 |
# File 'lib/sti_deploy/version.rb', line 62 def to_s base = "#{major}.#{minor}.#{hotfix}" base += "rc#{rc}" if rc > 0 base += "pre#{pre}" if pre > 0 base end |
#update_file! ⇒ Object
56 57 58 59 60 |
# File 'lib/sti_deploy/version.rb', line 56 def update_file! version_file = File.read(Configuration.version_path) new_version = version_file.gsub(FULL_VERSION_REGEX, to_s) File.open(Configuration.version_path, 'w') { |f| f.puts new_version } end |