tangled
alpha
login
or
join now
mackuba.eu
/
skyfall
A Ruby gem for streaming data from the Bluesky/ATProto firehose
6
fork
atom
overview
issues
pulls
pipelines
fixed image CIDs saved into json as CBOR tags
mackuba.eu
2 years ago
632660ff
0d51a2bd
+28
-1
1 changed file
expand all
collapse all
unified
split
lib
skyfall
car_archive.rb
+28
-1
lib/skyfall/car_archive.rb
···
32
end
33
34
def section_with_cid(cid)
35
-
@sections.detect { |s| s.cid == cid }&.body
0
0
0
0
0
36
end
37
38
private
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
39
40
def read_header(buffer)
41
len = buffer.read_varint
···
32
end
33
34
def section_with_cid(cid)
35
+
section = @sections.detect { |s| s.cid == cid }
36
+
37
+
if section
38
+
convert_cids(section.body)
39
+
section.body
40
+
end
41
end
42
43
private
44
+
45
+
def convert_cids(object)
46
+
if object.is_a?(Hash)
47
+
object.each do |k, v|
48
+
if v.is_a?(Hash) || v.is_a?(Array)
49
+
convert_cids(v)
50
+
elsif v.is_a?(CBOR::Tagged)
51
+
object[k] = CID.from_cbor_tag(v)
52
+
end
53
+
end
54
+
elsif object.is_a?(Array)
55
+
object.each_with_index do |v, i|
56
+
if v.is_a?(Hash) || v.is_a?(Array)
57
+
convert_cids(v)
58
+
elsif v.is_a?(CBOR::Tagged)
59
+
object[i] = CID.from_cbor_tag(v)
60
+
end
61
+
end
62
+
else
63
+
raise DecodeError, "Unexpected value type in record: #{object}"
64
+
end
65
+
end
66
67
def read_header(buffer)
68
len = buffer.read_varint