jsonfmt 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/jsonfmt +9 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03ad34ac2766099bf6aee08dc27abbc72ebfd1e4
4
- data.tar.gz: 9c2d1abcdc92c22508393d30abe6274e1b5fcc6d
3
+ metadata.gz: e852c40fae0006709f2109421cb6a73779d34f98
4
+ data.tar.gz: fe4a26d469e5d71512a5b7b403cb1e1250ea0123
5
5
  SHA512:
6
- metadata.gz: 1cbdd8f9ffc1244cb0a12080b28a93115eb4a5f521904d6a691854cc4a5cc0f81bb2bfcab65a42504aeae9f9d7cbf5f13ba1c05a5abb13804b9b831e35eb156c
7
- data.tar.gz: ce75ce670d0f71161482e13864c4690b7a29e67a3b8146f95af5ddf3c70e14255a8bbdda4cfdb04b46b55612f6e256ea5591cc5de093e06a5580e037967f55c6
6
+ metadata.gz: 5a94f64c5881db74c26fda90085d2617823ea1cfcdf8834d8712a427d80719fd5a321a12863cf506e1908c6fc728145af4b22ac77b6fb5008e1a64451fcf3b20
7
+ data.tar.gz: 8b29c554c35a2eb8f5e304a569e323ba201f7130ab0c59c21e54d7509806a5c580a5fa3855d378273f7497e0aac40669a027b453e7efea6b0efe8ede17036718
@@ -3,18 +3,22 @@
3
3
  # This is the Chef library uses. So we get the same format as a knife <something> -F json
4
4
  require 'ffi_yajl'
5
5
 
6
- def err(msg)
6
+ def err(msg,usage = true)
7
7
  puts "ERROR: #{msg}"
8
- puts "usage: #{$0} <file1> [<file2>] [<file3>]"
8
+ puts "usage: #{$0} <file1> [<file2>] [<file3>]" if usage
9
9
  exit 1
10
10
  end
11
11
 
12
12
  err "no file specified" unless ARGV.length > 0
13
13
 
14
14
  ARGV.each do |file|
15
- content = File.read(file)
16
- tmp = FFI_Yajl::Parser.parse content
17
- newcontent = FFI_Yajl::Encoder.encode(tmp,{pretty: true})
15
+ begin
16
+ content = File.read(file)
17
+ tmp = FFI_Yajl::Parser.parse content
18
+ newcontent = FFI_Yajl::Encoder.encode(tmp,{pretty: true})
19
+ rescue => e
20
+ err("While processing file #{file}: #{e.inspect}",false)
21
+ end
18
22
 
19
23
  if content == newcontent
20
24
  puts "No need to reformat file #{file} - not doing anything"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonfmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Viet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi-yajl