Class: SnapshotInspector::Snapshot
- Inherits:
-
Object
- Object
- SnapshotInspector::Snapshot
show all
- Defined in:
- app/models/snapshot_inspector/snapshot.rb,
app/models/snapshot_inspector/snapshot/type.rb,
app/models/snapshot_inspector/snapshot/context.rb,
app/models/snapshot_inspector/snapshot/mail_type.rb,
app/models/snapshot_inspector/snapshot/response_type.rb,
app/models/snapshot_inspector/snapshot/rspec_context.rb,
app/models/snapshot_inspector/snapshot/test_unit_context.rb
Defined Under Namespace
Classes: Context, MailType, NotFound, ResponseType, RspecContext, TestUnitContext, Type
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
10
11
12
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 10
def context
@context
end
|
#created_at ⇒ Object
Returns the value of attribute created_at.
10
11
12
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 10
def created_at
@created_at
end
|
#slug ⇒ Object
Returns the value of attribute slug.
10
11
12
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 10
def slug
@slug
end
|
Class Method Details
.find(slug) ⇒ Object
17
18
19
20
21
22
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 17
def self.find(slug)
hash = JSON.parse(Storage.read(slug), symbolize_names: true)
new.from_hash(hash)
rescue Errno::ENOENT
raise NotFound.new("Snapshot with a slug `#{slug}` can't be found.")
end
|
.grouped_by_test_case ⇒ Object
24
25
26
27
28
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 24
def self.grouped_by_test_case
all.group_by do |snapshot|
snapshot.context.test_group
end
end
|
.persist(snapshotee:, context:) ⇒ Object
13
14
15
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 13
def self.persist(snapshotee:, context:)
new.(snapshotee: snapshotee, context: context).persist
end
|
Instance Method Details
43
44
45
46
47
48
49
50
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 43
def (snapshotee:, context:)
(snapshotee)
(context)
@slug = @context.to_slug
@created_at = Time.current
self
end
|
#from_hash(hash) ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 59
def from_hash(hash)
from_hash_type_specific_data(hash)
from_hash_context(hash)
@slug = hash[:slug]
@created_at = Time.zone.parse(hash[:created_at])
self
end
|
#persist ⇒ Object
53
54
55
56
|
# File 'app/models/snapshot_inspector/snapshot.rb', line 53
def persist
Storage.write(slug, JSON.pretty_generate(as_json))
self
end
|