edn-abnf 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/edn-abnf +29 -4
- data/edn-abnf.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3897c19560ddc1c89c6a54f9ae9e71d88e1f1450589cd703261db76bfcca52c
|
4
|
+
data.tar.gz: 561925dbb535a93b97bce28fd6c36882a8ee73dd12e71bce99381f9f0d94dcfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a77b88f8fa087d4a5f1284cfb9735183af07a20090788e9d9b3b3eb0396005d35396cca28228842a0d7d5a9ecbbfa3debb3f6f7a86d83564df1ee2474aed52ff
|
7
|
+
data.tar.gz: a6c564e1577ea8dc88859465112a57a5e5d62473fa36e0f73cf3c30eeb46de0ad46f67197a826f178987b8b7dd856697e3e7c117f127909798e88715bfeda64c
|
data/bin/edn-abnf
CHANGED
@@ -10,7 +10,23 @@ require_relative '../lib/edn-abnf.rb'
|
|
10
10
|
def snaky(name)
|
11
11
|
name.gsub(/-/, "_")
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
|
+
class String
|
15
|
+
def hexi
|
16
|
+
bytes.map{|x| "%02x" % x}.join
|
17
|
+
end
|
18
|
+
def xeh
|
19
|
+
gsub(/\s/, "").chars.each_slice(2).map{ |x| Integer(x.join, 16).chr("BINARY") }.join
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def tree_from_edn_possibly_hex(s)
|
24
|
+
if s[0..1] == "h]"
|
25
|
+
s = s[2..-1].xeh.force_encoding(Encoding::UTF_8)
|
26
|
+
end
|
27
|
+
EDN.from_edn(s).tree
|
28
|
+
end
|
29
|
+
|
14
30
|
Encoding.default_external = Encoding::UTF_8
|
15
31
|
require 'optparse'
|
16
32
|
require 'ostruct'
|
@@ -61,17 +77,26 @@ if $options.lines
|
|
61
77
|
puts "# #{ok}, #{ednin.inspect}, #{out}" if $options.verbose
|
62
78
|
next
|
63
79
|
end
|
80
|
+
if ok[0] == "x"
|
81
|
+
result = tree_from_edn_possibly_hex(ednin)
|
82
|
+
result_hex = result.to_cbor.hexi
|
83
|
+
result_diag = result.cbor_diagnostic
|
84
|
+
puts "x #{ok}, #{ednin.inspect} / #{out} ➔ #{result_diag.inspect} / #{result_hex}" if $options.verbose
|
85
|
+
if result_hex != out
|
86
|
+
puts "** x / #{ednin.inspect} / #{out} ≠ #{result_diag.inspect} / #{result_hex}"
|
87
|
+
end
|
88
|
+
next
|
89
|
+
end
|
64
90
|
begin
|
65
91
|
ok = ok == "="
|
66
92
|
puts "➔ #{ok}, #{ednin}, #{out}" if $options.verbose
|
67
|
-
|
68
|
-
result = edn.tree
|
93
|
+
result = tree_from_edn_possibly_hex(ednin)
|
69
94
|
diag = result.cbor_diagnostic
|
70
95
|
if out == diag && !ok
|
71
96
|
puts "** ≠ / #{diag.inspect} / #{out.inspect}"
|
72
97
|
end
|
73
98
|
if out != diag && ok
|
74
|
-
outdiag =
|
99
|
+
outdiag = tree_from_edn_possibly_hex(out).cbor_diagnostic
|
75
100
|
if outdiag != diag
|
76
101
|
puts "** ≡ / #{ednin.inspect} #{diag.inspect} / #{out.inspect} #{outdiag.inspect}"
|
77
102
|
end
|
data/edn-abnf.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "edn-abnf"
|
3
|
-
s.version = "0.2.
|
3
|
+
s.version = "0.2.5"
|
4
4
|
s.summary = "CBOR Extended Diagnostic Notation (EDN) implemented in ABNF"
|
5
5
|
s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
|
6
6
|
s.author = "Carsten Bormann"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|