skyfall 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e7396b9d5f8de50025ea41e80b17578607e40aab7bfce17ffd948aa428cdd0f
4
- data.tar.gz: 8915e1d9cc0169c9c8bf0c3995f92fd36a14a49cab846c876a766afd92e31ab1
3
+ metadata.gz: 3917568c1283d599d3103b428599141e04d0df2cce33c4b17291bc935b8add4d
4
+ data.tar.gz: 329dd70a2f17bb689fa0a10c6646c7f522c1ac165b1e0ef49f96cd5b6d746d57
5
5
  SHA512:
6
- metadata.gz: 7fb7381a4fd818a6a9e956107dadb51e0a519898eb6b19f94d28cf3c41d2a25775460aace039b2b4713105e46ec5fef9bf9e5595a0170642f3d6cc59da56ca3f
7
- data.tar.gz: db58dc53caacf3eda013732b9324bd03be5b93445500beac2b035d5e15273dd6f2f7b59f05887f3dab8518a95809126f31d7a6c79eac9c6760d268fc11cc5a19
6
+ metadata.gz: '09e6812b1234a0f7e4aeab3dee4fe962b47a781d7ddcf1151b1f310558e72837808caee9c1ca0d4e98f7e137e7147b72c8bdcd9ae17501c48f1d1dcc1a32ca35'
7
+ data.tar.gz: 5c558d41a7fc49ecc34273a791dc26a706c00708ca0b00b09a59d5bdc4684ff4f14611c065e35343f65d7989a948e5294b7c9edc55b41426f5b2eae893bea392
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.2.3] - 2023-09-28
2
+
3
+ - fixed encoding of image CIDs again (they should be wrapped in a `$link` object)
4
+ - binary strings are now correctly returned as `$bytes` objects
5
+ - added `list`, `listblock` and `threadgate` to record type symbols and collection constants
6
+
1
7
  ## [0.2.2] - 2023-09-06
2
8
 
3
9
  - fixed image CIDs returned in the record JSON as CBOR tag objects (they are now returned decoded to the string form)
@@ -2,6 +2,7 @@ require_relative 'cid'
2
2
  require_relative 'errors'
3
3
  require_relative 'extensions'
4
4
 
5
+ require 'base64'
5
6
  require 'cbor'
6
7
  require 'stringio'
7
8
 
@@ -33,30 +34,30 @@ module Skyfall
33
34
 
34
35
  def section_with_cid(cid)
35
36
  section = @sections.detect { |s| s.cid == cid }
36
-
37
- if section
38
- convert_cids(section.body)
39
- section.body
40
- end
37
+ section && section.body
41
38
  end
42
39
 
43
40
  private
44
41
 
45
- def convert_cids(object)
42
+ def convert_data(object)
46
43
  if object.is_a?(Hash)
47
44
  object.each do |k, v|
48
45
  if v.is_a?(Hash) || v.is_a?(Array)
49
- convert_cids(v)
46
+ convert_data(v)
50
47
  elsif v.is_a?(CBOR::Tagged)
51
- object[k] = CID.from_cbor_tag(v)
48
+ object[k] = make_cid_link(v)
49
+ elsif v.is_a?(String) && v.encoding == Encoding::ASCII_8BIT
50
+ object[k] = make_bytes(v)
52
51
  end
53
52
  end
54
53
  elsif object.is_a?(Array)
55
54
  object.each_with_index do |v, i|
56
55
  if v.is_a?(Hash) || v.is_a?(Array)
57
- convert_cids(v)
56
+ convert_data(v)
58
57
  elsif v.is_a?(CBOR::Tagged)
59
- object[i] = CID.from_cbor_tag(v)
58
+ object[i] = make_cid_link(v)
59
+ elsif v.is_a?(String) && v.encoding == Encoding::ASCII_8BIT
60
+ object[i] = make_bytes(v)
60
61
  end
