mirror of
https://github.com/ditkrg/simplecov-json.git
synced 2026-01-22 22:06:46 +00:00
misc
This commit is contained in:
parent
e4d8b177b1
commit
ad09e37eeb
@ -2,14 +2,15 @@ require 'simplecov'
|
|||||||
require 'json'
|
require 'json'
|
||||||
|
|
||||||
class SimpleCov::Formatter::JSONFormatter
|
class SimpleCov::Formatter::JSONFormatter
|
||||||
|
|
||||||
def format(result)
|
def format(result)
|
||||||
puts result.inspect
|
|
||||||
data = {}
|
data = {}
|
||||||
data[:timestamp] = result.created_at.to_i
|
data[:timestamp] = result.created_at.to_i
|
||||||
data[:command_name] = result.command_name
|
data[:command_name] = result.command_name
|
||||||
data[:files] = []
|
data[:files] = []
|
||||||
result.original_result.each do |filename,coverage|
|
result.original_result.each do |filename, coverage|
|
||||||
next unless result.filenames.include? filename
|
next unless result.filenames.include? filename
|
||||||
|
|
||||||
data[:files] << {
|
data[:files] << {
|
||||||
filename: filename,
|
filename: filename,
|
||||||
coverage: coverage
|
coverage: coverage
|
||||||
@ -27,6 +28,7 @@ class SimpleCov::Formatter::JSONFormatter
|
|||||||
File.open(output_filepath, "w+") do |file|
|
File.open(output_filepath, "w+") do |file|
|
||||||
file.puts json
|
file.puts json
|
||||||
end
|
end
|
||||||
|
|
||||||
puts output_message(result)
|
puts output_message(result)
|
||||||
|
|
||||||
json
|
json
|
||||||
@ -44,9 +46,10 @@ class SimpleCov::Formatter::JSONFormatter
|
|||||||
"Coverage report generated for #{result.command_name} to #{output_filepath}. #{result.covered_lines} / #{result.total_lines} LOC (#{result.covered_percent.round(2)}%) covered."
|
"Coverage report generated for #{result.command_name} to #{output_filepath}. #{result.covered_lines} / #{result.total_lines} LOC (#{result.covered_percent.round(2)}%) covered."
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def output_path
|
def output_path
|
||||||
SimpleCov.coverage_path
|
SimpleCov.coverage_path
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user