Class: Rrm::GitlabCi
- Inherits:
-
Object
- Object
- Rrm::GitlabCi
- Defined in:
- lib/rrm/filehandlers/gitlab-ci.rb
Constant Summary collapse
- FILENAME =
'.gitlab-ci.yml'
- PATTERN =
/image: ruby:([\d.]{1,5})/
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#git ⇒ Object
Returns the value of attribute git.
-
#new_version ⇒ Object
Returns the value of attribute new_version.
Instance Method Summary collapse
-
#initialize(git) ⇒ GitlabCi
constructor
A new instance of GitlabCi.
- #ruby_version ⇒ Object
- #update!(new_version) ⇒ Object
Constructor Details
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
6 7 8 |
# File 'lib/rrm/filehandlers/gitlab-ci.rb', line 6 def content @content end |
#git ⇒ Object
Returns the value of attribute git.
6 7 8 |
# File 'lib/rrm/filehandlers/gitlab-ci.rb', line 6 def git @git end |
#new_version ⇒ Object
Returns the value of attribute new_version.
6 7 8 |
# File 'lib/rrm/filehandlers/gitlab-ci.rb', line 6 def new_version @new_version end |
Instance Method Details
#ruby_version ⇒ Object
26 27 28 |
# File 'lib/rrm/filehandlers/gitlab-ci.rb', line 26 def ruby_version @ruby_version ||= @content.match(PATTERN).captures.first end |
#update!(new_version) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rrm/filehandlers/gitlab-ci.rb', line 15 def update!(new_version) new_content = content.gsub(/(image: ruby:)([\d.]{1,5})/, ('\1'+new_version)) file = File.open("#{git.dir.path}/#{FILENAME}", 'w') file.puts new_content file.close git.commit_all("Updating #{FILENAME} to Ruby #{new_version}") rescue Rrm.logger.debug("Could not update #{FILENAME} because #{$!.}") nil end |