jcrvalidator 0.6.2 → 0.6.4

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
  SHA1:
3
- metadata.gz: c51482b079f0539c1cb4dc314bb0dac5fc5bb34b
4
- data.tar.gz: 7aab4f0a62693d94cb6764f500b9a95558bc19c6
3
+ metadata.gz: 4b2351b0c65ef5e3bbe3878b08b0358319a4ad75
4
+ data.tar.gz: 670ebcfdeb3ff7ee1d921a7c90c0f5767991d329
5
5
  SHA512:
6
- metadata.gz: f0be218960533949c2f4ba48aeaede5e18d9d54a2bd9b2fc757362814f26041e869425265232eb5e22bed56accac74d245a0e11b1e68dab9aeb473dd60a8b801
7
- data.tar.gz: 5a2aedf37cde03afd16060e05e4952107893b2ad3c1ee5e040047592b1af447a12c5218285dfa40781b68b599cda67082b83bfa526305d723c46e74a98191ffe
6
+ metadata.gz: 0fa7a5e9d18418e33b211a963c241db5cd0a81eb8ab2fb58732e524e500037846c67dc0fbff650c09a2a41344c9776c802e91598917ca91b26325acdac3c252d
7
+ data.tar.gz: d9ccd993fc2d950e5954771afb82e05be924deecb81bcd1c675db37236e07cde471cdefac604f31da4b71f67cb811bf57f00441c39557616b15cf166a955c29d
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -178,7 +178,7 @@ module JCR
178
178
 
179
179
  end # end if grule else
180
180
 
181
- if repeat_step && array_index % repeat_step != 0
181
+ if repeat_step && ( array_index - repeat_min ) % repeat_step != 0
182
182
  retval = Evaluation.new( false, "Matches (#{array_index }) do not meat repetition step for #{repeat_max} % #{repeat_step}")
183
183
  end
184
184
 
@@ -241,7 +241,7 @@ module JCR
241
241
  retval = Evaluation.new( false, "array does not have enough #{rule} for #{raised_rule(jcr,rule_atom)}")
242
242
  elsif successes > repeat_max
243
243
  retval = Evaluation.new( false, "array has too many #{rule} for #{raised_rule(jcr,rule_atom)}")
244
- elsif repeat_step && successes % repeat_step != 0
244
+ elsif repeat_step && ( successes - repeat_min ) % repeat_step != 0
245
245
  retval = Evaluation.new( false, "array matches (#{successes}) do not meet repetition step of #{repeat_max} % #{repeat_step} with #{rule} for #{raised_rule(jcr,rule_atom)}")
246
246
  else
247
247
  retval = Evaluation.new( true, nil )
@@ -268,7 +268,7 @@ module JCR
268
268
  retval = Evaluation.new( false, "array does not have enough #{rule} for #{raised_rule(jcr,rule_atom)}")
269
269
  elsif successes > repeat_max
270
270
  retval = Evaluation.new( false, "array has too many #{rule} for #{raised_rule(jcr,rule_atom)}")
271
- elsif repeat_step && successes % repeat_step != 0
271
+ elsif repeat_step && ( successes - repeat_min ) % repeat_step != 0
272
272
  retval = Evaluation.new( false, "array matches (#{successes}) do not meet repetition step of #{repeat_max} % #{repeat_step} with #{rule} for #{raised_rule(jcr,rule_atom)}")
273
273
  else
274
274
  retval = Evaluation.new( true, nil)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -95,7 +95,7 @@ module JCR
95
95
  retval = Evaluation.new( false, "object does not contain group #{rule} for #{raised_rule(jcr,rule_atom)}")
96
96
  elsif successes < repeat_min
97
97
  retval = Evaluation.new( false, "object does not have contain necessary number of group #{rule} for #{raised_rule(jcr,rule_atom)}")
98
- elsif repeat_step && successes % repeat_step != 0
98
+ elsif repeat_step && ( successes - repeat_min ) % repeat_step != 0
99
99
  retval = Evaluation.new( false, "object matches (#{successes}) do not have contain repetition #{repeat_max} % #{repeat_step} of group #{rule} for #{raised_rule(jcr,rule_atom)}")
100
100
  else
101
101
  retval = Evaluation.new( true, nil )
