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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/edn-abnf +29 -4
  3. data/edn-abnf.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0ccd3540b2b3966eb739a688fd22322c2e0a7300e315d647b583ce5960f33f6
4
- data.tar.gz: 98cdfdc738e65e68970cc9efec4d1616f54d8bfc2bcb296ec3d72c0f0363aa82
3
+ metadata.gz: c3897c19560ddc1c89c6a54f9ae9e71d88e1f1450589cd703261db76bfcca52c
4
+ data.tar.gz: 561925dbb535a93b97bce28fd6c36882a8ee73dd12e71bce99381f9f0d94dcfd
5
5
  SHA512:
6
- metadata.gz: 3e3ee53333c99241e2e9c4f29b06df4b2fd148dbedece4d6287058891e299fefffa8724c914a7931f51b0a8f879449afd1264dcc2dbe3301ccd7eb007418e0bb
7
- data.tar.gz: 73b08bd9557d8780e63ab65b21c71bd573f429ef1c3b29fab03773c61601d9f9ab474d8e8afdd97ac8a232cd815a57900b495ab100e0f38f85dd663a76c9d705
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
- edn = EDN.from_edn(ednin)
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 = EDN.from_edn(out).tree.cbor_diagnostic
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"
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.3
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-19 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler