jsonfmt 0.0.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 (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/jsonfmt +26 -0
  3. metadata +60 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03ad34ac2766099bf6aee08dc27abbc72ebfd1e4
4
+ data.tar.gz: 9c2d1abcdc92c22508393d30abe6274e1b5fcc6d
5
+ SHA512:
6
+ metadata.gz: 1cbdd8f9ffc1244cb0a12080b28a93115eb4a5f521904d6a691854cc4a5cc0f81bb2bfcab65a42504aeae9f9d7cbf5f13ba1c05a5abb13804b9b831e35eb156c
7
+ data.tar.gz: ce75ce670d0f71161482e13864c4690b7a29e67a3b8146f95af5ddf3c70e14255a8bbdda4cfdb04b46b55612f6e256ea5591cc5de093e06a5580e037967f55c6
data/bin/jsonfmt ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This is the Chef library uses. So we get the same format as a knife <something> -F json
4
+ require 'ffi_yajl'
5
+
6
+ def err(msg)
7
+ puts "ERROR: #{msg}"
8
+ puts "usage: #{$0} <file1> [<file2>] [<file3>]"
9
+ exit 1
10
+ end
11
+
12
+ err "no file specified" unless ARGV.length > 0
13
+
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})
18
+
19
+ if content == newcontent
20
+ puts "No need to reformat file #{file} - not doing anything"
21
+ else
22
+ puts "Update file #{file}"
23
+ File.write file, newcontent
24
+ end
25
+ end
26
+
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jsonfmt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Patrick Viet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi-yajl
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.2'
27
+ description: reformat json files
28
+ email:
29
+ - patrick.viet@gmail.com
30
+ executables:
31
+ - jsonfmt
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/jsonfmt
36
+ homepage: https://github.com/patrickviet/jsonfmt
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 2.0.14
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: no summary
60
+ test_files: []