cddl 0.8.17 → 0.8.18

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cddl +24 -14
  3. data/cddl.gemspec +1 -1
  4. data/test-data/abnf2.cddl +37 -0
  5. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e57d91298d6da2ed2f30060754b3c54f36ebdbf967e6e4e5f3e164fd8dfe2004
4
- data.tar.gz: c1f33e309cee195a2438d4e840fcef8748de4f50625f55ec15dbb154e1b43994
3
+ metadata.gz: ea0383306d236be5fef58afc284e8129b9cd125bb0b8548e6bf76f3bd7b45ab9
4
+ data.tar.gz: 3e439913ec68a51c044a4215a72789a2e4f25dd05b5f9e864349ce7dc9f83113
5
5
  SHA512:
6
- metadata.gz: 871fba7d4ec1b1d94a28149c3c9f9c9cdc4e60ddadb9d503f9ada96b35809534ed576865133f5a78c8645f1cce67f03ef04c799528c5dfa18752398d7e193302
7
- data.tar.gz: df38f1006d6c36782609681c994fd09c8b0eb8a23d35d8de57dcd6b252a18d97d05ef42b776b276b56359e8ee212b25e923e6b337c0944a7646e7770d36b6696
6
+ metadata.gz: a2d7a09bbeedfb2a1d9884deb69e55c8ed889eec727d67fed6c74223981c6cea5aac9fc07a37dd9bd2e253f5942afdc3ac35effe7a9a8baab47baf375f88222e
7
+ data.tar.gz: dd32c4869a4d708863ba8ed1188ae1f98b784c6fc6d33ffab54d2db4a6254cbf2ea0490706d31ae2f4c53f21e64ce7a87b9bb0d81ec495765ffe19a2471c6470
data/bin/cddl CHANGED
@@ -14,8 +14,8 @@ def usage
14
14
  warn "Usage:"
15
15
  warn "#$0 spec.cddl generate [n]"
16
16
  warn "#$0 spec.cddl json-generate [n]"
17
- warn "#$0 spec.cddl validate instance.cbor"
18
- warn "#$0 spec.cddl validate instance.json"
17
+ warn "#$0 spec.cddl validate instance.cbor..."
18
+ warn "#$0 spec.cddl validate instance.json..."
19
19
  exit EX_USAGE
20
20
  end
21
21
 
@@ -48,6 +48,8 @@ def my_diag(v)
48
48
  end
49
49
  end
50
50
 
51
+ retcode = 0
52
+
51
53
  begin
52
54
  case ARGV[1]
53
55
  when /\A..*p/
@@ -85,19 +87,25 @@ begin
85
87
  g = parser.generate
86
88
  puts JSON.pretty_generate(g)
87
89
  end
88
- when /\Av/
89
- instance = read_arg(ARGV[2])
90
- instance = if $sequence
91
- CBOR.decode("\x9f".b << instance.b << "\xff".b)
92
- else
93
- CBOR.decode(instance.b) rescue JSON.load(instance)
90
+ when /\Av(v)?/
91
+ verbose = $1
92
+ ARGV[2..-1].each do |fn|
93
+ instance = read_arg(fn)
94
+ instance = if $sequence
95
+ CBOR.decode("\x9f".b << instance.b << "\xff".b)
96
+ else
97
+ CBOR.decode(instance.b) rescue JSON.load(instance)
98
+ end
99
+ instance = instance.cbor_clone if $annotate && ENV["EXPERIMENTAL_ANNOTATE"]
100
+ warn "#{fn}:" if verbose
101
+ ann = parser.validate(instance)
102
+ # my_pp ann
103
+ instance.cbor_add_annotations_from(ann) rescue nil
104
+ my_diag(instance) if $annotate
105
+ unless ann
106
+ retcode = 1
107
+ end
94
108
  end
95
- instance = instance.cbor_clone if $annotate && ENV["EXPERIMENTAL_ANNOTATE"]
96
- ann = parser.validate(instance)
97
- # my_pp ann
98
- instance.cbor_add_annotations_from(ann) rescue nil
99
- my_diag(instance) if $annotate
100
- exit 1 unless ann
101
109
  else
102
110
  usage
103
111
  end
@@ -105,3 +113,5 @@ rescue CDDL::ParseError => e
105
113
  warn e.message
106
114
  exit EX_DATAERR
107
115
  end
116
+
117
+ exit retcode
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.8.17'
3
+ s.version = '0.8.18'
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')
@@ -0,0 +1,37 @@
1
+ start = [Tag0, Tag1004]
2
+
3
+ ; for draft-ietf-cbor-date-tag
4
+ Tag1004 = #6.1004(text .abnf full-date)
5
+ ; for RFC 7049
6
+ Tag0 = #6.0(text .abnf date-time)
7
+
8
+ full-date = "full-date" .cat rfc3339
9
+ date-time = "date-time" .cat rfc3339
10
+
11
+ ; Note the trick of idiomatically starting with a newline, separating
12
+ ; off the element in the .cat from the rule-list
13
+ rfc3339 = '
14
+ date-fullyear = 4DIGIT
15
+ date-month = 2DIGIT ; 01-12
16
+ date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
17
+ ; month/year
18
+ time-hour = 2DIGIT ; 00-23
19
+ time-minute = 2DIGIT ; 00-59
20
+ time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap sec
21
+ ; rules
22
+ time-secfrac = "." 1*DIGIT
23
+ time-numoffset = ("+" / "-") time-hour ":" time-minute
24
+ time-offset = "Z" / time-numoffset
25
+
26
+ partial-time = time-hour ":" time-minute ":" time-second
27
+ [time-secfrac]
28
+ full-date = date-fullyear "-" date-month "-" date-mday
29
+ full-time = partial-time time-offset
30
+
31
+ date-time = full-date "T" full-time
32
+ ' .cat rfc5234-core
33
+
34
+ rfc5234-core = '
35
+ DIGIT = %x30-39 ; 0-9
36
+ ; abbreviated here
37
+ '
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.17
4
+ version: 0.8.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
@@ -115,6 +115,7 @@ files:
115
115
  - test-data/a.cddl
116
116
  - test-data/abignum.cddl
117
117
  - test-data/abnf1.cddl
118
+ - test-data/abnf2.cddl
118
119
  - test-data/ambig.cddl
119
120
  - test-data/b.cddl
120
121
  - test-data/badaddr.cddl