jsonfmt 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/jsonfmt +9 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e852c40fae0006709f2109421cb6a73779d34f98
|
4
|
+
data.tar.gz: fe4a26d469e5d71512a5b7b403cb1e1250ea0123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a94f64c5881db74c26fda90085d2617823ea1cfcdf8834d8712a427d80719fd5a321a12863cf506e1908c6fc728145af4b22ac77b6fb5008e1a64451fcf3b20
|
7
|
+
data.tar.gz: 8b29c554c35a2eb8f5e304a569e323ba201f7130ab0c59c21e54d7509806a5c580a5fa3855d378273f7497e0aac40669a027b453e7efea6b0efe8ede17036718
|
data/bin/jsonfmt
CHANGED
@@ -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
|
-
|
16
|
-
|
17
|
-
|
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.
|
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-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-yajl
|