jcrvalidator 0.5.0 → 0.5.1
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 +4 -4
- data/bin/jcr +1 -1
- data/lib/jcr/jcr.rb +33 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a8868c03c216591e509ab1aee8c4f3d33e7acae
|
4
|
+
data.tar.gz: 262f39627844782d4f6703c2767994272b88b89a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4cd4e37bcfc7428a4ae1908ecd7a9532380b36a293c29a738f73adbdc1332c8305be556c89ef223f4471b9a8536a6a97947b8129ce3f8acede8a47ac542dbf8
|
7
|
+
data.tar.gz: 3c9e90cef2dd39e472477f55d32730b5252215fba202abb0889cb1e99a243168be6c774cb1b62b474ed894b2abed9c6dbee8e0165d491c86dc493c29d463e1d4
|
data/bin/jcr
CHANGED
data/lib/jcr/jcr.rb
CHANGED
@@ -132,11 +132,11 @@ module JCR
|
|
132
132
|
options = {}
|
133
133
|
|
134
134
|
opt_parser = OptionParser.new do |opt|
|
135
|
-
opt.banner = "Usage: jcr [OPTIONS] [
|
135
|
+
opt.banner = "Usage: jcr [OPTIONS] [JSON_FILES]"
|
136
136
|
opt.separator ""
|
137
137
|
opt.separator "Evaluates JSON against JSON Content Rules (JCR)."
|
138
138
|
opt.separator ""
|
139
|
-
opt.separator "If
|
139
|
+
opt.separator "If JSON_FILES is not specified, standard input (STDIN) is used."
|
140
140
|
opt.separator ""
|
141
141
|
opt.separator "Use -v to see results, otherwise check the exit code."
|
142
142
|
opt.separator ""
|
@@ -207,18 +207,40 @@ module JCR
|
|
207
207
|
ctx.override!( ov )
|
208
208
|
end
|
209
209
|
end
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
210
|
+
|
211
|
+
if $stdin.tty?
|
212
|
+
ec = 2
|
213
|
+
ARGV.each do |fn|
|
214
|
+
data = JSON.parse( File.open( fn ).read )
|
215
|
+
e = ctx.evaluate( data, options[:root_name] )
|
216
|
+
if e.success
|
217
|
+
if options[:verbose]
|
218
|
+
puts "Success!"
|
219
|
+
end
|
220
|
+
ec = 0
|
221
|
+
else
|
222
|
+
if options[:verbose]
|
223
|
+
puts "Failure: #{e.reason}"
|
224
|
+
end
|
225
|
+
ec = 1
|
226
|
+
end
|
215
227
|
end
|
216
|
-
return
|
228
|
+
return ec
|
217
229
|
else
|
218
|
-
|
219
|
-
|
230
|
+
data = JSON.parse( ARGF.read )
|
231
|
+
e = ctx.evaluate( data, options[:root_name] )
|
232
|
+
if e.success
|
233
|
+
if options[:verbose]
|
234
|
+
puts "Success!"
|
235
|
+
end
|
236
|
+
return 0
|
237
|
+
else
|
238
|
+
if options[:verbose]
|
239
|
+
puts "Failure: #{e.reason}"
|
240
|
+
end
|
241
|
+
return 1
|
220
242
|
end
|
221
|
-
|
243
|
+
|
222
244
|
end
|
223
245
|
|
224
246
|
end
|