Module: SimpleCov::Result::Serialization
- Included in:
- SimpleCov::Result
- Defined in:
- lib/simplecov/result/serialization.rb,
sig/simplecov.rbs
Instance Method Summary collapse
-
#append_contexts(data) ⇒ void
Serialized whenever a map was recorded, even an empty one: for the merge, the key's presence is the signal that this result tracked tests, which is what lets it tell "tracked and covered nothing" from "never tracked".
- #context_filenames ⇒ Set[String]
-
#coverage ⇒ Hash[String, untyped]
A live result's criterion keys are Symbols while entries parsed back from
.resultset.jsoncarry Strings, and the combiners read only String keys. - #to_hash ⇒ Hash[String, Hash[String, untyped]]
Instance Method Details
#append_contexts(data) ⇒ void
This method returns an undefined value.
Serialized whenever a map was recorded, even an empty one: for the merge, the key's presence is the signal that this result tracked tests, which is what lets it tell "tracked and covered nothing" from "never tracked". The map's files are restricted to this result's post-filter universe.
21 22 23 24 25 26 |
# File 'lib/simplecov/result/serialization.rb', line 21 def append_contexts(data) map = contexts return unless map data["contexts"] = map.to_h(only: context_filenames) end |
#context_filenames ⇒ Set[String]
28 29 30 |
# File 'lib/simplecov/result/serialization.rb', line 28 def context_filenames Set.new(filenames) end |
#coverage ⇒ Hash[String, untyped]
A live result's criterion keys are Symbols while entries parsed back from
.resultset.json carry Strings, and the combiners read only String keys.
Serializing with String keys is what lets a live result merged against a
stored entry contribute its counts instead of being dropped.
36 37 38 39 40 |
# File 'lib/simplecov/result/serialization.rb', line 36 def coverage original_result.slice(*filenames).transform_values do |file_coverage| file_coverage.transform_keys(&:to_s) end end |
#to_hash ⇒ Hash[String, Hash[String, untyped]]
6 7 8 9 10 11 12 13 |
# File 'lib/simplecov/result/serialization.rb', line 6 def to_hash data = {"coverage" => coverage, "timestamp" => created_at.to_f} #: Hash[String, untyped] data["run_id"] = run_id if run_id data["worker_id"] = worker_id if worker_id data["tracked_files"] = tracked_files unless tracked_files.empty? append_contexts(data) {command_name => data} end |