Class: StiDeploy::Version
- Inherits:
-
Object
- Object
- StiDeploy::Version
- Defined in:
- lib/sti_deploy/version.rb,
lib/sti_deploy/version/hotfix.rb,
lib/sti_deploy/version/release.rb,
lib/sti_deploy/version/pre_release.rb,
lib/sti_deploy/version/version_bumper.rb,
lib/sti_deploy/version/release_candidate.rb
Defined Under Namespace
Classes: Hotfix, PreRelease, Release, ReleaseCandidate, VersionBumper
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.
-
#old ⇒ Object
readonly
Returns the value of attribute old.
-
#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.
43 44 45 46 47 48 49 |
# File 'lib/sti_deploy/version.rb', line 43 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 @old = to_s 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 |
#old ⇒ Object (readonly)
Returns the value of attribute old.
6 7 8 |
# File 'lib/sti_deploy/version.rb', line 6 def old @old 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
Instance Method Details
#bump(deploy_type) ⇒ Object
51 52 53 |
# File 'lib/sti_deploy/version.rb', line 51 def bump(deploy_type) VersionBumper.from_deploy_type(deploy_type, self).bump end |
#to_s ⇒ Object
61 62 63 64 65 66 |
# File 'lib/sti_deploy/version.rb', line 61 def to_s base = "#{major}.#{minor}.#{hotfix}" base += "rc#{rc}" if rc > 0 base += "pre#{pre}" if pre > 0 base end |
#update_file! ⇒ Object
55 56 57 58 59 |
# File 'lib/sti_deploy/version.rb', line 55 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 |