cbor-diag 0.5.17 → 0.5.19

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/diag2diag.rb +42 -0
  3. data/cbor-diag.gemspec +1 -1
  4. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce766a02a4e89480afebeacc8d954f187bed26e306e4100529cc7174a3a7493e
4
- data.tar.gz: ade034f6ae05df4ddc29a100b523c6ed19127cfc7b83ee37e2f5482c6212fb49
3
+ metadata.gz: 222a5a85e9ce7a04e69d4620d0bbcd851500cea2b56ff6206b317f10c04bbeb8
4
+ data.tar.gz: 61b1b698cd6e8a0a34d532053e5f8784a1a4fe2c9c94713f75359a795926aea3
5
5
  SHA512:
6
- metadata.gz: 61c8f2391568315618435c2470d442b7d0d1baf378f302dcbaf089179d4fc3a3af818ff95dba546264d86d44f1da8a4abc8e5450e121d557796eb07f16064571
7
- data.tar.gz: b4f20f51b47a6b2771d2c1a42668dcdf6a25b49e8d7a020254e1ae5a60f2c896cdd972b80a416d3f3026ddbf89d29d03f67ea9cc97be7045a5e48d9c4b5a9b00
6
+ metadata.gz: b43b8603b856c370d9290fe89c8b6fdc3242c0fe4124704a46c3734c9123a3d4e4da9f21fb838dc55145eae216b0277b5ed57435bcabe56f2df751c0968f6633
7
+ data.tar.gz: 9ae5c2a6d02c854c5e0b4cd0de9f3210ce83d7cd61c86b3eaa1585a478cc54e9df0d0aa1998f28b835483ccfb296787942a40799af717faa8971b6e74de53cc9
data/bin/diag2diag.rb ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cbor-pure'
3
+ require 'treetop'
4
+ require 'cbor-diag-parser'
5
+ unless ''.respond_to? :b
6
+ require 'cbor-diagnostic' # for .b
7
+ end
8
+ require 'cbor-pretty'
9
+ require 'cbor-diagnostic'
10
+ require 'cbor-deterministic'
11
+ require 'cbor-canonical'
12
+
13
+ options = ''
14
+ while /\A-([cdetu]+)\z/ === ARGV[0]
15
+ options << $1
16
+ ARGV.shift
17
+ end
18
+
19
+ def diagnostic(o, options)
20
+ o = o.cbor_pre_canonicalize if /c/ === options
21
+ o = o.cbor_prepare_deterministic if /d/ === options
22
+ puts o.cbor_diagnostic(try_decode_embedded: /e/ === options,
23
+ bytes_as_text: /t/ === options,
24
+ utf8: /u/ === options)
25
+ end
26
+
27
+ parser = CBOR_DIAGParser.new
28
+
29
+ i = ARGF.read.b # binary to work around treetop performance bug
30
+ if result = parser.parse(i)
31
+ decoded = result.to_rb
32
+ out = case decoded
33
+ when CBOR::Sequence
34
+ decoded.elements
35
+ else
36
+ [decoded]
37
+ end.map {|x| diagnostic(x, options)}.join(", ")
38
+ print out
39
+ else
40
+ puts "*** can't parse #{i}"
41
+ puts "*** #{parser.failure_reason}"
42
+ end
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.17"
3
+ s.version = "0.5.19"
4
4
  s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
5
5
  s.description = %q{cbor-diag implements diagnostic notation for CBOR, RFC 8949 and RFC 8742}
6
6
  s.author = "Carsten Bormann"
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.17
4
+ version: 0.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,6 +109,7 @@ executables:
109
109
  - cborseq2pretty.rb
110
110
  - cborseq2yaml.rb
111
111
  - diag2cbor.rb
112
+ - diag2diag.rb
112
113
  - diag2pretty.rb
113
114
  - json2cbor.rb
114
115
  - json2json.rb
@@ -134,6 +135,7 @@ files:
134
135
  - bin/cborseq2pretty.rb
135
136
  - bin/cborseq2yaml.rb
136
137
  - bin/diag2cbor.rb
138
+ - bin/diag2diag.rb
137
139
  - bin/diag2pretty.rb
138
140
  - bin/json2cbor.rb
139
141
  - bin/json2json.rb