class UpdateRepo::Metrics
Class : Metrics
. This class takes care of storing the metrics for processed, failures, etc.
Public Class Methods
new()
click to toggle source
Public Instance Methods
[](key)
click to toggle source
Read the metric 'key' @param key [symbol] the key to read @return [various] Return the value for hash key 'key'
# File lib/update_repo/metrics.rb, line 25 def [](key) @metrics[key] end
[]=(key, value)
click to toggle source
Set the metric 'key' to 'value' @param key [symbol] the key to set @param value [symbol] set 'key' to this value. @return [value] Return the value set.
# File lib/update_repo/metrics.rb, line 33 def []=(key, value) @metrics[key] = value end
load_errors(config)
click to toggle source
loads an error file (if exists) into the @metrics. @param config [instance] of Config class @return [void]
# File lib/update_repo/metrics.rb, line 58 def load_errors(config) path = "#{config.config_path}.errors" @metrics[:failed_list] = YAML.load_file(path) if File.exist?(path) end
save_errors(config)
click to toggle source
This will save any (git) errors encountered to a file, so they can be reprinted again at a later date. If no errors, then delete any previously existing error file. @param config [instance] of Config class @return [void]
# File lib/update_repo/metrics.rb, line 42 def save_errors(config) # get the location of the config file, we'll use the same dir # and base name path = "#{config.config_path}.errors" if @metrics[:failed_list].empty? # delete any existing file if we have no errors File.delete(path) if File.exist?(path) else # otherwise save the errors to file File.open(path, 'w') { |file| file.write @metrics[:failed_list].to_yaml } end end