@@ -160,7 +160,7 @@ module JCR
160
160
  retval = Evaluation.new( false, "object does not have enough #{rule} for #{raised_rule(jcr,rule_atom)}")
161
161
  elsif repeat_results.length > repeat_max
162
162
  retval = Evaluation.new( false, "object has too many #{rule} for #{raised_rule(jcr,rule_atom)}")
163
- elsif repeat_step && repeat_results.length % repeat_step != 0
163
+ elsif repeat_step && ( repeat_results.length - repeat_min ) % repeat_step != 0
164
164
  retval = Evaluation.new( false, "object matches (#{repeat_results.length}) does not match repetition step of #{repeat_max} & #{repeat_step} for #{rule} for #{raised_rule(jcr,rule_atom)}")
165
165
  else
166
166
  retval = Evaluation.new( true, nil)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -141,7 +141,10 @@ module JCR
141
141
  elsif rule[:one_or_more]
142
142
  repeat_min = 1
143
143
  repeat_max = Float::INFINITY
144
- repeat_step = rule[:repetition_step].to_s.to_i if rule[:repetition_step]
144
+ if rule[:repetition_step]
145
+ repeat_step = rule[:repetition_step].to_s.to_i
146
+ repeat_min = repeat_step
147
+ end
145
148
  elsif rule[:zero_or_more]
146
149
  repeat_min = 0
147
150
  repeat_max = Float::INFINITY
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -64,7 +64,7 @@ module JCR
64
64
  return bad_value( jcr, rule_atom, "integer", data ) unless data.is_a?( Fixnum )
65
65
  min = jcr[:integer_min].to_s.to_i
66
66
  return bad_value( jcr, rule_atom, min, data ) unless data >= min
67
- when jcr[:integer_max] == nil && jcr[:integer_max] != nil
67
+ when jcr[:integer_min] == nil && jcr[:integer_max] != nil
68
68
  return bad_value( jcr, rule_atom, "integer", data ) unless data.is_a?( Fixnum )
69
69
  max = jcr[:integer_max].to_s.to_i
70
70
  return bad_value( jcr, rule_atom, max, data ) unless data <= max
@@ -223,13 +223,15 @@ module JCR
223
223
  #
224
224
 
225
225
  when jcr[:uri]
226
- return bad_value( jcr, rule_atom, "URI", data ) unless data.is_a?( String )
227
- uri = Addressable::URI.parse( data )
228
- return bad_value( jcr, rule_atom, "URI", data ) unless uri.is_a?( Addressable::URI )
229
- when jcr[:uri_scheme]
230
- t = jcr[:uri_scheme].to_s
231
- return bad_value( jcr, rule_atom, t, data ) unless data.is_a? String
232
- return bad_value( jcr, rule_atom, t, data ) unless data.start_with?( t )
226
+ if jcr[:uri].is_a? Hash
227
+ t = jcr[:uri][:uri_scheme].to_s
228
+ return bad_value( jcr, rule_atom, t, data ) unless data.is_a? String
229
+ return bad_value( jcr, rule_atom, t, data ) unless data.start_with?( t )
230
+ else
231
+ return bad_value( jcr, rule_atom, "URI", data ) unless data.is_a?( String )
232
+ uri = Addressable::URI.parse( data )
233
+ return bad_value( jcr, rule_atom, "URI", data ) unless uri.is_a?( Addressable::URI )
234
+ end
233
235
 
234
236
  #
235
237
  # phone and email value rules
@@ -467,9 +469,11 @@ module JCR
467
469
  retval = "idn"
468
470
 
469
471
  when rule[:uri]
470
- retval = "URI"
471
- when rule[:uri_scheme]
472
- retval = "URI with specific scheme #{rule[:uri_scheme].to_s}"
472
+ if rule[:uri].is_a? Hash
473
+ retval = "URI with specific scheme #{rule[:uri][:uri_scheme].to_s}"
474
+ else
475
+ retval = "URI"
476
+ end
473
477
 
474
478
  when rule[:email]
475
479
  retval = "email"
@@ -479,8 +483,8 @@ module JCR
479
483
 
480
484
  when rule[:hex]
481
485
  retval = "hex"
