refactor read_json method
This commit is contained in:
parent
21926a5e7d
commit
829bd10190
@ -12,16 +12,22 @@ class CoverageReport
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.simplecov(report_path, data)
|
def self.simplecov(report_path, data)
|
||||||
report = JSON.parse(File.read(report_path))
|
report = read_json(report_path)
|
||||||
minumum_percent = data[:min]
|
minumum_percent = data[:min]
|
||||||
covered_percent = report.dig('result', 'covered_percent')
|
covered_percent = report.dig('result', 'covered_percent')
|
||||||
{ 'lines' => { 'covered_percent' => covered_percent, 'minumum_percent' => minumum_percent } }
|
{ 'lines' => { 'covered_percent' => covered_percent, 'minumum_percent' => minumum_percent } }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.jest(report_path, data)
|
def self.jest(report_path, data)
|
||||||
report = JSON.parse(File.read(report_path))
|
report = read_json(report_path)
|
||||||
minumum_percent = data[:min]
|
minumum_percent = data[:min]
|
||||||
covered_percent = report.dig('result', 'covered_percent')
|
covered_percent = report.dig('result', 'covered_percent')
|
||||||
{ 'lines' => { 'covered_percent' => covered_percent, 'minumum_percent' => minumum_percent } }
|
{ 'lines' => { 'covered_percent' => covered_percent, 'minumum_percent' => minumum_percent } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def read_json(path)
|
||||||
|
JSON.parse(File.read(path))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user