Class: Spoom::Coverage::Snapshot
- Inherits:
-
T::Struct
- Object
- T::Struct
- Spoom::Coverage::Snapshot
- Defined in:
- lib/spoom/coverage/snapshot.rb
Constant Summary collapse
- STRICTNESSES =
The strictness name as found in the Sorbet metrics file
T.let(["ignore", "false", "true", "strict", "strong", "stdlib"].freeze, T::Array[String])
Class Method Summary collapse
-
.from_json(json) ⇒ Object
: (String json) -> Snapshot.
-
.from_obj(obj) ⇒ Object
: (Hash[String, untyped] obj) -> Snapshot.
Instance Method Summary collapse
-
#print(out: $stdout, colors: true, indent_level: 0) ⇒ Object
: (?out: (IO | StringIO), ?colors: bool, ?indent_level: Integer) -> void.
-
#to_json(*arg) ⇒ Object
: (*untyped arg) -> String.
Class Method Details
.from_json(json) ⇒ Object
: (String json) -> Snapshot
43 44 45 |
# File 'lib/spoom/coverage/snapshot.rb', line 43 def from_json(json) from_obj(JSON.parse(json)) end |
.from_obj(obj) ⇒ Object
: (Hash[String, untyped] obj) -> Snapshot
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/spoom/coverage/snapshot.rb', line 48 def from_obj(obj) snapshot = Snapshot.new snapshot. = obj.fetch("timestamp", 0) snapshot.version_static = obj.fetch("version_static", nil) snapshot.version_runtime = obj.fetch("version_runtime", nil) snapshot.duration = obj.fetch("duration", 0) snapshot.commit_sha = obj.fetch("commit_sha", nil) snapshot. = obj.fetch("commit_timestamp", nil) snapshot.files = obj.fetch("files", 0) snapshot.rbi_files = obj.fetch("rbi_files", 0) snapshot.modules = obj.fetch("modules", 0) snapshot.classes = obj.fetch("classes", 0) snapshot.singleton_classes = obj.fetch("singleton_classes", 0) snapshot.methods_with_sig = obj.fetch("methods_with_sig", 0) snapshot.methods_without_sig = obj.fetch("methods_without_sig", 0) snapshot.calls_typed = obj.fetch("calls_typed", 0) snapshot.calls_untyped = obj.fetch("calls_untyped", 0) snapshot.methods_with_sig_excluding_rbis = obj.fetch("methods_with_sig_excluding_rbis", 0) snapshot.methods_without_sig_excluding_rbis = obj.fetch("methods_without_sig_excluding_rbis", 0) sigils = obj.fetch("sigils", {}) if sigils Snapshot::STRICTNESSES.each do |strictness| next unless sigils.key?(strictness) snapshot.sigils[strictness] = sigils[strictness] end end sigils_excluding_rbis = obj.fetch("sigils_excluding_rbis", {}) if sigils_excluding_rbis Snapshot::STRICTNESSES.each do |strictness| next unless sigils_excluding_rbis.key?(strictness) snapshot.sigils_excluding_rbis[strictness] = sigils_excluding_rbis[strictness] end end snapshot end |
Instance Method Details
#print(out: $stdout, colors: true, indent_level: 0) ⇒ Object
: (?out: (IO | StringIO), ?colors: bool, ?indent_level: Integer) -> void
31 32 33 34 |
# File 'lib/spoom/coverage/snapshot.rb', line 31 def print(out: $stdout, colors: true, indent_level: 0) printer = SnapshotPrinter.new(out: out, colors: colors, indent_level: indent_level) printer.print_snapshot(self) end |
#to_json(*arg) ⇒ Object
: (*untyped arg) -> String
37 38 39 |
# File 'lib/spoom/coverage/snapshot.rb', line 37 def to_json(*arg) serialize.to_json(*arg) end |