edn-abnf 0.5.11 → 0.5.13

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0256ffcfa25350ebaec7f12b1e7453022cb598d940e277f1802372517af2f010
4
- data.tar.gz: 63d04404a325565ef62008b5df88eb4396e0851b68527f104108b2e8e1b7f4b3
3
+ metadata.gz: 69b5019bb0f6f80ce030b7af41a9a354c5a73caa653a151618766444d293fea1
4
+ data.tar.gz: '09c8ac9b5f3fffba27602bf2ecfdcf21d85ac00e26298fedf829c403a09a6c31'
5
5
  SHA512:
6
- metadata.gz: e91c759504595744b197f522fdd6de6ba1a07add5f994e9adf40899d5e0281fe5ab53d184b841b13f27a9e1ae4cc81786ef3767b6d32cb659125bf9bc1ed56a1
7
- data.tar.gz: 4cd259259f9c11a5ff2acdad7da471b98087e5053529b56ec7e144eb207c3caab547041e8fa3eefbcb7a72e17a961152e6e0ff77fab3a983f72ef8a0083ac6d0
6
+ metadata.gz: bc5fbfc1624358d1308ec3d42de5738558eef3c7601c67a6e32a1a4008423fb865506c6c9a5272f0e8288d25899d7f4dd5cda106ec727c0301837b85f1af5a7b
7
+ data.tar.gz: 1cdee66c10564ec2b0633bdd3d02ad25711a5c81e6de5cef7bb2042cb30c912d5a72d55b3444e066ac42f1690209397049868cdbdce75088193dac019452d1e6
data/bin/edn-abnf CHANGED
@@ -5,6 +5,7 @@ require 'yaml'
5
5
  require 'treetop'
6
6
  require 'json'
7
7
  require 'cbor-pretty'
8
+ require 'cbor-deterministic'
8
9
 
9
10
  # Temporary fix for name conflicts between cbor-diag and edn-abnf
10
11
  diag_path = $LOAD_PATH.grep(/gems\/cbor-diag/).first
@@ -40,7 +41,7 @@ require 'ostruct'
40
41
 
41
42
  $error = 0
42
43
 
43
- output_formats = [:basic, :neat, :json, :yaml, :edn, :diag, :pretty, :hex, :cbor]
44
+ output_formats = [:basic, :neat, :json, :yaml, :edn, :diag, :pretty, :hex, :cbor, :"decoder-test"]
44
45
 
45
46
  $options = OpenStruct.new
46
47
  begin
@@ -199,6 +200,45 @@ when :pretty, :hex, :cbor
199
200
  else
200
201
  fail "Cannot happen"
201
202
  end
203
+ when :"decoder-test"
204
+ fail "Not a map" unless Hash === result
205
+ tests = result.delete("tests")
206
+ fail "tests not an array" unless Array === tests
207
+ if result.delete("fail")
208
+ p result
209
+ tests.each do |t|
210
+ encoded = t.delete("encoded")
211
+ fail t unless encoded
212
+ begin
213
+ r = CBOR.decode(encoded)
214
+ fail "#{encoded.inspect} unexpectedly decodes, as #{r.cbor_diagnostic}"
215
+ rescue CBOR::OutOfBytesError, RuntimeError, JSON::GeneratorError
216
+ # p [r, t, encoded]
217
+ rescue => e
218
+ puts "*** Unexpected error:"
219
+ p [e, r, t, encoded.hexi]
220
+ end
221
+ end
222
+ else
223
+ p result
224
+ tests.each do |t|
225
+ encoded = t.delete("encoded")
226
+ fail t unless encoded
227
+ roundtrip = t.delete("roundtrip")
228
+ fail "not implemented: roundtrip is #{roundtrip.inspect} in #{t.inspect}" if roundtrip
229
+ # p t
230
+ decoded = t.delete("decoded") { :"no-decoded"}
231
+ fail "no decoded" if decoded == :"no-decoded"
232
+ begin
233
+ r = CBOR.decode(encoded)
234
+ if !r.cbor_same?(decoded)
235
+ puts "*** unexpected: #{r.inspect} for #{decoded.inspect} in #{t.inspect}"
236
+ end
237
+ rescue => e
238
+ puts "*** decode failure: #{e}"
239
+ end
240
+ end
241
+ end
202
242
  else
203
243
  warn ["Unknown target format: ", $options.target].inspect
204
244
  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.5.11"
3
+ s.version = "0.5.13"
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"
@@ -1,4 +1,10 @@
1
1
  module CBOR
