Merge pull request #9344 from Homebrew/dependabot/bundler/Library/Homebrew/simplecov-0.20.0

build(deps): bump simplecov from 0.19.1 to 0.20.0 in /Library/Homebrew
This commit is contained in:
Mike McQuaid 2020-11-30 13:13:38 +00:00 committed by GitHub
commit f24f5f400b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 223 additions and 2 deletions

View File

@ -122,10 +122,12 @@ GEM
rubocop
ruby-macho (2.5.0)
ruby-progressbar (1.10.1)
simplecov (0.19.1)
simplecov (0.20.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.2)
sorbet (0.5.6111)
sorbet-static (= 0.5.6111)
sorbet-runtime (0.5.6111)

View File

@ -0,0 +1,8 @@
# DO NOT EDIT MANUALLY
# This is an autogenerated file for types exported from the `simplecov_json_formatter` gem.
# Please instead update this file by running `tapioca sync`.
# typed: true
# THIS IS AN EMPTY RBI FILE.
# see https://github.com/Shopify/tapioca/blob/master/README.md#manual-gem-requires

View File

@ -27765,6 +27765,13 @@ end
class SimpleCov::Formatter::HTMLFormatter
end
class SimpleCov::Formatter::JSONFormatter
def format(result); end
end
class SimpleCov::Formatter::JSONFormatter
end
class SimpleCov::Formatter::MultiFormatter
end
@ -27789,6 +27796,7 @@ class SimpleCov::Formatter::SimpleFormatter
end
module SimpleCov::Formatter
def self.from_env(env); end
end
module SimpleCov::LastRun
@ -28140,6 +28148,40 @@ module SimpleCov
def self.write_last_run(result); end
end
module SimpleCovJSONFormatter
end
class SimpleCovJSONFormatter::ResultExporter
def export(); end
def initialize(result_hash); end
FILENAME = ::T.let(nil, ::T.untyped)
end
class SimpleCovJSONFormatter::ResultExporter
end
class SimpleCovJSONFormatter::ResultHashFormatter
def format(); end
def initialize(result); end
end
class SimpleCovJSONFormatter::ResultHashFormatter
end
class SimpleCovJSONFormatter::SourceFileFormatter
def format(); end
def initialize(source_file); end
end
class SimpleCovJSONFormatter::SourceFileFormatter
end
module SimpleCovJSONFormatter
end
module Singleton
def _dump(depth=T.unsafe(nil)); end

View File

@ -19,7 +19,8 @@ $:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/extensions/universal-darwi
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/json-2.3.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/docile-1.3.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-html-0.12.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.19.1/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov_json_formatter-0.1.2/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/simplecov-0.20.0/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/codecov-0.2.12/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/coderay-1.1.3/lib"
$:.unshift "#{path}/../#{ruby_engine}/#{ruby_version}/gems/colorize-0.8.1/lib"

View File

@ -0,0 +1,36 @@
# frozen_string_literal: true
require 'simplecov_json_formatter/result_hash_formatter'
require 'simplecov_json_formatter/result_exporter'
require 'json'
module SimpleCov
module Formatter
class JSONFormatter
def format(result)
result_hash = format_result(result)
export_formatted_result(result_hash)
puts output_message(result)
end
private
def format_result(result)
result_hash_formater = SimpleCovJSONFormatter::ResultHashFormatter.new(result)
result_hash_formater.format
end
def export_formatted_result(result_hash)
result_exporter = SimpleCovJSONFormatter::ResultExporter.new(result_hash)
result_exporter.export
end
def output_message(result)
"JSON Coverage report generated for #{result.command_name} to #{SimpleCov.coverage_path}. \
#{result.covered_lines} / #{result.total_lines} LOC (#{result.covered_percent.round(2)}%) covered."
end
end
end
end

View File

@ -0,0 +1,27 @@
# frozen_string_literal: true
module SimpleCovJSONFormatter
class ResultExporter
FILENAME = 'coverage.json'
def initialize(result_hash)
@result = result_hash
end
def export
File.open(export_path, 'w') do |file|
file << json_result
end
end
private
def json_result
JSON.pretty_generate(@result)
end
def export_path
File.join(SimpleCov.coverage_path, FILENAME)
end
end
end

View File

@ -0,0 +1,36 @@
# frozen_string_literal: true
require 'simplecov_json_formatter/source_file_formatter'
module SimpleCovJSONFormatter
class ResultHashFormatter
def initialize(result)
@result = result
end
def format
@result.files.each do |source_file|
formatted_result[:coverage][source_file.filename] =
format_source_file(source_file)
end
formatted_result
end
private
def formatted_result
@formatted_result ||= {
meta: {
simplecov_version: SimpleCov::VERSION
},
coverage: {}
}
end
def format_source_file(source_file)
source_file_formatter = SourceFileFormatter.new(source_file)
source_file_formatter.format
end
end
end

View File

@ -0,0 +1,64 @@
# frozen_string_literal: true
module SimpleCovJSONFormatter
class SourceFileFormatter
def initialize(source_file)
@source_file = source_file
end
def format
if SimpleCov.branch_coverage?
line_coverage.merge(branch_coverage)
else
line_coverage
end
end
private
def line_coverage
@line_coverage || {
lines: lines
}
end
def branch_coverage
{
branches: branches
}
end
def lines
lines = []
@source_file.lines.each do |line|
lines << parse_line(line)
end
lines
end
def branches
branches = []
@source_file.branches.each do |branch|
branches << parse_branch(branch)
end
branches
end
def parse_line(line)
return line.coverage unless line.skipped?
'ignored'
end
def parse_branch(branch)
{
type: branch.type,
start_line: branch.start_line,
end_line: branch.end_line,
coverage: parse_line(branch)
}
end
end
end

View File

@ -0,0 +1,5 @@
# frozen_string_literal: true
module SimpleCovJSONFormatter
VERSION = '0.1.2'
end