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
32
end
33
33
34
34
def section_with_cid(cid)
35
35
-
@sections.detect { |s| s.cid == cid }&.body
35
35
+
section = @sections.detect { |s| s.cid == cid }
36
36
+
37
37
+
if section
38
38
+
convert_cids(section.body)
39
39
+
section.body
40
40
+
end
36
41
end
37
42
38
43
private
44
44
+
45
45
+
def convert_cids(object)
46
46
+
if object.is_a?(Hash)
47
47
+
object.each do |k, v|
48
48
+
if v.is_a?(Hash) || v.is_a?(Array)
49
49
+
convert_cids(v)
50
50
+
elsif v.is_a?(CBOR::Tagged)
51
51
+
object[k] = CID.from_cbor_tag(v)
52
52
+
end
53
53
+
end
54
54
+
elsif object.is_a?(Array)
55
55
+
object.each_with_index do |v, i|
56
56
+
if v.is_a?(Hash) || v.is_a?(Array)
57
57
+
convert_cids(v)
58
58
+
elsif v.is_a?(CBOR::Tagged)
59
59
+
object[i] = CID.from_cbor_tag(v)
60
60
+
end
61
61
+
end
62
62
+
else
63
63
+
raise DecodeError, "Unexpected value type in record: #{object}"
64
64
+
end
65
65
+
end
39
66
40
67
def read_header(buffer)
41
68
len = buffer.read_varint