2
+ module CoreExt # extend cbor-pure
3
+ def cbor_same?(other)
4
+ to_deterministic_cbor == other.to_deterministic_cbor
5
+ end
6
+ end
7
+
2
8
  Box = Struct.new(:value, :options) do
3
9
  def to_s
4
10
  value.to_s
@@ -669,11 +669,9 @@ module B64GRAMMAR
669
669
  r0
670
670
  end
671
671
 
672
-
673
- class Parser < Treetop::Runtime::CompiledParser
674
- include B64GRAMMAR
675
- end
676
672
  end
677
673
 
678
- B64GRAMMARParser = B64GRAMMAR::Parser
674
+ class B64GRAMMARParser < Treetop::Runtime::CompiledParser
675
+ include B64GRAMMAR
676
+ end
679
677
 
@@ -707,11 +707,9 @@ module DTGRAMMAR
707
707
  r0
708
708
  end
709
709
 
710
-
711
- class Parser < Treetop::Runtime::CompiledParser
712
- include DTGRAMMAR
713
- end
714
710
  end
715
711
 
716
- DTGRAMMARParser = DTGRAMMAR::Parser
712
+ class DTGRAMMARParser < Treetop::Runtime::CompiledParser
713
+ include DTGRAMMAR
714
+ end
717
715
 
@@ -763,11 +763,9 @@ module HGRAMMAR
763
763
  r0
764
764
  end
765
765
 
766
-
767
- class Parser < Treetop::Runtime::CompiledParser
768
- include HGRAMMAR
769
- end
770
766
  end
771
767
 
772
- HGRAMMARParser = HGRAMMAR::Parser
768
+ class HGRAMMARParser < Treetop::Runtime::CompiledParser
769
+ include HGRAMMAR
770
+ end
773
771
 
@@ -1690,11 +1690,9 @@ module IPGRAMMAR
1690
1690
  r0
1691
1691
  end
1692
1692
 
1693
-
1694
- class Parser < Treetop::Runtime::CompiledParser
1695
- include IPGRAMMAR
1696
- end
1697
1693
  end
1698
1694
 
1699
- IPGRAMMARParser = IPGRAMMAR::Parser
1695
+ class IPGRAMMARParser < Treetop::Runtime::CompiledParser
1696
+ include IPGRAMMAR
1697
+ end
1700
1698
 
@@ -1991,7 +1991,7 @@ module EDNGRAMMAR
1991
1991
  s0 << r1
1992
1992
  if r1
1993
1993
  i2 = index
1994
- r3 = lambda {|(rd)|@rawdelim = rd.text_value}.call(s0)
1994
+ r3 = lambda {|(rd)|@rawdelimlength = rd.text_value.length}.call(s0)
1995
1995
  if !r3
1996
1996
  terminal_parse_failure("<semantic predicate>")
1997
1997
  end
@@ -2040,7 +2040,7 @@ module EDNGRAMMAR
2040
2040
  s0 << r1
2041
2041
  if r1
2042
2042
  i2 = index
2043
- r3 = lambda {|(rd)|rd.text_value.length >= @rawdelim.length}.call(s0)
2043
+ r3 = lambda {|(rd)|rd.text_value.length >= @rawdelimlength}.call(s0)
2044
2044
  if !r3
2045
2045
  terminal_parse_failure("<semantic predicate>")
2046
2046
  end
@@ -2089,7 +2089,7 @@ module EDNGRAMMAR
2089
2089
  s0 << r1
2090
2090
  if r1
2091
2091
  i2 = index
2092
- r3 = lambda {|(rd)|rd.text_value.length < @rawdelim.length}.call(s0)
2092
+ r3 = lambda {|(rd)|rd.text_value.length < @rawdelimlength}.call(s0)
2093
2093
  if !r3
2094
2094
  terminal_parse_failure("<semantic predicate>")
2095
2095
  end
@@ -9132,5 +9132,5 @@ module EDNGRAMMAR
9132
9132
  end
9133
9133
  end
9134
9134
 
9135
- EDNGRAMMARParser = EDNGRAMMAR::Parser
9135
+ (remove_const(:EDNGRAMMARParser) if const_defined?(:EDNGRAMMARParser)) rescue nil; EDNGRAMMARParser = EDNGRAMMAR::Parser
9136
9136
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn-abnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.11
4
+ version: 0.5.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
- rubygems_version: 3.6.9
136
+ rubygems_version: 4.0.2
137
137
  specification_version: 4
138
138
  summary: CBOR Extended Diagnostic Notation (EDN) implemented in ABNF
139
139
  test_files: []