rack-pretty_json 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.
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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-pretty_json.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Damien Wilson
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,56 @@
1
+ # Rack::PrettyJson
2
+
3
+ Make your json responses PRETTY!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rack-pretty_json', :require => 'rack/pretty_json'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rack-pretty_json
18
+
19
+ ## Usage
20
+
21
+ Simply `require 'rack/pretty_json'` and add `Rack::PrettyJSON` to your
22
+ list of Rack middleware. `Rack::PrettyJSON` will look for any JSON
23
+ encoded responses from your application and pretty them up for you!
24
+
25
+ ## Configuration
26
+
27
+ You can customize the behavior of `Rack::PrettyJSON` by passing it a
28
+ configuration hash in your rackup file or middleware configuration.
29
+
30
+ use Rack::PrettyJSON,
31
+ :always => false,
32
+ :with_paramater => 'pretty'
33
+
34
+ Here's a list of the things you can tweak through the configuration
35
+ hash:
36
+
37
+ * `:always` (boolean, default: false) - if set to true, process all JSON
38
+ responses
39
+ * `:with_paramater` (string, default: 'pretty'): When present as a key in
40
+ a HTTP request's GET query hash, any resulting JSON responses will be
41
+ processed.
42
+
43
+ ## Notes
44
+
45
+ * Currently, `Rack::PrettyJSON` will only handle GET requests. Support
46
+ for JSON responses resulting from HTTP POST requests is planned.
47
+ * RSpec coverage is in progress. You can find a simple test app and
48
+ rackup file in the `spec/support` directory.
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ require "yard"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
8
+
9
+ desc "Run test app"
10
+ task :testapp do
11
+ require "rack"
12
+ Rack::Server.start :config => File.expand_path("./spec/support/pretty_json.ru", File.dirname(__FILE__))
13
+ end
14
+
15
+ YARD::Rake::YardocTask.new do |t|
16
+ t.options = %w(--markup markdown)
17
+ end
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ module PrettyJson
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,79 @@
1
+ require "yajl"
2
+ require "rack"
3
+ require "rack/pretty_json/version"
4
+
5
+ module Rack
6
+
7
+ class PrettyJSON
8
+
9
+ # You can customize the behavior of `Rack::PrettyJSON` with the options hash.
10
+ # @param [#call] app A Rack middleware or endpoint
11
+ # @param [Hash<Symbol => Boolean, String>] options a configuration hash
12
+ def initialize(app, options = {})
13
+ @app = app
14
+ @options = {
15
+ :always => false,
16
+ :with_paramater => 'pretty'
17
+ }.merge(options)
18
+ end
19
+
20
+ def call(env)
21
+ status, headers, body = @app.call(env)
22
+ headers = Rack::Utils::HeaderHash.new(headers)
23
+ query_hash = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
24
+
25
+ # If this is a JSON response..
26
+ if headers['Content-Type'] == 'application/json'
27
+ # AND if ANY of the following are true:
28
+ # - we've been configured to process all JSON responses
29
+ # - pretty json format has been requested
30
+ # - we're in development mode
31
+ if always_process? || requsted_pretty_version?(query_hash) || development?
32
+ body = make_pretty!(body)
33
+ end
34
+ end
35
+
36
+ [status, headers, body]
37
+ end
38
+
39
+ private
40
+ # True if `Rack::PrettyJSON` has been configured to process all JSON responses.
41
+ # @return Boolean
42
+ def always_process?
43
+ @options[:always]
44
+ end
45
+
46
+ # True if our configured request paramater is present in the GET query string
47
+ # @param [Hash] query_hash a Hash representation of the request GET paramaters
48
+ # @return Boolean
49
+ def requsted_pretty_version?(query_hash)
50
+ query_hash.has_key?(@options[:with_paramater])
51
+ end
52
+
53
+ # True if RACK_ENV is set to 'development'
54
+ # @return Boolean
55
+ def development?
56
+ ENV['RACK_ENV'] == 'development'
57
+ end
58
+
59
+ # Takes a JSON string and uses it to generated a nicely formated version of it.
60
+ # @param [String] body a valid JSON string
61
+ # @return #each
62
+ def make_pretty!(body)
63
+ # Convert the response body into a StringIO
64
+ json = StringIO.new
65
+ body.each { |line| json << line }
66
+ json.rewind
67
+
68
+ # Stream our raw data through the parser
69
+ data = Yajl::Parser.parse(json, :pretty => true)
70
+ pretty_json = StringIO.new
71
+ Yajl::Encoder.encode(data, pretty_json, :pretty => true)
72
+ pretty_json.rewind
73
+
74
+ pretty_json
75
+ end
76
+
77
+ end
78
+
79
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rack/pretty_json/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Damien Wilson"]
6
+ gem.email = ["damien@mindglob.com"]
7
+ gem.description = %q{Pretty JSON for pretty people}
8
+ gem.summary = %q{Rack::PrettyJSON reformats JSON responses for easier readability.}
9
+ gem.homepage = "https://www.github.com/damien/rack-pretty_json/"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "rack-pretty_json"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Rack::PrettyJson::VERSION
17
+
18
+ gem.add_dependency "rack", "~> 1.4.1"
19
+ gem.add_dependency "yajl-ruby", "~> 1.1.0"
20
+
21
+ gem.add_development_dependency "rake"
22
+ gem.add_development_dependency "rspec"
23
+ gem.add_development_dependency "yard"
24
+ gem.add_development_dependency "redcarpet"
25
+ end
@@ -0,0 +1,11 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper.rb"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+ end
@@ -0,0 +1,22 @@
1
+ $:.unshift File.expand_path("../../../lib/", __FILE__)
2
+
3
+ require "rack"
4
+ require "rack/pretty_json"
5
+ require "stringio"
6
+
7
+ module TestApp
8
+
9
+ def self.call(env)
10
+ status = 200
11
+ headers = {"Content-Type" => "application/json"}
12
+ body = <<-END
13
+ [{"parentid":23424900,"woeid":116545,"countryCode":"MX","name":"Mexico City","country":"Mexico","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/116545"},{"woeid":2428184,"countryCode":"US","name":"Jackson","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2428184"},{"woeid":15015372,"countryCode":"JP","name":"Kyoto","country":"Japan","placeType":{"name":"Town","code":7},"parentid":23424856,"url":"http:\/\/where.yahooapis.com\/v1\/place\/15015372"},{"woeid":2122541,"countryCode":"RU","name":"Novosibirsk","country":"Russia","placeType":{"name":"Town","code":7},"parentid":23424936,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2122541"},{"woeid":2459115,"countryCode":"US","name":"New York","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2459115"},{"woeid":2503713,"countryCode":"US","name":"Tallahassee","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2503713"},{"woeid":2460389,"countryCode":"US","placeType":{"name":"Town","code":7},"name":"Norfolk","country":"United States","parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2460389"},{"woeid":2452078,"countryCode":"US","name":"Minneapolis","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2452078"},{"woeid":2344116,"countryCode":"TR","name":"Istanbul","country":"Turkey","placeType":{"name":"Town","code":7},"parentid":23424969,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2344116"},{"woeid":23424748,"countryCode":"AU","name":"Australia","country":"Australia","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424748"},{"woeid":2471217,"countryCode":"US","name":"Philadelphia","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2471217"},{"woeid":2381475,"countryCode":"US","name":"Cleveland","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2381475"},{"parentid":23424856,"name":"Fukuoka","country":"Japan","url":"http:\/\/where.yahooapis.com\/v1\/place\/1117099","woeid":1117099,"countryCode":"JP","placeType":{"name":"Town","code":7}},{"woeid":23424768,"countryCode":"BR","name":"Brazil","country":"Brazil","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424768"},{"woeid":2343732,"countryCode":"TR","name":"Ankara","country":"Turkey","placeType":{"name":"Town","code":7},"parentid":23424969,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2343732"},{"parentid":23424977,"name":"Phoenix","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2471390","woeid":2471390,"countryCode":"US","placeType":{"name":"Town","code":7}},{"name":"Orlando","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2466256","placeType":{"name":"Town","code":7},"woeid":2466256,"parentid":23424977,"countryCode":"US"},{"name":"Santo Domingo","country":"Dominican Republic","url":"http:\/\/where.yahooapis.com\/v1\/place\/76456","placeType":{"name":"Town","code":7},"woeid":76456,"parentid":23424800,"countryCode":"DO"},{"woeid":349859,"countryCode":"CL","placeType":{"name":"Town","code":7},"name":"Santiago","country":"Chile","parentid":23424782,"url":"http:\/\/where.yahooapis.com\/v1\/place\/349859"},{"placeType":{"name":"Town","code":7},"woeid":2344117,"countryCode":"TR","name":"Izmir","parentid":23424969,"country":"Turkey","url":"http:\/\/where.yahooapis.com\/v1\/place\/2344117"},{"woeid":23424775,"countryCode":"CA","placeType":{"name":"Country","code":12},"name":"Canada","country":"Canada","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424775"},{"name":"Las Vegas","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2436704","woeid":2436704,"countryCode":"US","placeType":{"name":"Town","code":7},"parentid":23424977},{"woeid":455825,"countryCode":"BR","name":"Rio de Janeiro","country":"Brazil","placeType":{"name":"Town","code":7},"parentid":23424768,"url":"http:\/\/where.yahooapis.com\/v1\/place\/455825"},{"woeid":23424803,"countryCode":"IE","placeType":{"name":"Country","code":12},"name":"Ireland","country":"Ireland","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424803"},{"placeType":{"name":"Town","code":7},"woeid":2345896,"countryCode":"JP","name":"Okinawa","parentid":23424856,"country":"Japan","url":"http:\/\/where.yahooapis.com\/v1\/place\/2345896"},{"woeid":368148,"countryCode":"CO","name":"Bogot\u00e1","country":"Colombia","placeType":{"name":"Town","code":7},"parentid":23424787,"url":"http:\/\/where.yahooapis.com\/v1\/place\/368148"},{"parentid":1,"name":"Germany","country":"Germany","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424829","woeid":23424829,"countryCode":"DE","placeType":{"name":"Country","code":12}},{"woeid":23424853,"countryCode":"IT","placeType":{"name":"Country","code":12},"name":"Italy","country":"Italy","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424853"},{"name":"Sacramento","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2486340","woeid":2486340,"countryCode":"US","placeType":{"name":"Town","code":7},"parentid":23424977},{"woeid":1118285,"countryCode":"JP","name":"Takamatsu","country":"Japan","placeType":{"name":"Town","code":7},"parentid":23424856,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1118285"},{"woeid":23424975,"countryCode":"GB","name":"United Kingdom","country":"United Kingdom","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424975"},{"parentid":23424977,"woeid":2378426,"countryCode":"US","name":"Charlotte","country":"United States","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2378426"},{"woeid":733075,"countryCode":"NL","placeType":{"name":"Town","code":7},"name":"Rotterdam","country":"Netherlands","parentid":23424909,"url":"http:\/\/where.yahooapis.com\/v1\/place\/733075"},{"woeid":1,"countryCode":null,"name":"Worldwide","country":"","placeType":{"name":"Supername","code":19},"url":"http:\/\/where.yahooapis.com\/v1\/place\/1"},{"name":"San Antonio","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2487796","woeid":2487796,"countryCode":"US","placeType":{"name":"Town","code":7},"parentid":23424977},{"woeid":726874,"countryCode":"NL","name":"Den Haag","country":"Netherlands","placeType":{"name":"Town","code":7},"parentid":23424909,"url":"http:\/\/where.yahooapis.com\/v1\/place\/726874"},{"woeid":23424977,"countryCode":"US","name":"United States","country":"United States","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424977"},{"woeid":2473224,"countryCode":"US","name":"Pittsburgh","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2473224"},{"woeid":2487956,"countryCode":"US","placeType":{"name":"Town","code":7},"name":"San Francisco","country":"United States","parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2487956"},{"parentid":23424846,"name":"Surabaya","country":"Indonesia","url":"http:\/\/where.yahooapis.com\/v1\/place\/1044316","woeid":1044316,"countryCode":"ID","placeType":{"name":"Town","code":7}},{"parentid":1,"woeid":23424969,"countryCode":"TR","name":"Turkey","country":"Turkey","placeType":{"name":"Country","code":12},"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424969"},{"parentid":23424977,"woeid":2442047,"countryCode":"US","name":"Los Angeles","country":"United States","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2442047"},{"placeType":{"name":"Town","code":7},"name":"Harrisburg","parentid":23424977,"country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2418046","woeid":2418046,"countryCode":"US"},{"parentid":23424748,"name":"Sydney","country":"Australia","url":"http:\/\/where.yahooapis.com\/v1\/place\/1105779","woeid":1105779,"countryCode":"AU","placeType":{"name":"Town","code":7}},{"name":"Lagos","country":"Nigeria","url":"http:\/\/where.yahooapis.com\/v1\/place\/1398823","woeid":1398823,"countryCode":"NG","placeType":{"name":"Town","code":7},"parentid":23424908},{"woeid":1030077,"countryCode":"ID","name":"Bekasi","country":"Indonesia","placeType":{"name":"Town","code":7},"parentid":23424846,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1030077"},{"woeid":2457170,"countryCode":"US","name":"Nashville","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2457170"},{"parentid":23424775,"name":"Toronto","country":"Canada","url":"http:\/\/where.yahooapis.com\/v1\/place\/4118","woeid":4118,"countryCode":"CA","placeType":{"name":"Town","code":7}},{"woeid":395272,"countryCode":"VE","name":"Valencia","country":"Venezuela","placeType":{"name":"Town","code":7},"parentid":23424982,"url":"http:\/\/where.yahooapis.com\/v1\/place\/395272"},{"woeid":2490383,"countryCode":"US","name":"Seattle","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2490383"},{"woeid":468739,"countryCode":"AR","name":"Buenos Aires","country":"Argentina","placeType":{"name":"Town","code":7},"parentid":23424747,"url":"http:\/\/where.yahooapis.com\/v1\/place\/468739"},{"woeid":20070458,"countryCode":"IN","name":"Delhi","country":"India","placeType":{"name":"Town","code":7},"parentid":23424848,"url":"http:\/\/where.yahooapis.com\/v1\/place\/20070458"},{"woeid":418440,"countryCode":"PE","name":"Lima","country":"Peru","placeType":{"name":"Town","code":7},"parentid":23424919,"url":"http:\/\/where.yahooapis.com\/v1\/place\/418440"},{"name":"Washington","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2514815","woeid":2514815,"countryCode":"US","placeType":{"name":"Town","code":7},"parentid":23424977},{"placeType":{"name":"Town","code":7},"name":"Maracaibo","parentid":23424982,"country":"Venezuela","url":"http:\/\/where.yahooapis.com\/v1\/place\/395270","woeid":395270,"countryCode":"VE"},{"woeid":455827,"countryCode":"BR","name":"S\u00e3o Paulo","country":"Brazil","placeType":{"name":"Town","code":7},"parentid":23424768,"url":"http:\/\/where.yahooapis.com\/v1\/place\/455827"},{"parentid":23424848,"woeid":2295420,"countryCode":"IN","name":"Bangalore","country":"India","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2295420"},{"woeid":12723,"countryCode":"GB","name":"Birmingham","country":"United Kingdom","placeType":{"name":"Town","code":7},"parentid":23424975,"url":"http:\/\/where.yahooapis.com\/v1\/place\/12723"},{"woeid":23424909,"countryCode":"NL","name":"Netherlands","country":"Netherlands","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424909"},{"parentid":23424977,"woeid":2359991,"countryCode":"US","name":"Baton Rouge","country":"United States","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2359991"},{"woeid":23424800,"countryCode":"DO","name":"Dominican Republic","country":"Dominican Republic","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424800"},{"name":"Argentina","country":"Argentina","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424747","woeid":23424747,"countryCode":"AR","placeType":{"name":"Country","code":12},"parentid":1},{"woeid":2295414,"countryCode":"IN","name":"Hyderabad","country":"India","placeType":{"name":"Town","code":7},"parentid":23424848,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2295414"},{"woeid":2364559,"countryCode":"US","name":"Birmingham","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2364559"},{"woeid":23424819,"countryCode":"FR","name":"France","country":"France","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424819"},{"parentid":1,"name":"Nigeria","country":"Nigeria","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424908","woeid":23424908,"countryCode":"NG","placeType":{"name":"Country","code":12}},{"woeid":23424782,"countryCode":"CL","name":"Chile","country":"Chile","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424782"},{"woeid":2414469,"countryCode":"US","name":"Greensboro","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2414469"},{"parentid":23424848,"name":"Ahmedabad","country":"India","url":"http:\/\/where.yahooapis.com\/v1\/place\/2295402","woeid":2295402,"countryCode":"IN","placeType":{"name":"Town","code":7}},{"parentid":23424900,"name":"Monterrey","country":"Mexico","url":"http:\/\/where.yahooapis.com\/v1\/place\/134047","woeid":134047,"countryCode":"MX","placeType":{"name":"Town","code":7}},{"name":"Caracas","country":"Venezuela","url":"http:\/\/where.yahooapis.com\/v1\/place\/395269","woeid":395269,"countryCode":"VE","placeType":{"name":"Town","code":7},"parentid":23424982},{"woeid":15015370,"countryCode":"JP","name":"Osaka","country":"Japan","placeType":{"name":"Town","code":7},"parentid":23424856,"url":"http:\/\/where.yahooapis.com\/v1\/place\/15015370"},{"parentid":23424975,"name":"Glasgow","country":"United Kingdom","url":"http:\/\/where.yahooapis.com\/v1\/place\/21125","woeid":21125,"countryCode":"GB","placeType":{"name":"Town","code":7}},{"woeid":23424950,"countryCode":"ES","name":"Spain","country":"Spain","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424950"},{"woeid":2480894,"countryCode":"US","name":"Richmond","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2480894"},{"woeid":2295424,"countryCode":"IN","name":"Chennai","country":"India","placeType":{"name":"Town","code":7},"parentid":23424848,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2295424"},{"name":"South Africa","country":"South Africa","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424942","woeid":23424942,"countryCode":"ZA","placeType":{"name":"Country","code":12},"parentid":1},{"woeid":2357536,"countryCode":"US","name":"Austin","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2357536"},{"woeid":23424934,"countryCode":"PH","name":"Philippines","country":"Philippines","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424934"},{"woeid":2427032,"countryCode":"US","name":"Indianapolis","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2427032"},{"placeType":{"name":"Country","code":12},"name":"Indonesia","parentid":1,"country":"Indonesia","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424846","woeid":23424846,"countryCode":"ID"},{"woeid":2458833,"countryCode":"US","name":"New Orleans","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2458833"},{"parentid":1,"woeid":23424919,"countryCode":"PE","name":"Peru","country":"Peru","placeType":{"name":"Country","code":12},"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424919"},{"parentid":23424977,"name":"Milwaukee","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2451822","woeid":2451822,"countryCode":"US","placeType":{"name":"Town","code":7}},{"woeid":23424787,"countryCode":"CO","name":"Colombia","country":"Colombia","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424787"},{"name":"Mexico","country":"Mexico","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424900","placeType":{"name":"Country","code":12},"woeid":23424900,"parentid":1,"countryCode":"MX"},{"woeid":1154726,"countryCode":"MY","name":"Klang","country":"Malaysia","placeType":{"name":"Town","code":7},"parentid":23424901,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1154726"},{"woeid":2380358,"countryCode":"US","name":"Cincinnati","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2380358"},{"parentid":1,"woeid":23424916,"countryCode":"NZ","name":"New Zealand","country":"New Zealand","placeType":{"name":"Country","code":12},"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424916"},{"woeid":1199682,"countryCode":"PH","placeType":{"name":"Town","code":7},"name":"Quezon City","country":"Philippines","parentid":23424934,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1199682"},{"woeid":23424738,"countryCode":"AE","name":"United Arab Emirates","country":"United Arab Emirates","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424738"},{"name":"Jakarta","country":"Indonesia","url":"http:\/\/where.yahooapis.com\/v1\/place\/1047378","woeid":1047378,"countryCode":"ID","placeType":{"name":"Town","code":7},"parentid":23424846},{"woeid":1118129,"countryCode":"JP","name":"Sendai","country":"Japan","placeType":{"name":"Town","code":7},"parentid":23424856,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1118129"},{"parentid":23424848,"woeid":2295411,"countryCode":"IN","name":"Mumbai","country":"India","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2295411"},{"woeid":468382,"countryCode":"VE","name":"Barquisimeto","country":"Venezuela","placeType":{"name":"Town","code":7},"parentid":23424982,"url":"http:\/\/where.yahooapis.com\/v1\/place\/468382"},{"woeid":1199477,"countryCode":"PH","name":"Manila","country":"Philippines","placeType":{"name":"Town","code":7},"parentid":23424934,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1199477"},{"woeid":638242,"countryCode":"DE","name":"Berlin","country":"Germany","placeType":{"name":"Town","code":7},"parentid":23424829,"url":"http:\/\/where.yahooapis.com\/v1\/place\/638242"},{"woeid":906057,"countryCode":"SE","name":"Stockholm","country":"Sweden","placeType":{"name":"Town","code":7},"parentid":23424954,"url":"http:\/\/where.yahooapis.com\/v1\/place\/906057"},{"parentid":1,"name":"Venezuela","country":"Venezuela","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424982","woeid":23424982,"countryCode":"VE","placeType":{"name":"Country","code":12}},{"woeid":23424948,"countryCode":"SG","placeType":{"name":"Country","code":12},"name":"Singapore","country":"Singapore","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424948"},{"woeid":656958,"countryCode":"DE","placeType":{"name":"Town","code":7},"name":"Hamburg","country":"Germany","parentid":23424829,"url":"http:\/\/where.yahooapis.com\/v1\/place\/656958"},{"woeid":2477058,"countryCode":"US","name":"Providence","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2477058"},{"woeid":23424922,"countryCode":"PK","name":"Pakistan","country":"Pakistan","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424922"},{"woeid":23424801,"countryCode":"EC","placeType":{"name":"Country","code":12},"name":"Ecuador","country":"Ecuador","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424801"},{"parentid":23424977,"woeid":2357024,"countryCode":"US","name":"Atlanta","country":"United States","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2357024"},{"parentid":23424829,"name":"Munich","country":"Germany","url":"http:\/\/where.yahooapis.com\/v1\/place\/676757","woeid":676757,"countryCode":"DE","placeType":{"name":"Town","code":7}},{"woeid":2358820,"countryCode":"US","name":"Baltimore","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2358820"},{"woeid":615702,"countryCode":"FR","placeType":{"name":"Town","code":7},"name":"Paris","country":"France","parentid":23424819,"url":"http:\/\/where.yahooapis.com\/v1\/place\/615702"},{"woeid":2383660,"countryCode":"US","placeType":{"name":"Town","code":7},"name":"Columbus","country":"United States","parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2383660"},{"woeid":560743,"countryCode":"IE","name":"Dublin","country":"Ireland","placeType":{"name":"Town","code":7},"parentid":23424803,"url":"http:\/\/where.yahooapis.com\/v1\/place\/560743"},{"woeid":2367105,"countryCode":"US","name":"Boston","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2367105"},{"woeid":610264,"countryCode":"FR","name":"Marseille","country":"France","placeType":{"name":"Town","code":7},"parentid":23424819,"url":"http:\/\/where.yahooapis.com\/v1\/place\/610264"},{"woeid":2487610,"countryCode":"US","name":"Salt Lake City","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2487610"},{"woeid":9807,"countryCode":"CA","name":"Vancouver","country":"Canada","placeType":{"name":"Town","code":7},"parentid":23424775,"url":"http:\/\/where.yahooapis.com\/v1\/place\/9807"},{"woeid":609125,"countryCode":"FR","name":"Lyon","country":"France","placeType":{"name":"Town","code":7},"parentid":23424819,"url":"http:\/\/where.yahooapis.com\/v1\/place\/609125"},{"woeid":3534,"countryCode":"CA","name":"Montreal","country":"Canada","placeType":{"name":"Town","code":7},"parentid":23424775,"url":"http:\/\/where.yahooapis.com\/v1\/place\/3534"},{"woeid":2487889,"countryCode":"US","name":"San Diego","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2487889"},{"woeid":2379574,"countryCode":"US","name":"Chicago","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2379574"},{"woeid":2475687,"countryCode":"US","name":"Portland","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2475687"},{"woeid":455826,"countryCode":"BR","name":"Salvador","country":"Brazil","placeType":{"name":"Town","code":7},"parentid":23424768,"url":"http:\/\/where.yahooapis.com\/v1\/place\/455826"},{"woeid":23424954,"countryCode":"SE","name":"Sweden","country":"Sweden","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424954"},{"woeid":727232,"countryCode":"NL","placeType":{"name":"Town","code":7},"name":"Amsterdam","country":"Netherlands","parentid":23424909,"url":"http:\/\/where.yahooapis.com\/v1\/place\/727232"},{"woeid":455830,"countryCode":"BR","name":"Fortaleza","country":"Brazil","placeType":{"name":"Town","code":7},"parentid":23424768,"url":"http:\/\/where.yahooapis.com\/v1\/place\/455830"},{"parentid":23424977,"woeid":2388929,"countryCode":"US","name":"Dallas-Ft. Worth","country":"United States","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/2388929"},{"woeid":1582504,"countryCode":"ZA","placeType":{"name":"Town","code":7},"name":"Johannesburg","country":"South Africa","parentid":23424942,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1582504"},{"woeid":455819,"countryCode":"BR","name":"Bras\u00edlia","country":"Brazil","placeType":{"name":"Town","code":7},"parentid":23424768,"url":"http:\/\/where.yahooapis.com\/v1\/place\/455819"},{"placeType":{"name":"Town","code":7},"name":"Tokyo","parentid":23424856,"country":"Japan","url":"http:\/\/where.yahooapis.com\/v1\/place\/1118370","woeid":1118370,"countryCode":"JP"},{"woeid":1047180,"countryCode":"ID","placeType":{"name":"Town","code":7},"name":"Bandung","country":"Indonesia","parentid":23424846,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1047180"},{"name":"Denver","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2391279","woeid":2391279,"countryCode":"US","placeType":{"name":"Town","code":7},"parentid":23424977},{"woeid":455833,"countryCode":"BR","name":"Manaus","country":"Brazil","placeType":{"name":"Town","code":7},"parentid":23424768,"url":"http:\/\/where.yahooapis.com\/v1\/place\/455833"},{"woeid":2503863,"countryCode":"US","name":"Tampa","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2503863"},{"woeid":23424848,"countryCode":"IN","placeType":{"name":"Country","code":12},"name":"India","country":"India","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424848"},{"woeid":23424856,"countryCode":"JP","placeType":{"name":"Country","code":12},"name":"Japan","country":"Japan","parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424856"},{"parentid":23424977,"name":"Detroit","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2391585","woeid":2391585,"countryCode":"US","placeType":{"name":"Town","code":7}},{"woeid":2458410,"countryCode":"US","placeType":{"name":"Town","code":7},"name":"New Haven","country":"United States","parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2458410"},{"placeType":{"name":"Country","code":12},"name":"Guatemala","parentid":1,"country":"Guatemala","url":"http:\/\/where.yahooapis.com\/v1\/place\/23424834","woeid":23424834,"countryCode":"GT"},{"woeid":1117817,"countryCode":"JP","name":"Nagoya","country":"Japan","placeType":{"name":"Town","code":7},"parentid":23424856,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1117817"},{"placeType":{"name":"Town","code":7},"name":"Barcelona","parentid":23424950,"country":"Spain","url":"http:\/\/where.yahooapis.com\/v1\/place\/753692","woeid":753692,"countryCode":"ES"},{"woeid":2478307,"countryCode":"US","name":"Raleigh","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2478307"},{"woeid":1154781,"countryCode":"MY","placeType":{"name":"Town","code":7},"name":"Kuala Lumpur","country":"Malaysia","parentid":23424901,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1154781"},{"woeid":23424901,"countryCode":"MY","name":"Malaysia","country":"Malaysia","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424901"},{"woeid":2424766,"countryCode":"US","name":"Houston","country":"United States","placeType":{"name":"Town","code":7},"parentid":23424977,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2424766"},{"parentid":23424977,"name":"Memphis","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2449323","woeid":2449323,"countryCode":"US","placeType":{"name":"Town","code":7}},{"parentid":23424950,"woeid":766273,"countryCode":"ES","name":"Madrid","country":"Spain","placeType":{"name":"Town","code":7},"url":"http:\/\/where.yahooapis.com\/v1\/place\/766273"},{"woeid":23424936,"countryCode":"RU","name":"Russia","country":"Russia","placeType":{"name":"Country","code":12},"parentid":1,"url":"http:\/\/where.yahooapis.com\/v1\/place\/23424936"},{"woeid":28218,"countryCode":"GB","placeType":{"name":"Town","code":7},"name":"Manchester","country":"United Kingdom","parentid":23424975,"url":"http:\/\/where.yahooapis.com\/v1\/place\/28218"},{"placeType":{"name":"Town","code":7},"name":"St. Louis","parentid":23424977,"country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2486982","woeid":2486982,"countryCode":"US"},{"woeid":2122265,"countryCode":"RU","name":"Moscow","country":"Russia","placeType":{"name":"Town","code":7},"parentid":23424936,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2122265"},{"woeid":1118108,"countryCode":"JP","name":"Sapporo","country":"Japan","placeType":{"name":"Town","code":7},"parentid":23424856,"url":"http:\/\/where.yahooapis.com\/v1\/place\/1118108"},{"woeid":44418,"countryCode":"GB","placeType":{"name":"Town","code":7},"name":"London","country":"United Kingdom","parentid":23424975,"url":"http:\/\/where.yahooapis.com\/v1\/place\/44418"},{"woeid":2450022,"parentid":23424977,"countryCode":"US","name":"Miami","country":"United States","url":"http:\/\/where.yahooapis.com\/v1\/place\/2450022","placeType":{"name":"Town","code":7}},{"woeid":2123260,"countryCode":"RU","name":"Saint Petersburg","country":"Russia","placeType":{"name":"Town","code":7},"parentid":23424936,"url":"http:\/\/where.yahooapis.com\/v1\/place\/2123260"}]
14
+ END
15
+
16
+ [status, headers, [body]]
17
+ end
18
+
19
+ end
20
+
21
+ use Rack::PrettyJSON
22
+ run TestApp
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-pretty_json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Damien Wilson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rack
16
+ requirement: &70123843120320 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70123843120320
25
+ - !ruby/object:Gem::Dependency
26
+ name: yajl-ruby
27
+ requirement: &70123843119320 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70123843119320
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70123843118600 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70123843118600
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70123843117780 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70123843117780
58
+ - !ruby/object:Gem::Dependency
59
+ name: yard
60
+ requirement: &70123843116840 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70123843116840
69
+ - !ruby/object:Gem::Dependency
70
+ name: redcarpet
71
+ requirement: &70123843116280 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70123843116280
80
+ description: Pretty JSON for pretty people
81
+ email:
82
+ - damien@mindglob.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - .rspec
89
+ - .yardopts
90
+ - Gemfile
91
+ - LICENSE
92
+ - README.md
93
+ - Rakefile
94
+ - lib/rack/pretty_json.rb
95
+ - lib/rack/pretty_json/version.rb
96
+ - rack-pretty_json.gemspec
97
+ - spec/spec_helper.rb
98
+ - spec/support/pretty_json.ru
99
+ homepage: https://www.github.com/damien/rack-pretty_json/
100
+ licenses: []
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ! '>='
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 1.8.17
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Rack::PrettyJSON reformats JSON responses for easier readability.
123
+ test_files:
124
+ - spec/spec_helper.rb
125
+ - spec/support/pretty_json.ru
126
+ has_rdoc: