cbor-diag 0.5.2 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cbor2diag.rb +7 -1
- data/bin/cborleader2diag.rb +10 -0
- data/bin/cborseq2json.rb +10 -0
- data/bin/cborseq2neatjson.rb +11 -0
- data/bin/cborseq2yaml.rb +18 -0
- data/cbor-diag.gemspec +2 -1
- data/lib/cbor-diag-parser.rb +5 -5
- data/lib/cbor-diagnostic.rb +14 -0
- metadata +28 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7ce2154bebe9237e19250a539bbd30ef39834545bfd2a6e3300f21b1fab9d96
|
4
|
+
data.tar.gz: 5986f189ccf5d06fc90fda46890cbbc97768929355b039d823cb6046768c5cca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdc1056ab81a9eb943ddcf1e63025634d51d61a3bd2f06bc98f10aa220b322fb5d0742e1511c8c144df9c0d1ce63be2d810e16395e15e2c48418c6bad9242950
|
7
|
+
data.tar.gz: 3e9e5ec91bce71170dae957881de0453b3d4841bfe3e5936f6600e8fc299190038cf6be591e3b3cfca186a93bd9170bf0ef15ae0bee4b425b213a9becec32910
|
data/bin/cbor2diag.rb
CHANGED
data/bin/cborseq2json.rb
ADDED
data/bin/cborseq2yaml.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'psych.rb' # WTF
|
3
|
+
require 'yaml'
|
4
|
+
require 'cbor-pure'
|
5
|
+
|
6
|
+
class Array
|
7
|
+
def to_yaml_style()
|
8
|
+
all? {|x| Integer === x } && length < 20 ? :inline : super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ARGF.binmode
|
13
|
+
i = ARGF.read
|
14
|
+
while i != ''
|
15
|
+
o, i = CBOR.decode_with_rest(i)
|
16
|
+
puts YAML.dump(o)
|
17
|
+
end
|
18
|
+
|
data/cbor-diag.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cbor-diag"
|
3
|
-
s.version = "0.5.
|
3
|
+
s.version = "0.5.8"
|
4
4
|
s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
|
5
5
|
s.description = %q{cbor-diag implements diagnostic notation for CBOR, RFC 7049}
|
6
6
|
s.author = "Carsten Bormann"
|
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.add_development_dependency 'bundler', '~>1'
|
20
20
|
s.add_dependency 'treetop', '~>1'
|
21
21
|
s.add_dependency 'json'
|
22
|
+
s.add_dependency 'neatjson'
|
22
23
|
end
|
data/lib/cbor-diag-parser.rb
CHANGED
@@ -2265,7 +2265,7 @@ module CBOR_DIAG
|
|
2265
2265
|
module B64string2
|
2266
2266
|
#"
|
2267
2267
|
def to_rb;
|
2268
|
-
t = s.text_value.chars.each_slice(4).map(&:join)
|
2268
|
+
t = s.text_value.gsub(/\s/, '').chars.each_slice(4).map(&:join)
|
2269
2269
|
if last = t[-1]
|
2270
2270
|
last << "=" * (4 - last.size)
|
2271
2271
|
end
|
@@ -2297,11 +2297,11 @@ module CBOR_DIAG
|
|
2297
2297
|
i2, s2 = index, []
|
2298
2298
|
s3, i3 = [], index
|
2299
2299
|
loop do
|
2300
|
-
if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_
|
2300
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-zA-Z_\\-+/\\s]'] ||= Regexp.new(gr), :regexp, index)
|
2301
2301
|
r4 = true
|
2302
2302
|
@index += 1
|
2303
2303
|
else
|
2304
|
-
terminal_parse_failure('[0-9a-zA-Z_
|
2304
|
+
terminal_parse_failure('[0-9a-zA-Z_\\-+/\\s]')
|
2305
2305
|
r4 = nil
|
2306
2306
|
end
|
2307
2307
|
if r4
|
@@ -2315,11 +2315,11 @@ module CBOR_DIAG
|
|
2315
2315
|
if r3
|
2316
2316
|
s5, i5 = [], index
|
2317
2317
|
loop do
|
2318
|
-
if has_terminal?(@regexps[gr = '\A[
|
2318
|
+
if has_terminal?(@regexps[gr = '\A[=\\s]'] ||= Regexp.new(gr), :regexp, index)
|
2319
2319
|
r6 = true
|
2320
2320
|
@index += 1
|
2321
2321
|
else
|
2322
|
-
terminal_parse_failure('[
|
2322
|
+
terminal_parse_failure('[=\\s]')
|
2323
2323
|
r6 = nil
|
2324
2324
|
end
|
2325
2325
|
if r6
|
data/lib/cbor-diagnostic.rb
CHANGED
@@ -46,6 +46,20 @@ class String
|
|
46
46
|
"(_ #{lengths.map{|l| r = self[pos, l].cbor_diagnostic(options); pos += l; r}.join(", ")})"
|
47
47
|
else
|
48
48
|
if encoding == Encoding::BINARY
|
49
|
+
if options[:try_decode_embedded] && self != ''
|
50
|
+
begin
|
51
|
+
rest = self
|
52
|
+
result = []
|
53
|
+
while rest != ''
|
54
|
+
dv, rest = CBOR.decode_with_rest(rest)
|
55
|
+
result << dv
|
56
|
+
end
|
57
|
+
return "<< #{result.map{|x| x.cbor_diagnostic(options)}.join(", ")} >>"
|
58
|
+
rescue RuntimeError => e
|
59
|
+
# that didn't work out, so continue with other options
|
60
|
+
# puts e.backtrace
|
61
|
+
end
|
62
|
+
end
|
49
63
|
if options[:bytes_as_text] && (u8 = dup.force_encoding(Encoding::UTF_8)).valid_encoding?
|
50
64
|
"'#{u8.cbor_diagnostic(options)[1..-2].gsub("'", "\\\\'")}'" # \' is a backref, so needs \\'
|
51
65
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbor-diag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: neatjson
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
description: cbor-diag implements diagnostic notation for CBOR, RFC 7049
|
56
70
|
email: cabo@tzi.org
|
57
71
|
executables:
|
@@ -59,6 +73,10 @@ executables:
|
|
59
73
|
- cbor2json.rb
|
60
74
|
- cbor2pretty.rb
|
61
75
|
- cbor2yaml.rb
|
76
|
+
- cborleader2diag.rb
|
77
|
+
- cborseq2json.rb
|
78
|
+
- cborseq2neatjson.rb
|
79
|
+
- cborseq2yaml.rb
|
62
80
|
- diag2cbor.rb
|
63
81
|
- diag2pretty.rb
|
64
82
|
- json2cbor.rb
|
@@ -73,6 +91,10 @@ files:
|
|
73
91
|
- bin/cbor2json.rb
|
74
92
|
- bin/cbor2pretty.rb
|
75
93
|
- bin/cbor2yaml.rb
|
94
|
+
- bin/cborleader2diag.rb
|
95
|
+
- bin/cborseq2json.rb
|
96
|
+
- bin/cborseq2neatjson.rb
|
97
|
+
- bin/cborseq2yaml.rb
|
76
98
|
- bin/diag2cbor.rb
|
77
99
|
- bin/diag2pretty.rb
|
78
100
|
- bin/json2cbor.rb
|
@@ -90,7 +112,7 @@ homepage: http://cbor.io/
|
|
90
112
|
licenses:
|
91
113
|
- Apache-2.0
|
92
114
|
metadata: {}
|
93
|
-
post_install_message:
|
115
|
+
post_install_message:
|
94
116
|
rdoc_options: []
|
95
117
|
require_paths:
|
96
118
|
- lib
|
@@ -105,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
127
|
- !ruby/object:Gem::Version
|
106
128
|
version: '0'
|
107
129
|
requirements: []
|
108
|
-
|
109
|
-
|
110
|
-
signing_key:
|
130
|
+
rubygems_version: 3.1.4
|
131
|
+
signing_key:
|
111
132
|
specification_version: 4
|
112
133
|
summary: CBOR (Concise Binary Object Representation) diagnostic notation
|
113
134
|
test_files: []
|