Class: Piggly::Reporter::SchemaCsv
- Defined in:
- lib/piggly/reporter/schema_csv.rb
Overview
Generates schema-level coverage summary in CSV format.
Constant Summary collapse
- HEADERS =
["No", "Schema Name", "Objects Count", "Covered Objects", "Line Coverage Percent"].freeze
- NO_SCHEMA =
"<no schema>".freeze
Constants included from HtmlDsl
HtmlDsl::HTML_PATTERN, HtmlDsl::HTML_REPLACE
Instance Method Summary collapse
-
#initialize(config, profile, output_path = nil) ⇒ SchemaCsv
constructor
A new instance of SchemaCsv.
-
#report(procedures) ⇒ Object
Generate CSV schema coverage report for all procedures.
Methods inherited from Base
Methods included from HtmlDsl
Constructor Details
#initialize(config, profile, output_path = nil) ⇒ SchemaCsv
Returns a new instance of SchemaCsv.
14 15 16 17 18 19 |
# File 'lib/piggly/reporter/schema_csv.rb', line 14 def initialize(config, profile, output_path = nil) @config = config @profile = profile @output_path = output_path || File.join(@config.report_root, "coverage_by_schema.csv") @line_coverage = Compiler::LineCoverage.new(config) end |
Instance Method Details
#report(procedures) ⇒ Object
Generate CSV schema coverage report for all procedures
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/piggly/reporter/schema_csv.rb', line 23 def report(procedures) FileUtils.makedirs(File.dirname(@output_path)) aggregates = aggregate_by_schema(procedures) CSV.open(@output_path, "wb:UTF-8") do |csv| csv << HEADERS aggregates.each_with_index do |row, index| csv << [ index + 1, row[:schema_name], row[:objects_count], row[:covered_objects], format("%0.2f", row[:coverage_percent]) ] end end @output_path end |