61
62
  end
62
63
  else
@@ -64,6 +65,14 @@ module Skyfall
64
65
  end
65
66
  end
66
67
 
68
+ def make_cid_link(cid)
69
+ { '$link' => CID.from_cbor_tag(cid) }
70
+ end
71
+
72
+ def make_bytes(data)
73
+ { '$bytes' => Base64.encode64(data).chomp.gsub(/=+$/, '') }
74
+ end
75
+
67
76
  def read_header(buffer)
68
77
  len = buffer.read_varint
69
78
 
@@ -104,6 +113,7 @@ module Skyfall
104
113
 
105
114
  body_data = sbuffer.read
106
115
  body = CBOR.decode(body_data)
116
+ convert_data(body)
107
117
 
108
118
  @sections << CarSection.new(cid, body)
109
119
  end
@@ -1,12 +1,15 @@
1
1
  module Skyfall
2
2
  module Collection
3
- BSKY_POST = "app.bsky.feed.post"
4
- BSKY_LIKE = "app.bsky.feed.like"
5
- BSKY_FOLLOW = "app.bsky.graph.follow"
6
- BSKY_REPOST = "app.bsky.feed.repost"
7
- BSKY_BLOCK = "app.bsky.graph.block"
8
- BSKY_PROFILE = "app.bsky.actor.profile"
9
- BSKY_LISTITEM = "app.bsky.graph.listitem"
10
- BSKY_FEED = "app.bsky.feed.generator"
3
+ BSKY_PROFILE = "app.bsky.actor.profile"
4
+ BSKY_FEED = "app.bsky.feed.generator"
5
+ BSKY_LIKE = "app.bsky.feed.like"
6
+ BSKY_POST = "app.bsky.feed.post"
7
+ BSKY_REPOST = "app.bsky.feed.repost"
8
+ BSKY_THREADGATE = "app.bsky.feed.threadgate"
9
+ BSKY_BLOCK = "app.bsky.graph.block"
10
+ BSKY_FOLLOW = "app.bsky.graph.follow"
11
+ BSKY_LIST = "app.bsky.graph.list"
12
+ BSKY_LISTBLOCK = "app.bsky.graph.listblock"
13
+ BSKY_LISTITEM = "app.bsky.graph.listitem"
11
14
  end
12
15
  end
@@ -41,14 +41,17 @@ module Skyfall
41
41
 
42
42
  def type
43
43
  case collection
44
- when Collection::BSKY_POST then :bsky_post
45
- when Collection::BSKY_LIKE then :bsky_like
46
- when Collection::BSKY_FOLLOW then :bsky_follow
47
- when Collection::BSKY_REPOST then :bsky_repost
48
- when Collection::BSKY_BLOCK then :bsky_block
49
- when Collection::BSKY_PROFILE then :bsky_profile
50
- when Collection::BSKY_LISTITEM then :bsky_listitem
51
- when Collection::BSKY_FEED then :bsky_feed
44
+ when Collection::BSKY_BLOCK then :bsky_block
45
+ when Collection::BSKY_FEED then :bsky_feed
46
+ when Collection::BSKY_FOLLOW then :bsky_follow
47
+ when Collection::BSKY_LIKE then :bsky_like
48
+ when Collection::BSKY_LIST then :bsky_list
49
+ when Collection::BSKY_LISTBLOCK then :bsky_listblock
50
+ when Collection::BSKY_LISTITEM then :bsky_listitem
51
+ when Collection::BSKY_POST then :bsky_post
52
+ when Collection::BSKY_PROFILE then :bsky_profile
53
+ when Collection::BSKY_REPOST then :bsky_repost
54
+ when Collection::BSKY_THREADGATE then :bsky_threadgate
52
55
  else :unknown
53
56
  end
54
57
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Skyfall
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skyfall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kuba Suder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-06 00:00:00.000000000 Z
11
+ date: 2023-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base32