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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/jcr +1 -1
  3. data/lib/jcr/jcr.rb +33 -11
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42b7b9f30fbdce18d3eb52e3fbea46a1a8a1350e
4
- data.tar.gz: 80f3a34f4134303c2bc2c2e153330e316b4c0bef
3
+ metadata.gz: 9a8868c03c216591e509ab1aee8c4f3d33e7acae
4
+ data.tar.gz: 262f39627844782d4f6703c2767994272b88b89a
5
5
  SHA512:
6
- metadata.gz: 660737cced532d5aefa2de290c374eb3a69184d7628215ebfed9feac7d99f92ee7307fb470af295982641bb4dfb688497bfe15f45dc4bb6b53d134f5ad31488c
7
- data.tar.gz: 6fd4e1d6b0cde8f89794d7529d5f19af9a13d6c51a8c1ab31c8350d1bd8dc58122c8e888304e496374899c4df20bcf92eca0ffd7a558a2637de059ce23250e00
6
+ metadata.gz: f4cd4e37bcfc7428a4ae1908ecd7a9532380b36a293c29a738f73adbdc1332c8305be556c89ef223f4471b9a8536a6a97947b8129ce3f8acede8a47ac542dbf8
7
+ data.tar.gz: 3c9e90cef2dd39e472477f55d32730b5252215fba202abb0889cb1e99a243168be6c774cb1b62b474ed894b2abed9c6dbee8e0165d491c86dc493c29d463e1d4
data/bin/jcr CHANGED
@@ -22,5 +22,5 @@ rescue LoadError
22
22
  require 'jcr'
23
23
  end
24
24
 
25
- JCR.main
25
+ exit JCR.main
26
26
 
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] [JSON_FILE]"
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 JSON_FILE is not specified, standard input (STDIN) is used."
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
- data = JSON.parse( ARGF.read )
211
- e = ctx.evaluate( data, options[:root_name] )
212
- if e.success
213
- if options[:verbose]
214
- puts "Success!"
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 0
228
+ return ec
217
229
  else
218
- if options[:verbose]
219
- puts "Failure: #{e.reason}"
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
- return 1
243
+
222
244
  end
223
245
 
224
246
  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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newton