Class: Bump::BumpInfo
- Inherits:
-
Object
- Object
- Bump::BumpInfo
- Defined in:
- lib/bump/domain/bump_info.rb
Overview
The bump information model
Instance Attribute Summary collapse
-
#after_version ⇒ Object
readonly
Returns the value of attribute after_version.
-
#before_version ⇒ Object
readonly
Returns the value of attribute before_version.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#bump(level) ⇒ Object
Performs bumping version.
-
#commit_message ⇒ String
Gets the commit message with the current version number.
-
#create_update_rules ⇒ Array<Bump::FileUpdateRule>
Creates file update rules according to the current settings.
-
#initialize(version, files, commit) ⇒ BumpInfo
constructor
A new instance of BumpInfo.
-
#perform_update ⇒ void
Performs all updates.
-
#preid=(preid) ⇒ Object
Sets the preid.
-
#update_rules ⇒ Array<Bump::FileUpdateRules>
Gets the file update rules.
-
#valid? ⇒ Boolean
Checks the all the version patterns are available.
Constructor Details
#initialize(version, files, commit) ⇒ BumpInfo
Returns a new instance of BumpInfo.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bump/domain/bump_info.rb', line 11 def initialize(version, files, commit) @version = version @files = files @commit = commit @commit = 'Bump to version v%.%.%' unless @commit @before_version = @version.to_s @after_version = @version.to_s end |
Instance Attribute Details
#after_version ⇒ Object (readonly)
Returns the value of attribute after_version.
6 7 8 |
# File 'lib/bump/domain/bump_info.rb', line 6 def after_version @after_version end |
#before_version ⇒ Object (readonly)
Returns the value of attribute before_version.
6 7 8 |
# File 'lib/bump/domain/bump_info.rb', line 6 def before_version @before_version end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
6 7 8 |
# File 'lib/bump/domain/bump_info.rb', line 6 def commit @commit end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/bump/domain/bump_info.rb', line 6 def files @files end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
6 7 8 |
# File 'lib/bump/domain/bump_info.rb', line 6 def version @version end |
Instance Method Details
#bump(level) ⇒ Object
Performs bumping version.
30 31 32 33 |
# File 'lib/bump/domain/bump_info.rb', line 30 def bump(level) @version.bump level @after_version = @version.to_s end |
#commit_message ⇒ String
Gets the commit message with the current version number
24 25 26 |
# File 'lib/bump/domain/bump_info.rb', line 24 def @commit.sub '%.%.%', @after_version end |
#create_update_rules ⇒ Array<Bump::FileUpdateRule>
Creates file update rules according to the current settings.
51 52 53 54 55 |
# File 'lib/bump/domain/bump_info.rb', line 51 def create_update_rules @files.map do |file, pattern| FileUpdateRuleFactory.create(file, pattern, @before_version, @after_version) end.flatten end |
#perform_update ⇒ void
This method returns an undefined value.
Performs all updates.
60 61 62 |
# File 'lib/bump/domain/bump_info.rb', line 60 def perform_update create_update_rules.each(&:perform) end |
#preid=(preid) ⇒ Object
Sets the preid.
37 38 39 40 |
# File 'lib/bump/domain/bump_info.rb', line 37 def preid=(preid) @version.preid = preid @after_version = @version.to_s end |
#update_rules ⇒ Array<Bump::FileUpdateRules>
Gets the file update rules.
44 45 46 |
# File 'lib/bump/domain/bump_info.rb', line 44 def update_rules create_update_rules end |
#valid? ⇒ Boolean
Checks the all the version patterns are available
66 67 68 69 70 71 72 |
# File 'lib/bump/domain/bump_info.rb', line 66 def valid? create_update_rules.each do |rule| return false if !rule.file_exists || !rule.pattern_exists end true end |