class DependencyUpdater::RubyHandler
Constants
- FILES
- SOURCE
Public Class Methods
new(git_object)
click to toggle source
# File lib/dependency_updater/handlers/ruby_handler.rb, line 15 def initialize(git_object) @gitlab = git_object @original_version = '' @latest_patch_version = '' end
Public Instance Methods
find_version_data()
click to toggle source
# File lib/dependency_updater/handlers/ruby_handler.rb, line 21 def find_version_data find_original_version find_latest_patch_version end
update_project_files()
click to toggle source
# File lib/dependency_updater/handlers/ruby_handler.rb, line 26 def update_project_files return false if up_to_date actions = [] FILES.each do |filepath| next unless File.exist? filepath new_text = File.read(filepath).strip.gsub(@original_version, @latest_patch_version) actions << @gitlab.build_commit_action(filepath, new_text) end message = "Update Ruby version declarations to #{@latest_patch_version}" @gitlab.commit(message, actions) return true end
Private Instance Methods
find_latest_patch_version()
click to toggle source
# File lib/dependency_updater/handlers/ruby_handler.rb, line 47 def find_latest_patch_version minor_used = @original_version.slice(/(\d+?\.\d+?)\.\d+?/, 1) minor_available = RestClient.get(SOURCE).body.scan(/Ruby\s(#{minor_used}\.\d+?)[^-]/).flatten highest_patch_available = minor_available.map { |v| v.slice(/\d+?$/).to_i }.max @latest_patch_version = "#{minor_used}.#{highest_patch_available}" end
find_original_version()
click to toggle source
# File lib/dependency_updater/handlers/ruby_handler.rb, line 43 def find_original_version @original_version = File.read('.ruby-version').strip end
up_to_date()
click to toggle source
# File lib/dependency_updater/handlers/ruby_handler.rb, line 54 def up_to_date @original_version == @latest_patch_version end