skyfall 0.6.1 → 0.7.1

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.
data/lib/skyfall/cid.rb DELETED
@@ -1,43 +0,0 @@
1
- require_relative 'errors'
2
-
3
- require 'base32'
4
-
5
- # CIDs in DAG-CBOR: https://ipld.io/specs/codecs/dag-cbor/spec/
6
- # CIDs in JSON: https://ipld.io/specs/codecs/dag-json/spec/
7
- # multibase: https://github.com/multiformats/multibase
8
-
9
- module Skyfall
10
- class CID
11
- attr_reader :data
12
-
13
- def self.from_cbor_tag(tag)
14
- data = tag.value
15
- raise DecodeError.new("Unexpected first byte of CID: #{data[0]}") unless data[0] == "\x00"
16
- CID.new(data[1..-1])
17
- end
18
-
19
- def self.from_json(string)
20
- raise DecodeError.new("Unexpected CID length") unless string.length == 59
21
- raise DecodeError.new("Unexpected CID prefix") unless string[0] == 'b'
22
-
23
- data = Base32.decode(string[1..-1].upcase)
24
- CID.new(data)
25
- end
26
-
27
- def initialize(data)
28
- @data = data
29
- end
30
-
31
- def to_s
32
- 'b' + Base32.encode(@data).downcase.gsub(/=+$/, '')
33
- end
34
-
35
- def inspect
36
- "CID(\"#{to_s}\")"
37
- end
38
-
39
- def ==(other)
40
- other.is_a?(CID) && @data == other.data
41
- end
42
- end
43
- end
@@ -1,32 +0,0 @@
1
- require 'cbor'
2
- require 'stringio'
3
-
4
- module Skyfall
5
- module Extensions
6
-
7
- refine StringIO do
8
- # https://en.wikipedia.org/wiki/LEB128
9
- def read_varint
10
- shift = 1
11
- value = 0
12
-
13
- loop do
14
- byte = self.readbyte
15
- value += byte % 128 * shift
16
- break if byte < 128
17
- shift *= 128
18
- end
19
-
20
- value
21
- end
22
- end
23
-
24
- refine CBOR.singleton_class do
25
- def decode_sequence(data)
26
- unpacker = CBOR::Unpacker.new(StringIO.new(data))
27
- unpacker.each.to_a
28
- end
29
- end
30
-
31
- end
32
- end
@@ -1,14 +0,0 @@
1
- require_relative '../firehose'
2
-
3
- module Skyfall
4
-
5
- #
6
- # Note: this event type is deprecated and will stop being emitted at some point.
7
- # You should instead listen for 'identity' events (Skyfall::Firehose::IdentityMessage).
8
- #
9
- class Firehose::HandleMessage < Firehose::Message
10
- def handle
11
- @data_object['handle']
12
- end
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- require_relative '../firehose'
2
-
3
- module Skyfall
4
-
5
- #
6
- # Note: this event type is deprecated and will stop being emitted at some point.
7
- # You should instead listen for 'account' events (Skyfall::Firehose::AccountMessage).
8
- #
9
- class Firehose::TombstoneMessage < Firehose::Message
10
- end
11
- end