cbor-dcbor 0.0.2 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cbor-dcbor.gemspec +1 -1
- data/lib/cbor-dcbor.rb +18 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18a9a98628bd3c72dcec7eb19d97e1fe660d195987d5669fdbabd538762726d8
|
4
|
+
data.tar.gz: eaef07ea3210bc702d2fc326f7b4e9de052c8a9b535d907a2898cc9a459e1a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c146002bc34feea3773f92913aa490bdf230ef9a67e8c042242629ac7bd85fa65d5699caa8473982222b473b9e7ae69e98042b1183d8407ea636684154ddc3ee
|
7
|
+
data.tar.gz: e398441cbafc63cef594d26bbd92c5c81ddc89a99cf7e18ddc97cb7fec5b90853c1504e866739e56285c88643048254c688558b0d8e04e833ce7ea0ba7ba5e75
|
data/cbor-dcbor.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cbor-dcbor"
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.1.2"
|
4
4
|
s.summary = "CBOR (Concise Binary Object Representation) \"dCBOR\" encoding"
|
5
5
|
s.description = %q{cbor-dcbor implements "dCBOR" encoding for CBOR, RFC 8949}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/cbor-dcbor.rb
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
require "cbor" unless defined? CBOR
|
4
4
|
|
5
5
|
module CBOR
|
6
|
-
module Dcbor
|
6
|
+
module Dcbor # Gordian dCBOR
|
7
|
+
|
8
|
+
# Not yet implemented: exclusions
|
7
9
|
|
8
10
|
module Object_Dcbor_CBOR
|
9
11
|
def cbor_prepare_dcbor
|
@@ -15,28 +17,12 @@ module CBOR
|
|
15
17
|
end
|
16
18
|
Object.send(:include, Object_Dcbor_CBOR)
|
17
19
|
|
18
|
-
|
19
|
-
def cbor_prepare_dcbor
|
20
|
-
zigzag, tagnum = if self < 0
|
21
|
-
[-1-self, 3]
|
22
|
-
else
|
23
|
-
[self, 2]
|
24
|
-
end
|
25
|
-
bytes = zigzag.digits(256)
|
26
|
-
if bytes.size + 2 < self.to_cbor.size
|
27
|
-
CBOR::Tagged.new(tagnum, bytes.pack("C*").reverse!)
|
28
|
-
else
|
29
|
-
self
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
Integer.send(:include, Integer_Dcbor_CBOR)
|
20
|
+
DCBOR_PROFILE_1_INTEGER_RANGE = (-2**63 .. 2**64-1)
|
34
21
|
|
35
22
|
module Float_Dcbor_CBOR
|
36
23
|
def cbor_prepare_dcbor
|
37
|
-
int = self.to_i
|
38
|
-
|
39
|
-
int.cbor_prepare_dcbor
|
24
|
+
if finite? && (int = self.to_i) == self && DCBOR_PROFILE_1_INTEGER_RANGE.include?(int)
|
25
|
+
int
|
40
26
|
else
|
41
27
|
self
|
42
28
|
end
|
@@ -69,5 +55,17 @@ module CBOR
|
|
69
55
|
end
|
70
56
|
end
|
71
57
|
CBOR::Tagged.send(:include, Tagged_Dcbor_CBOR)
|
58
|
+
|
59
|
+
module String_Dcbor_CBOR
|
60
|
+
def from_dcbor
|
61
|
+
ret = CBOR.decode(self)
|
62
|
+
if ret.to_dcbor != self
|
63
|
+
raise ArgumentError, "dCBOR deterministic reencoding mismatch", caller
|
64
|
+
end
|
65
|
+
ret
|
66
|
+
end
|
67
|
+
end
|
68
|
+
String.send(:include, String_Dcbor_CBOR)
|
69
|
+
|
72
70
|
end
|
73
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbor-dcbor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: cbor-dcbor implements "dCBOR" encoding for CBOR, RFC 8949
|
14
14
|
email: cabo@tzi.org
|
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
requirements: []
|
41
|
-
rubygems_version: 3.4.
|
41
|
+
rubygems_version: 3.4.6
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: CBOR (Concise Binary Object Representation) "dCBOR" encoding
|