482
- when rule[:base32url]
483
- retval = "base32url"
486
+ when rule[:base32hex]
487
+ retval = "base32hex"
484
488
  when rule[:base64url]
485
489
  retval = "base64url"
486
490
  when rule[:base64]
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
data/lib/jcr/jcr.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -23,6 +23,7 @@ require 'jcr/check_groups'
23
23
  require 'jcr/find_roots'
24
24
  require 'jcr/map_rule_names'
25
25
  require 'jcr/process_directives'
26
+ require 'jcr/version'
26
27
 
27
28
  module JCR
28
29
 
@@ -214,6 +215,9 @@ module JCR
214
215
  opt.separator " 1 = parsing or other bad condition"
215
216
  opt.separator " 2 = fall through bad condition"
216
217
  opt.separator " 3 = unsuccessful evaluation of JSON"
218
+
219
+ opt.separator ""
220
+ opt.separator "JCR Version " + JCR::VERSION
217
221
  end
218
222
 
219
223
  opt_parser.parse! my_argv
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
data/lib/jcr/parser.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014,2015 American Registry for Internet Numbers (ARIN)
1
+ # Copyright (C) 2014-2016 American Registry for Internet Numbers (ARIN)
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -185,7 +185,7 @@ module JCR
185
185
  integer_type | integer_range | integer_value |
186
186
  sized_int_type | sized_uint_type |
187
187
  ipv4_type | ipv6_type | ipaddr_type | fqdn_type | idn_type |
188
- uri_range | uri_type | phone_type | email_type |
188
+ uri_type | phone_type | email_type |
189
189
  datetime_type | date_type | time_type |
190
190
  hex_type | base32hex_type | base32_type | base64url_type | base64_type |
191
191
  any
@@ -197,7 +197,7 @@ module JCR
197
197
  #! integer_type / integer_range / integer_value /
198
198
  #! sized_int_type / sized_uint_type / ipv4_type /
199
199
  #! ipv6_type / ipaddr_type / fqdn_type / idn_type /
200
- #! uri_range / uri_type / phone_type / email_type /
200
+ #! uri_type / phone_type / email_type /
201
201
  #! datetime_type / date_type / time_type /
202
202
  #! hex_type / base32hex_type / base32_type /
203
203
  #! base64url_type / base64_type / any
@@ -267,11 +267,8 @@ module JCR
267
267
  rule(:idn_type) { str('idn').as(:idn) }
268
268
  #! idn_type = idn-kw
269
269
  #> idn-kw = "idn"
270
- rule(:uri_range) { str('uri..') >> uri_scheme }
271
- #! uri_range = uri-dotdot-kw uri_scheme
272
- #> uri-dotdot-kw = "uri.."
273
- rule(:uri_type) { str('uri').as(:uri) }
274
- #! uri_type = uri-kw
270
+ rule(:uri_type) { (str('uri') >> ( str("..") >> uri_scheme ).maybe).as(:uri) }
271
+ #! uri_type = uri-kw [ ".." uri-scheme ]
275
272
  #> uri-kw = "uri"
276
273
  rule(:phone_type) { str('phone').as(:phone) }
277
274
  #! phone_type = phone-kw
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2015 American Registry for Internet Numbers
1
+ # Copyright (c) 2015-2016 American Registry for Internet Numbers
2
2
  #
3
3
  # Permission to use, copy, modify, and/or distribute this software for any
4
4
  # purpose with or without fee is hereby granted, provided that the above
@@ -0,0 +1,20 @@
1
+ # Copyright (c) 2016 American Registry for Internet Numbers
2
+ #
3
+ # Permission to use, copy, modify, and/or distribute this software for any
4
+ # purpose with or without fee is hereby granted, provided that the above
5
+ # copyright notice and this permission notice appear in all copies.
6
+ #
7
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
13
+ # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
+
15
+
16
+ module JCR
17
+
18
+ VERSION = "0.6.4"
19
+
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jcrvalidator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newton
@@ -89,6 +89,7 @@ files:
89
89
  - lib/jcr/map_rule_names.rb
90
90
  - lib/jcr/parser.rb
91
91
  - lib/jcr/process_directives.rb
92
+ - lib/jcr/version.rb
92
93
  homepage: https://github.com/arineng/jcrvalidator
93
94
  licenses:
94
95
  - ISC