lib/uppityrobot/cli/commands/monitors/update.rb in uppityrobot-0.4.0 vs lib/uppityrobot/cli/commands/monitors/update.rb in uppityrobot-0.4.1

- old
+ new

@@ -21,15 +21,15 @@ def call(format:, data:, **) check_format(format) data = parse_data(format, data) unless data.is_a? Array abort( - { stat: "fail", error: "Data must be an array: #{data.inspect}" }.to_json + {stat: "fail", error: "Data must be an array: #{data.inspect}"}.to_json ) end - updated = { stat: "ok", total: 0, updated: 0, monitors: [], errors: [] } + updated = {stat: "ok", total: 0, updated: 0, monitors: [], errors: []} data.each do |d| original = d.dup # UptimeRobot::Client modifies `d`, avoid this for errors updated[:total] += 1 updated[:monitors] << UppityRobot::Client.new(:editMonitor, d).execute updated[:updated] += 1 @@ -37,19 +37,19 @@ updated[:errors] << "#{e.message} for: #{original.inspect}" end puts updated.to_json rescue CSV::MalformedCSVError, JSON::ParserError => e - puts JSON.generate({ stat: "fail", error: "Invalid input: #{e.message}" }) + puts JSON.generate({stat: "fail", error: "Invalid input: #{e.message}"}) end # rubocop:enable Metrics/AbcSize def check_format(format) return if %w[csv json].include? format - abort({ stat: "fail", - error: "Format not recognized, must be one of: [csv, json]" }.to_json) + abort({stat: "fail", + error: "Format not recognized, must be one of: [csv, json]"}.to_json) end def parse_data(format, data) if format == "json" && File.file?(data) JSON.parse(File.read(data)) @@ -60,10 +60,10 @@ CSV.foreach(data, headers: true, header_converters: :symbol) do |row| rows << row.to_hash end rows else - abort({ stat: "fail", error: "Error parsing data: #{format}, #{data.inspect}" }.to_json) + abort({stat: "fail", error: "Error parsing data: #{format}, #{data.inspect}"}.to_json) end end end end end