cddl 0.12.5 → 0.12.7

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/cddl.gemspec +1 -2
  3. data/lib/cddl.rb +15 -3
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b77b45ee60d8e79876e52c98aa9ab48548edf4e8af92faa28672db533c292a39
4
- data.tar.gz: f4f61374b1b0c74010f4e2f73ef87487889b1d5f5feefbedba829bba685fc959
3
+ metadata.gz: 58f2bd91f628b3686d62fdd6071ea357207b9a3591e8ecef508a17c4a37df01a
4
+ data.tar.gz: dfdaa775173c9a965330a0edbc428d80e09db21ec7071a660d33357ff99e990f
5
5
  SHA512:
6
- metadata.gz: ed08c886645ce05ad9af193ce4e2a724f1d394c731a3e5438112fd1a5a7a264db2833036d004ec249052ca9cefb42f5a5adb6a13c6ab1ef186edf524debc4b3a
7
- data.tar.gz: e4bcc5a23cf88e2a20d5238a1f2ebf74fa3ae2988deaf3f71336bd009b15b38d511c0cd037a68923d24a86b5ae7d41365f1b31d5294fdeb6ab57dd0f13117ec1
6
+ metadata.gz: 891c152f7453624519f82189e28542e9d3a9b7b18574fea76c743cfc724e83812505fa4c4f159cd0c5c7b24a86513f52e5b4fc200bba0c0ad262105529f25655
7
+ data.tar.gz: 016e7b1ef5527af5e1d4952025183c4a1a87ec00f897a4d140611cccb6d47114a5890ef72514128d888817c2815c63e02a5232676f23770c41cefc9fdae9d24f
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.5'
3
+ s.version = '0.12.7'
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')
@@ -20,7 +20,6 @@ spec = Gem::Specification.new do |s|
20
20
  s.required_ruby_version = '>= 2.3'
21
21
  s.author = "Carsten Bormann"
22
22
  s.email = "cabo@tzi.org"
23
- s.homepage = "http://github.com/cabo/cddl"
24
23
  s.license = 'MIT'
25
24
  end
26
25
 
data/lib/cddl.rb CHANGED
@@ -302,6 +302,12 @@ module CDDL
302
302
  abnfb: Encoding::BINARY
303
303
  }
304
304
 
305
+ def myfrand(exp)
306
+ exprange = 1 << exp
307
+ expoffset= exprange >> 1
308
+ (rand(2)*2-1) * rand() * 2.0**(rand(exprange)-expoffset)
309
+ end
310
+
305
311
  def generate
306
312
  @recursion = 0
307
313
  generate1(rules)
@@ -446,15 +452,15 @@ module CDDL
446
452
  when 0..19, 23, 32..255
447
453
  CBOR::Simple.new(w2)
448
454
  when 25
449
- while !(hs = Half.encode_from_single_bytes([rand()].pack("g")))
455
+ while !(hs = Half.encode_from_single_bytes([myfrand(5)].pack("g")))
450
456
  end
451
457
  Half.decode(hs)
452
458
  when 26
453
- while (a = [rand()].pack("g").unpack("g").first).to_cbor.size != 5
459
+ while (a = [myfrand(8)].pack("g").unpack("g").first).to_cbor.size != 5
454
460
  end
455
461
  a
456
462
  when 27
457
- while (a = rand()).to_cbor.size != 9
463
+ while (a = myfrand(11)).to_cbor.size != 9
458
464
  end
459
465
  a
460
466
  else
@@ -1005,6 +1011,7 @@ module CDDL
1005
1011
  end
1006
1012
 
1007
1013
  OPERATORS = {lt: :<, le: :<=, gt: :>, ge: :>=, eq: :==, ne: :!=}
1014
+ OPERATORS_MATCH = {eq: true, ne: false}
1008
1015
  FLOAT_AI_FROM_SIZE = {3 => 25, 5 => 26, 9 => 27}
1009
1016
 
1010
1017
  def validate1(d, where)
@@ -1135,6 +1142,11 @@ module CDDL
1135
1142
  ok, v, _vt = extract_value(control)
1136
1143
  if ok
1137
1144
  ann if d.send(op, v) rescue nil # XXX Focus ArgumentError
1145
+ else
1146
+ needs_to_match = OPERATORS_MATCH[conop]
1147
+ unless needs_to_match.nil?
1148
+ ann if !!validate1(d, control) == needs_to_match
1149
+ end
1138
1150
  end
1139
1151
  when :regexp
1140
1152
  ann if (
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.5
4
+ version: 0.12.7
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-06-23 00:00:00.000000000 Z
11
+ date: 2024-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cbor-diag
@@ -272,7 +272,7 @@ files:
272
272
  - test-data/yangid.cddl
273
273
  - test-data/yaron1.cddl
274
274
  - test/test-cddl.rb
275
- homepage: http://github.com/cabo/cddl
275
+ homepage:
276
276
  licenses:
277
277
  - MIT
278
278
  metadata: {}
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
293
  requirements: []
294
- rubygems_version: 3.5.11
294
+ rubygems_version: 3.5.14
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: CDDL generator and validator.