edn-abnf 0.5.5 → 0.5.7
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 +4 -4
- data/bin/edn-abnf +18 -6
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edn-util.rb +16 -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: 3bcd4eb027bdd536dd68495888d729d0bd74647daa157fe2ba8f674432f6a8d8
|
4
|
+
data.tar.gz: 3fcc1ece75ccda7eca35284880b26232f6014528d17e0abd46ef73c86c2dc7da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2820714dc0bca0ac2196af9f156062423db534c166de6b18dd0e243638b808d2906b3bcd2cf0e2d7fcbb6555fa42f21213c1026983ac586e1793735b21bfcd1
|
7
|
+
data.tar.gz: dc913cf9e16dfc2655c086042c477ac664f43ac179bfd06939cc063426360e1e62a1173f84b7413cc97a4f4b7f663a399b3eaaf7e7099f48d1c1c6feeef12614
|
data/bin/edn-abnf
CHANGED
@@ -34,6 +34,8 @@ require 'ostruct'
|
|
34
34
|
|
35
35
|
$error = 0
|
36
36
|
|
37
|
+
output_formats = [:basic, :neat, :json, :yaml, :edn, :diag, :pretty, :hex, :cbor]
|
38
|
+
|
37
39
|
$options = OpenStruct.new
|
38
40
|
begin
|
39
41
|
op = OptionParser.new do |opts|
|
@@ -53,8 +55,8 @@ begin
|
|
53
55
|
$options.edn = v
|
54
56
|
end
|
55
57
|
opts.on("-tFMT", "--to=FMT",
|
56
|
-
|
57
|
-
"Target format (default: diag)") do |v|
|
58
|
+
output_formats,
|
59
|
+
"Target format (#{output_formats.join("/")}, default: diag)") do |v|
|
58
60
|
$options.target = v
|
59
61
|
end
|
60
62
|
opts.on("-aAPP", "--app=APP", "Load application extension") do |v|
|
@@ -66,17 +68,21 @@ begin
|
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
71
|
+
opts.on("-f", "--[no-]fallback", "use tag 999 for unknown app-extensions") do |v|
|
72
|
+
$options.fallback = v
|
73
|
+
end
|
69
74
|
end
|
70
75
|
op.parse!
|
71
76
|
rescue Exception => e
|
72
77
|
warn e
|
78
|
+
warn op
|
73
79
|
exit 1
|
74
80
|
end
|
75
81
|
|
76
82
|
|
77
83
|
if !$options.edn
|
78
84
|
if ARGV == []
|
79
|
-
|
85
|
+
warn op
|
80
86
|
exit 1
|
81
87
|
end
|
82
88
|
$options.edn = ARGF.read
|
@@ -165,17 +171,23 @@ when :yaml
|
|
165
171
|
puts result.to_yaml
|
166
172
|
when :edn, :diag, nil
|
167
173
|
puts result.cbor_diagnostic
|
168
|
-
when :pretty, :hex
|
174
|
+
when :pretty, :hex, :cbor
|
169
175
|
# XXX can't do Box yet
|
170
176
|
enc = if CBOR::Sequence === result
|
171
177
|
result.to_cborseq
|
172
178
|
else
|
173
179
|
result.to_cbor
|
174
180
|
end
|
175
|
-
|
181
|
+
case $options.target
|
182
|
+
when :pretty
|
176
183
|
puts CBOR::pretty_seq(enc)
|
177
|
-
|
184
|
+
when :hex
|
178
185
|
puts enc.bytes.map{|x| "%02x" % x}.join
|
186
|
+
when :cbor
|
187
|
+
$stdout.binmode
|
188
|
+
print enc
|
189
|
+
else
|
190
|
+
fail "Cannot happen"
|
179
191
|
end
|
180
192
|
else
|
181
193
|
warn ["Unknown target format: ", $options.target].inspect
|
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.
|
3
|
+
s.version = "0.5.7"
|
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"
|
data/lib/parser/edn-util.rb
CHANGED
@@ -5,11 +5,26 @@ end
|
|
5
5
|
require 'treetop'
|
6
6
|
require_relative './edngrammar'
|
7
7
|
|
8
|
+
class CBOR_DIAG::App_ # fallback!
|
9
|
+
def self.decode(app_prefix, s)
|
10
|
+
if CBOR::Sequence === s
|
11
|
+
args = s.elements
|
12
|
+
else
|
13
|
+
args = [s]
|
14
|
+
end
|
15
|
+
CBOR::Tagged.new(999, [app_prefix, args])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
8
19
|
module EDNGRAMMAR
|
9
20
|
const_set(:APPS, Hash.new { |h, k|
|
10
21
|
h[k] = begin ::CBOR_DIAG.const_get("App_#{k.downcase}")
|
11
22
|
rescue NameError
|
12
|
-
|
23
|
+
if $options.fallback
|
24
|
+
::CBOR_DIAG::App_
|
25
|
+
else
|
26
|
+
raise ArgumentError, "cbor-diagnostic: Unknown application-oriented extension '#{k}'", caller
|
27
|
+
end
|
13
28
|
end
|
14
29
|
}) unless const_defined?(:APPS)
|
15
30
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-05-15 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: bundler
|