class Rrm::Travis

Constants

FILENAME
PATTERN

Attributes

content[RW]
git[RW]
new_version[RW]

Public Class Methods

new(git) click to toggle source
# File lib/rrm/filehandlers/travis.rb, line 8
def initialize(git)
  @content = File.read("#{git.dir.path}/#{FILENAME}")
  @git = git
rescue
  @content = nil
end

Public Instance Methods

ruby_version() click to toggle source
# File lib/rrm/filehandlers/travis.rb, line 26
def ruby_version
  @ruby_version ||= @content.match(PATTERN).captures.first
end
update!(new_version) click to toggle source
# File lib/rrm/filehandlers/travis.rb, line 15
def update!(new_version)
  new_content = content.gsub(/(rvm:\s+-\s)(\d.\d.\d)/, ('\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 #{$!.message}")
  nil
end