cddl 0.12.1 → 0.12.2

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/cddl +16 -6
  3. data/cddl.gemspec +1 -1
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a29d5d85e11598502b09d04e3b08a7ada9b6d0d8a9eb0e425bb01da81b92532b
4
- data.tar.gz: 61c2a191c264c34600f0b66a8e7cfb2ea1359f3954676828a56a63aa25e3015c
3
+ metadata.gz: 4b6553d8156f74c2c630f22f6069c537e53b4f34a3d436df02ce73f99e648cb5
4
+ data.tar.gz: 175ddf07c82ef984d40c932eb80f8a8d7cdab54823777d8e9482239251756edc
5
5
  SHA512:
6
- metadata.gz: 671d119f1cb328151c0631cbcd808f5a32d1f82d6c715a64cb5e5c9702b3452c996278a6b5055613de74b00f76489a9874037b336ac3a760947d4a2526d84cc9
7
- data.tar.gz: 8146d9b66bb87e84b2179507fb9144012676be726dd5f4312da2482a047e46429a6d41d5b1d49097724aa8cfd68519be06e6e8f860e97f0cbc187de0c20242ca
6
+ metadata.gz: 357a054cb881ab89c00befe26adfcbf9999b8cbd19f400bdd31eccc39a0eb690e50f4552fc446dfa364086987e1187638983e3579e1a3e06084eb874e1311509
7
+ data.tar.gz: bf8e429cf02926f4c078e7911d73ccffb47ee3c96520f627e33673333061cd85b472e3795a122362fe615c7b73f8ac2ad6ac02290c5f9a0a9ba19ebe3b15fae6
data/bin/cddl CHANGED
@@ -22,6 +22,13 @@ def usage
22
22
  exit EX_USAGE
23
23
  end
24
24
 
25
+ def utfify(s)
26
+ s.force_encoding(Encoding::UTF_8).scrub { |c|
27
+ warn "*** replaced invalid UTF-8 byte sequence #{c.inspect} by U+FFFD REPLACEMENT CHARACTER"
28
+ 0xFFFD.chr(Encoding::UTF_8)
29
+ }
30
+ end
31
+
25
32
  def read_arg(arg, remember_fn = true)
26
33
  if arg == "-"
27
34
  $fn = "(stdin)" if remember_fn
@@ -29,15 +36,12 @@ def read_arg(arg, remember_fn = true)
29
36
  else
30
37
  usage unless arg
31
38
  $fn = arg if remember_fn
32
- File.read(arg, mode: "rb").force_encoding(Encoding::UTF_8).scrub { |c|
33
- warn "*** replaced invalid UTF-8 byte sequence #{c.inspect} by U+FFFD REPLACEMENT CHARACTER"
34
- 0xFFFD.chr(Encoding::UTF_8)
35
- }
39
+ File.read(arg, mode: "rb")
36
40
  end
37
41
  end
38
42
 
39
43
  def parser
40
- @parser ||= CDDL::Parser.new(read_arg(ARGV[0], false))
44
+ @parser ||= CDDL::Parser.new(utfify(read_arg(ARGV[0], false)))
41
45
  end
42
46
 
43
47
  def my_pp(v)
@@ -102,7 +106,12 @@ begin
102
106
  instance = if $sequence
103
107
  CBOR.decode("\x9f".b << instance.b << "\xff".b)
104
108
  else
105
- CBOR.decode(instance.b) rescue JSON.load(instance)
109
+ begin
110
+ CBOR.decode(instance.b)
111
+ rescue => e
112
+ warn e.inspect if verbose
113
+ JSON.load(utfify(instance))
114
+ end
106
115
  end
107
116
  instance = instance.cbor_clone if $annotate && ENV["EXPERIMENTAL_ANNOTATE"]
108
117
  warn "#{fn}:" if verbose
@@ -110,6 +119,7 @@ begin
110
119
  # my_pp ann
111
120
  instance.cbor_add_annotations_from(ann) rescue nil
112
121
  my_diag(instance) if $annotate
122
+ warn "ann: #{!!ann}" if verbose
113
123
  unless ann
114
124
  retcode = 1
115
125
  end
data/cddl.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'cddl'
3
- s.version = '0.12.1'
3
+ s.version = '0.12.2'
4
4
  s.summary = "CDDL generator and validator."
5
5
  s.description = %{A parser, generator, and validator for CDDL}
6
6
  s.add_dependency('cbor-diag')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.2
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-05-16 00:00:00.000000000 Z
11
+ date: 2024-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cbor-diag
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  - !ruby/object:Gem::Version
291
291
  version: '0'
292
292
  requirements: []
293
- rubygems_version: 3.5.9
293
+ rubygems_version: 3.5.11
294
294
  signing_key:
295
295
  specification_version: 4
296
296
  summary: CDDL generator and validator.