jpp 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.
- data/README.md +32 -0
- data/bin/jpp +4 -0
- data/ext/hash.rb +8 -0
- data/lib/jpp.rb +36 -0
- metadata +66 -0
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
jpp
|
2
|
+
===
|
3
|
+
|
4
|
+
**A command-line JSON pretty printer.**
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
Pretty-print responses from web services:
|
10
|
+
|
11
|
+
curl https://api.github.com/users/octocat | jpp
|
12
|
+
|
13
|
+
Or pretty-print JSON from a file:
|
14
|
+
|
15
|
+
jpp file.json
|
16
|
+
|
17
|
+
More usage:
|
18
|
+
|
19
|
+
>> jpp -h benton.porter@bhollis-mbpro
|
20
|
+
Usage: jpp [options] file
|
21
|
+
-s, --sort Sort json alphabetically by key
|
22
|
+
-v, --version Show version
|
23
|
+
|
24
|
+
|
25
|
+
Install
|
26
|
+
-------
|
27
|
+
|
28
|
+
You currently have to clone the repo and build/install the gem.
|
29
|
+
|
30
|
+
git clone git@github.com:bentonporter/jpp.git
|
31
|
+
cd jpp
|
32
|
+
gem build jpp.gemspec && gem install jpp-0.1.gem
|
data/bin/jpp
ADDED
data/ext/hash.rb
ADDED
data/lib/jpp.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'optparse'
|
3
|
+
require 'hash'
|
4
|
+
|
5
|
+
class Jpp
|
6
|
+
VERSION = '0.1'
|
7
|
+
|
8
|
+
def main()
|
9
|
+
options = {}
|
10
|
+
|
11
|
+
parser = OptionParser.new do |opts|
|
12
|
+
opts.banner = 'Usage: jpp [options] file'
|
13
|
+
|
14
|
+
opts.on('-s', '--sort', 'Sort json alphabetically by key') do |s|
|
15
|
+
options[:sort] = s
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on('-v', '--version', 'Show version') do |v|
|
19
|
+
puts VERSION
|
20
|
+
exit
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
begin parser.parse!
|
25
|
+
rescue OptionParser::InvalidOption => message
|
26
|
+
puts message
|
27
|
+
puts parser
|
28
|
+
exit 1
|
29
|
+
end
|
30
|
+
|
31
|
+
input = JSON.load(ARGF.read)
|
32
|
+
input = input.sort_by_key() if options[:sort]
|
33
|
+
output = JSON.pretty_generate(input)
|
34
|
+
puts output
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jpp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben Porter
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: A command-line JSON pretty-printer using the json gem
|
31
|
+
email: benton.porter@gmail.com
|
32
|
+
executables:
|
33
|
+
- jpp
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- bin/jpp
|
38
|
+
- ext/hash.rb
|
39
|
+
- lib/jpp.rb
|
40
|
+
- README.md
|
41
|
+
homepage: https://github.com/bentonporter/jpp
|
42
|
+
licenses: []
|
43
|
+
post_install_message:
|
44
|
+
rdoc_options: []
|
45
|
+
require_paths:
|
46
|
+
- ext
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.8.23
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Command-line JSON pretty-printer
|
66
|
+
test_files: []
|