cddlc 0.3.4 → 0.3.5
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/cddlc.gemspec +1 -1
- data/lib/writer/cddl-writer.rb +27 -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: 6d01061fd86124e6e68aae0a7ef043d23c9a2211992f9421e9333c50d8a870ee
|
4
|
+
data.tar.gz: 7efe567eeca90c756dac4354791583cae6da812b05eaf4074dfb953f71d09adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c051e4c6c4e319e223dc8126512ffe8c7368b985735c8b15b34ac3ae5dad183f7f80f74e3a4b90f1679877472c8c5a0968f38d73994fc4e3dbb8669a39938c09
|
7
|
+
data.tar.gz: 29fce82dbdfd0bf5e14184b8445d3281a648fdd3f1fb982e37020317c23b94100449d21fed9a609a2f041fdc4a035c7842e23f861b5730480f9a828963122fef
|
data/cddlc.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cddlc"
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.5"
|
4
4
|
s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
|
5
5
|
s.description = %q{cddlc implements converters and miscellaneous tools for CDDL, RFC 8610}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/writer/cddl-writer.rb
CHANGED
@@ -2,6 +2,32 @@ require_relative "../cddlc.rb"
|
|
2
2
|
|
3
3
|
class CDDL
|
4
4
|
|
5
|
+
# In each specific case, use the appropriate subset
|
6
|
+
ESCAPED_STRING_MAPPINGS = Hash[[
|
7
|
+
["\x08", "b"],
|
8
|
+
["\x09", "t"],
|
9
|
+
["\x0A", "n"],
|
10
|
+
["\x0C", "f"],
|
11
|
+
["\x0D", "r"],
|
12
|
+
["\x22", "\""],
|
13
|
+
["\x27", "'"],
|
14
|
+
["\x2F", "/"],
|
15
|
+
["\x5C", "\\"],
|
16
|
+
]]
|
17
|
+
|
18
|
+
# TODO: Enable selecting Unicode-friendly variants
|
19
|
+
def escape_string(s)
|
20
|
+
s.gsub(/[^\n !#-\[\]-~]/) {|ch|
|
21
|
+
if m = ESCAPED_STRING_MAPPINGS[ch]
|
22
|
+
"\\#{m}"
|
23
|
+
elsif (o = ch.ord) < 0x10000
|
24
|
+
"\\u#{"%04x" % o}"
|
25
|
+
else
|
26
|
+
"\\u{#{"%x" % o}}"
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
5
31
|
def write_lhs(k, parmnames)
|
6
32
|
if parmnames
|
7
33
|
"#{k}<#{parmnames.join(", ")}>"
|
@@ -104,7 +130,7 @@ class CDDL
|
|
104
130
|
in ["bytes", t]
|
105
131
|
[4, t] # XXX not very clean
|
106
132
|
in ["text", t]
|
107
|
-
[4, "\"#{t}\""]
|
133
|
+
[4, "\"#{escape_string(t)}\""]
|
108
134
|
in ["number", t]
|
109
135
|
[4, t.to_s]
|
110
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cddlc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.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:
|
11
|
+
date: 2025-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|