ppjson 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzI1OTEwNTg4ZDUwYWEwODhiOGEwNDEwYzQxODkzZTIzN2VmNmEzNA==
5
+ data.tar.gz: !binary |-
6
+ OGQ2N2U4Y2I0ODY0NGFhMzRkZmJlMTgzMTYzNDNhNjZjNDEwNDZmYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Y2IwZmZlNjkzMTZjMDBmODFkYjI3NTgwMTBkZjBkMGNmZDA0ZTdlZTA0OGE3
10
+ NGM0NmVhOWEzMDE0MDAxNzQ2YTliNzUzZDM5YWNhZDgzMzMxZDRjNzJhODBj
11
+ Mjg5NGY0ZmY3NGNmOTcwNjNkNDY2OTgzYjViNWI3NWMwYzdmYzc=
12
+ data.tar.gz: !binary |-
13
+ OTAzZjFkZTkxMTBiMGYxM2IwNzI3ZjA2Y2JlYmFlYzJiYTM2M2JkNGQzYzEy
14
+ MDA3MmMyMjFkMDQyMzMzNDZjYjVjMWU0Mzk3YzU2MjhlOTYyNGIyODFiZGE2
15
+ ZjRmNWNlYWMxZTcyOTIzMTZiZTQwMjIyNDY5Y2JmYTY1NTRmMTA=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+
3
+ failed=1
4
+ gemset=ppjson
5
+ rubies="ruby-1.9.3-p362 ruby-1.9.3-p194 ruby-1.9.2-p290 "
6
+
7
+ for ruby in $rubies; do
8
+ rvm use $ruby@$gemset --create 1>/dev/null 2>&1
9
+ if [ $? == 0 ]; then
10
+ echo
11
+ echo ">>" rvm is using $ruby@$gemset
12
+ echo
13
+ failed=0
14
+ break
15
+ fi
16
+ done
17
+
18
+ if [ $failed == 1 ]; then
19
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
+ echo cannot find a ruby runtime in the set: $rubies, please install one
21
+ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22
+ fi
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'escort'
4
+
5
+ # Specify your gem's dependencies in ppjson.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alan Skorkin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Ppjson
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ppjson'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ppjson
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO.txt ADDED
@@ -0,0 +1,9 @@
1
+ - write a decent readme
2
+ - stop using an unreleased escort that points at filesystem
3
+ - try it out when installing at the top level
4
+ - try it out with binstubs in another project
5
+ - think about if it needs any arguments at all
6
+
7
+ - ppjson --file - to read json from a file, format it and spit it out to STDOUT
8
+ - ppjson --file --inline - to read json from a file, format it and overwrite the file with it
9
+ - ppjson --file --backwards - take json from file which is presumably pretty already and unprettify it
data/bin/ppjson ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'escort'
4
+ require 'ppjson'
5
+
6
+ Escort::App.create do |app|
7
+ app.version Ppjson::VERSION
8
+
9
+ app.requires_arguments
10
+
11
+ app.action do |options, arguments|
12
+ Ppson::Commands::PrettyPrintJson.new(options, arguments).execute
13
+ end
14
+ end
data/lib/ppjson.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'yajl'
2
+ require 'yajl/json_gem'
3
+ require 'multi_json'
4
+
5
+ require "ppjson/version"
6
+
7
+ require "ppjson/commands/pretty_print_json"
@@ -0,0 +1,23 @@
1
+ module Ppson
2
+ module Commands
3
+ class PrettyPrintJson < ::Escort::ActionCommand::Base
4
+ def execute
5
+ arguments.each do |argument|
6
+ hash = from_json(argument.to_s)
7
+ $stdout.puts MultiJson.dump(hash, :pretty => true)
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def from_json(json)
14
+ MultiJson.load(json)
15
+ rescue MultiJson::LoadError => e
16
+ $stderr.puts "Invalid JSON string (don't forget to quote your strings e.g. '{\"abc\":\"def\"}'):"
17
+ $stderr.puts e.message
18
+ $stderr.puts "#{json}"
19
+ exit(1)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Ppjson
2
+ VERSION = "0.0.1"
3
+ end
data/ppjson.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ppjson/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ppjson"
8
+ gem.version = Ppjson::VERSION
9
+ gem.authors = ["Alan Skorkin"]
10
+ gem.email = ["alan@skorks.com"]
11
+ gem.summary = %q{Pretty print JSON on the command-line}
12
+ gem.description = %q{Pretty print JSON strings by piping or passing them as arguments, without reordering your keys}
13
+ gem.homepage = "https://github.com/skorks/ppjson"
14
+
15
+
16
+ gem.add_runtime_dependency('escort')
17
+ gem.add_runtime_dependency('yajl-ruby')
18
+ gem.add_runtime_dependency('multi_json')
19
+
20
+ gem.add_development_dependency('rake')
21
+ gem.add_development_dependency('rspec')
22
+
23
+ gem.files = `git ls-files`.split($/)
24
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
25
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
+ gem.require_paths = ["lib"]
27
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ppjson
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alan Skorkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: escort
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: yajl-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Pretty print JSON strings by piping or passing them as arguments, without
84
+ reordering your keys
85
+ email:
86
+ - alan@skorks.com
87
+ executables:
88
+ - ppjson
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - .gitignore
93
+ - .rvmrc
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - TODO.txt
99
+ - bin/ppjson
100
+ - lib/ppjson.rb
101
+ - lib/ppjson/commands/pretty_print_json.rb
102
+ - lib/ppjson/version.rb
103
+ - ppjson.gemspec
104
+ homepage: https://github.com/skorks/ppjson
105
+ licenses: []
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.0
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Pretty print JSON on the command-line
127
+ test_files: []