cddl 0.12.9 → 0.12.11

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: 4c98730c57c25c57066cc2c35d0912b14df39e1d3f3ff3815950217435513d30
4
- data.tar.gz: 1da65aafd52644087e1fa33d5e158ae4c85d58b11658fc39bf64a465f8cf3b43
3
+ metadata.gz: cfdab2f7b34bf400cc492abf8c301a90e01176423c6d1fb41ec45cc439a7757f
4
+ data.tar.gz: 06e53c2536c2a7aa1510f989b2cf8d01d0becbbc71a7264aa8355f29adddb0ad
5
5
  SHA512:
6
- metadata.gz: 54a58e321f94a6c8e3c61dd0216f1e6afd214972dbd71cc4326a5ec294714b4f0ce5b1695ab951bd5526e1cd9a1550c5102333395e3fdda4cac3a87d0c4d075b
7
- data.tar.gz: ad35e2794090e2d403ffa218fd3c9414052c00092b0a1b34ab11d9a7563be3ac06b0e3b5923982f1f46e9b0a2b13e578c7c3da0b12b4cc4ee6eaff0bb5581f5b
6
+ metadata.gz: 170ddd4fa055f9efd24092af3147d4175fdb089e290eafcd418e6a16204250cfa6769f3d53124c5fc6161608301b21186e4d2348bae489175d8ab546230ff5b0
7
+ data.tar.gz: 17025b96351c9def9fe171cd74fc9398eeba3e927eb715b691880b2dd9812e1ea7268bbfc42dfe896d5be3cbf8ad0535cbb0a942cae80b04cdbc97a84e5eb293
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.9'
3
+ s.version = '0.12.11'
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')
data/lib/cddl.rb CHANGED
@@ -119,6 +119,16 @@ module CDDL
119
119
  r.compact
120
120
  end
121
121
 
122
+ def longest_initial_match(old, now)
123
+ md = /\A(.*)(.*)\n\1(.*)\z/.match([old,now].join("\n"))
124
+ md[1..3]
125
+ end
126
+
127
+ def diff_message(old, now)
128
+ c, l, r = longest_initial_match(old, now)
129
+ "-- common: >#{c}< -- old: >#{l}< -- new: >#{r}<"
130
+ end
131
+
122
132
  def cname(s)
123
133
  s.to_s.gsub(/-/, "_")
124
134
  end
@@ -205,7 +215,7 @@ module CDDL
205
215
  ids = g.children(:id).map(&:to_s)
206
216
  # puts ["ids", ids].inspect
207
217
  if b = @generics[n]
208
- fail "Duplicate generics definition #{n} as #{rule_ast} (was #{b})"
218
+ fail "Duplicate generics definition #{n} #{diff_message(strip_nodes(b[0]).inspect, strip_nodes(rule_ast).inspect)}"
209
219
  end
210
220
  @generics[n] = [rule_ast, ids]
211
221
  else
@@ -217,7 +227,7 @@ module CDDL
217
227
  if a == b
218
228
  warn "*** Warning: Identical redefinition of #{n} as #{a}"
219
229
  else
220
- fail "Duplicate rule definition #{n} as #{b} (was #{a})"
230
+ fail "Duplicate rule definition #{n} #{diff_message(b, a)}"
221
231
  end
222
232
  end
223
233
  @rules[n] = rule_ast
@@ -626,7 +636,13 @@ module CDDL
626
636
  end
627
637
  content = JSON::dump(generate1(control))
628
638
  content
629
- when :decimal
639
+ when :decimal, :base10
640
+ if conop == :decimal
641
+ unless @decimal_warned
642
+ warn "** .decimal control operator is now called .base10"
643
+ @decimal_warned = true
644
+ end
645
+ end
630
646
  unless target == [:prim, 3]
631
647
  fail "Don't know yet how to generate #{where}"
632
648
  end
@@ -1200,7 +1216,14 @@ module CDDL
1200
1216
  end
1201
1217
  when :json
1202
1218
  ann if validate1((JSON::load(d) rescue :BAD_JSON), control)
1203
- when :decimal
1219
+ when :decimal, :base10
1220
+ if conop == :decimal
1221
+ unless @decimal_warned
1222
+ warn "** .decimal control operator is now called .base10"
1223
+ @decimal_warned = true
1224
+ end
1225
+ end
1226
+
1204
1227
  ann if (
1205
1228
  if /\A0|-?[1-9][0-9]*\z/ === d
1206
1229
  validate1((d.to_i rescue :BAD_JSON), control)
@@ -1741,7 +1764,7 @@ module CDDL
1741
1764
  :within, :and,
1742
1765
  :default, :lt, :le, :gt, :ge, :eq, :ne,
1743
1766
  :feature, :abnf, :abnfb, :det, :cat, :plus,
1744
- :json, :decimal, :join,
1767
+ :json, :decimal, :base10, :join,
1745
1768
  :b64u, :"b64u-sloppy", :b64c, :"b64c-sloppy",
1746
1769
  :b45, :b32, :h32, :hex, :hexlc, :hexuc,
1747
1770
  :printf,
@@ -0,0 +1 @@
1
+ s = [text .decimal 4711, text .base10 4712]
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.9
4
+ version: 0.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-15 00:00:00.000000000 Z
10
+ date: 2025-05-07 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: cbor-diag
@@ -184,6 +183,7 @@ files:
184
183
  - test-data/cose.cddl
185
184
  - test-data/dcaf.cddl
186
185
  - test-data/dcaf1.cddl
186
+ - test-data/decimal-warn.cddl
187
187
  - test-data/decimal.cddl
188
188
  - test-data/decimal2.cddl
189
189
  - test-data/det1.cddl
@@ -276,7 +276,6 @@ homepage: https://www.rfc-editor.org/rfc/rfc8610#appendix-F
276
276
  licenses:
277
277
  - MIT
278
278
  metadata: {}
279
- post_install_message:
280
279
  rdoc_options: []
281
280
  require_paths:
282
281
  - lib
@@ -291,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
290
  - !ruby/object:Gem::Version
292
291
  version: '0'
293
292
  requirements: []
294
- rubygems_version: 3.5.14
295
- signing_key:
293
+ rubygems_version: 3.6.2
296
294
  specification_version: 4
297
295
  summary: CDDL generator and validator.
298
296
  test_files: []