class Spoom::Coverage::Snapshot

Constants

STRICTNESSES

The strictness name as found in the Sorbet metrics file

Public Class Methods

from_json(json) click to toggle source
# File lib/spoom/coverage/snapshot.rb, line 36
def self.from_json(json)
  from_obj(JSON.parse(json))
end
from_obj(obj) click to toggle source
# File lib/spoom/coverage/snapshot.rb, line 41
def self.from_obj(obj)
  snapshot = Snapshot.new
  snapshot.timestamp = 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.commit_timestamp = 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)

  sigils = obj.fetch("sigils", {})
  if sigils
    Snapshot::STRICTNESSES.each do |strictness|
      next unless sigils.key?(strictness)
      snapshot.sigils[strictness] = sigils[strictness]
    end
  end

  snapshot
end

Public Instance Methods

print(out: $stdout, colors: true, indent_level: 0) click to toggle source
to_json(*arg) click to toggle source
# File lib/spoom/coverage/snapshot.rb, line 71
def to_json(*arg)
  serialize.to_json(*arg)
end