Skip to content

Instantly share code, notes, and snippets.

@neonichu
Last active August 29, 2015 14:06
Show Gist options
  • Save neonichu/b172f0afe5ceb58155c3 to your computer and use it in GitHub Desktop.
Save neonichu/b172f0afe5ceb58155c3 to your computer and use it in GitHub Desktop.
Convert JSON generated by Faux Pas to a format understood by PuncoverPlugin.
#!/usr/bin/env ruby
require 'rubygems'
require 'date'
require 'json'
input = JSON.parse(ARGF.read)
output = { 'meta' => { 'timestamp' => DateTime.now.strftime('%Y-%m-%d %H:%M:%S.%6N') } }
symbols = {}
input['diagnostics'].each do |diag|
file = diag['file']
next unless file
file = file.sub(Dir.pwd + '/', '')
symbol = { 'line' => diag['extent']['start']['line'],
'long_text' => diag['ruleDescription'],
'short_text' => diag['ruleShortName'] }
if symbols.has_key?(file)
symbols[file] << symbol
else
symbols[file] = [ symbol ]
end
end
output['symbols_by_file'] = symbols
File.open('.gutter.json', 'w') { |file| file.write(output.to_json) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment