Module: SimpleCov::Formatter::JSONFormatter::ProductionSectionFormatter
- Extended by:
- ProductionSectionFormatter
- Included in:
- ProductionSectionFormatter
- Defined in:
- lib/simplecov/formatter/json_formatter/production_section_formatter.rb
Instance Method Summary collapse
-
#call(path = SimpleCov.production_coverage) ⇒ Object
The section for the configured store, or nil when none is configured or it is unreadable.
-
#files(store) ⇒ Object
coverageandlast_seenare the two keys a parsed store always carries, sinceFileSink.parsesubstitutes an empty Hash for either one a document is missing. - #section(store) ⇒ Object
Instance Method Details
#call(path = SimpleCov.production_coverage) ⇒ Object
The section for the configured store, or nil when none is configured or it is unreadable. An unreadable store warns instead of raising: the report is generated at the end of a test run, and a missing night of production data must not fail the suite that measured the tests.
15 16 17 18 19 20 21 |
# File 'lib/simplecov/formatter/json_formatter/production_section_formatter.rb', line 15 def call(path = SimpleCov.production_coverage) return nil unless path section(Production::FileSink.read(path)) rescue SystemCallError, Production::Error => e warn "[SimpleCov] skipping production coverage (#{e})" end |
#files(store) ⇒ Object
coverage and last_seen are the two keys a parsed store always carries,
since FileSink.parse substitutes an empty Hash for either one a document
is missing.
36 37 38 39 40 41 42 43 44 |
# File 'lib/simplecov/formatter/json_formatter/production_section_formatter.rb', line 36 def files(store) last_seen = store.fetch("last_seen") store.fetch("coverage").sort.to_h do |file, lines| entry = {lines: lines} #: Hash[Symbol, untyped] stamp = last_seen[file] entry[:last_seen] = stamp if stamp [file, entry] end end |
#section(store) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/simplecov/formatter/json_formatter/production_section_formatter.rb', line 23 def section(store) section = {} #: Hash[Symbol, untyped] started_at = store["started_at"] updated_at = store["updated_at"] section[:started_at] = started_at if started_at section[:updated_at] = updated_at if updated_at section[:files] = files(store) section end |