Last active
August 29, 2015 14:06
-
-
Save neonichu/b172f0afe5ceb58155c3 to your computer and use it in GitHub Desktop.
Convert JSON generated by Faux Pas to a format understood by PuncoverPlugin.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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