summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Meusel <tim@bastelfreak.de>2017-04-19 09:27:49 (GMT)
committerTim Meusel <tim@bastelfreak.de>2017-04-19 09:27:49 (GMT)
commit9c7d45ffa81485e47fba052715b86a0ecbf59e86 (patch)
tree754e2bf841cc9af9064c330c7b4afc41266c1909
parent22a8abfd11339ffac47a247be2d7d9266854e82b (diff)
downloadpuppet-prometheus_reporter-9c7d45ffa81485e47fba052715b86a0ecbf59e86.zip
puppet-prometheus_reporter-9c7d45ffa81485e47fba052715b86a0ecbf59e86.tar.gz
puppet-prometheus_reporter-9c7d45ffa81485e47fba052715b86a0ecbf59e86.tar.bz2
rubocop: autofix
-rw-r--r--lib/puppet/reports/prometheus.rb30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/puppet/reports/prometheus.rb b/lib/puppet/reports/prometheus.rb
index 250bb04..bf4473e 100644
--- a/lib/puppet/reports/prometheus.rb
+++ b/lib/puppet/reports/prometheus.rb
@@ -24,29 +24,29 @@ Puppet::Reports.register_report(:prometheus) do
raise(Puppet::ParseError, "#{configfile}: textfile_directory is not set.")
end
- unless REPORT_FILENAME.nil? or REPORT_FILENAME.end_with? '.prom'
+ unless REPORT_FILENAME.nil? || REPORT_FILENAME.end_with?('.prom')
raise(Puppet::ParseError, "#{configfile}: report_filename does not ends with .prom")
end
def process
- if REPORT_FILENAME.nil?
- namevar = self.host
- else
- namevar = REPORT_FILENAME
- end
+ namevar = if REPORT_FILENAME.nil?
+ host
+ else
+ REPORT_FILENAME
+ end
yaml_filename = File.join(TEXTFILE_DIRECTORY, '.' + namevar + '.yaml')
filename = File.join(TEXTFILE_DIRECTORY, namevar + '.prom')
common_values = {
- environment: self.environment,
- host: self.host,
- }.reduce([]) {
- |values, extra| values + Array("#{extra[0].to_s}=\"#{extra[1].to_s}\"")
- }
+ environment: environment,
+ host: host
+ }.reduce([]) do |values, extra|
+ values + Array("#{extra[0]}=\"#{extra[1]}\"")
+ end
- new_metrics = Hash.new
- unless metrics.empty? or metrics['events'].nil?
+ new_metrics = {}
+ unless metrics.empty? || metrics['events'].nil?
metrics.each do |metric, data|
data.values.each do |val|
new_metrics["puppet_report_#{metric}{name=\"#{val[1]}\",#{common_values.join(',')}}"] = val[2]
@@ -62,9 +62,7 @@ Puppet::Reports.register_report(:prometheus) do
file.write("# Old metrics\n")
existing_metrics = YAML.load_file(yaml_filename)
existing_metrics.each do |k, _v|
- unless new_metrics.include?(k)
- file.write("#{k} -1\n")
- end
+ file.write("#{k} -1\n") unless new_metrics.include?(k)
end
end