scout 5.7.1 → 5.7.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +5 -0
- data/lib/scout/command/run.rb +1 -1
- data/lib/scout/server.rb +2 -1
- data/lib/scout/streamer.rb +3 -2
- data/lib/scout/streamer_daemon.rb +4 -4
- data/lib/scout/version.rb +1 -1
- data/test/scout_test.rb +7 -8
- data/vendor/httpclient/README.txt +759 -0
- data/vendor/httpclient/bin/httpclient +65 -0
- data/vendor/httpclient/lib/hexdump.rb +50 -0
- data/vendor/httpclient/lib/http-access2.rb +55 -0
- data/vendor/httpclient/lib/http-access2/cookie.rb +1 -0
- data/vendor/httpclient/lib/http-access2/http.rb +1 -0
- data/vendor/httpclient/lib/httpclient.rb +1156 -0
- data/vendor/httpclient/lib/httpclient/auth.rb +899 -0
- data/vendor/httpclient/lib/httpclient/cacert.p7s +1912 -0
- data/vendor/httpclient/lib/httpclient/connection.rb +88 -0
- data/vendor/httpclient/lib/httpclient/cookie.rb +438 -0
- data/vendor/httpclient/lib/httpclient/http.rb +1046 -0
- data/vendor/httpclient/lib/httpclient/include_client.rb +83 -0
- data/vendor/httpclient/lib/httpclient/session.rb +1025 -0
- data/vendor/httpclient/lib/httpclient/ssl_config.rb +403 -0
- data/vendor/httpclient/lib/httpclient/timeout.rb +140 -0
- data/vendor/httpclient/lib/httpclient/util.rb +178 -0
- data/vendor/httpclient/lib/httpclient/version.rb +3 -0
- data/vendor/httpclient/lib/oauthclient.rb +110 -0
- data/vendor/httpclient/sample/async.rb +8 -0
- data/vendor/httpclient/sample/auth.rb +11 -0
- data/vendor/httpclient/sample/cookie.rb +18 -0
- data/vendor/httpclient/sample/dav.rb +103 -0
- data/vendor/httpclient/sample/howto.rb +49 -0
- data/vendor/httpclient/sample/oauth_buzz.rb +57 -0
- data/vendor/httpclient/sample/oauth_friendfeed.rb +59 -0
- data/vendor/httpclient/sample/oauth_salesforce_10.rb +63 -0
- data/vendor/httpclient/sample/oauth_twitter.rb +61 -0
- data/vendor/httpclient/sample/ssl/0cert.pem +22 -0
- data/vendor/httpclient/sample/ssl/0key.pem +30 -0
- data/vendor/httpclient/sample/ssl/1000cert.pem +19 -0
- data/vendor/httpclient/sample/ssl/1000key.pem +18 -0
- data/vendor/httpclient/sample/ssl/htdocs/index.html +10 -0
- data/vendor/httpclient/sample/ssl/ssl_client.rb +22 -0
- data/vendor/httpclient/sample/ssl/webrick_httpsd.rb +29 -0
- data/vendor/httpclient/sample/stream.rb +21 -0
- data/vendor/httpclient/sample/thread.rb +27 -0
- data/vendor/httpclient/sample/wcat.rb +21 -0
- data/vendor/httpclient/test/ca-chain.cert +44 -0
- data/vendor/httpclient/test/ca.cert +23 -0
- data/vendor/httpclient/test/client.cert +19 -0
- data/vendor/httpclient/test/client.key +15 -0
- data/vendor/httpclient/test/helper.rb +129 -0
- data/vendor/httpclient/test/htdigest +1 -0
- data/vendor/httpclient/test/htpasswd +2 -0
- data/vendor/httpclient/test/runner.rb +2 -0
- data/vendor/httpclient/test/server.cert +19 -0
- data/vendor/httpclient/test/server.key +15 -0
- data/vendor/httpclient/test/sslsvr.rb +65 -0
- data/vendor/httpclient/test/subca.cert +21 -0
- data/vendor/httpclient/test/test_auth.rb +321 -0
- data/vendor/httpclient/test/test_cookie.rb +391 -0
- data/vendor/httpclient/test/test_hexdump.rb +14 -0
- data/vendor/httpclient/test/test_http-access2.rb +507 -0
- data/vendor/httpclient/test/test_httpclient.rb +1783 -0
- data/vendor/httpclient/test/test_include_client.rb +52 -0
- data/vendor/httpclient/test/test_ssl.rb +235 -0
- data/vendor/multi_json/.document +5 -0
- data/vendor/multi_json/.rspec +3 -0
- data/vendor/multi_json/.travis.yml +11 -0
- data/vendor/multi_json/.yardopts +6 -0
- data/vendor/multi_json/CHANGELOG.md +169 -0
- data/vendor/multi_json/CONTRIBUTING.md +46 -0
- data/vendor/multi_json/Gemfile +31 -0
- data/vendor/multi_json/LICENSE.md +20 -0
- data/vendor/multi_json/README.md +109 -0
- data/vendor/multi_json/Rakefile +12 -0
- data/vendor/multi_json/lib/multi_json.rb +157 -0
- data/vendor/multi_json/lib/multi_json/adapter.rb +48 -0
- data/vendor/multi_json/lib/multi_json/adapters/gson.rb +19 -0
- data/vendor/multi_json/lib/multi_json/adapters/jr_jackson.rb +19 -0
- data/vendor/multi_json/lib/multi_json/adapters/json_common.rb +25 -0
- data/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +11 -0
- data/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +11 -0
- data/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +34 -0
- data/vendor/multi_json/lib/multi_json/adapters/oj.rb +24 -0
- data/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +22 -0
- data/vendor/multi_json/lib/multi_json/adapters/yajl.rb +19 -0
- data/vendor/multi_json/lib/multi_json/convertible_hash_keys.rb +43 -0
- data/vendor/multi_json/lib/multi_json/load_error.rb +11 -0
- data/vendor/multi_json/lib/multi_json/options.rb +48 -0
- data/vendor/multi_json/lib/multi_json/vendor/okjson.rb +606 -0
- data/vendor/multi_json/lib/multi_json/version.rb +20 -0
- data/vendor/multi_json/multi_json.gemspec +22 -0
- data/vendor/multi_json/spec/adapter_shared_example.rb +235 -0
- data/vendor/multi_json/spec/has_options.rb +119 -0
- data/vendor/multi_json/spec/helper.rb +35 -0
- data/vendor/multi_json/spec/json_common_shared_example.rb +30 -0
- data/vendor/multi_json/spec/multi_json_spec.rb +226 -0
- data/vendor/{signature → pusher}/.document +0 -0
- data/vendor/{json_pure/diagrams/.keep → pusher/.gemtest} +0 -0
- data/vendor/pusher/.gitignore +23 -0
- data/vendor/pusher/.travis.yml +15 -0
- data/vendor/pusher/Gemfile +2 -0
- data/vendor/{pusher-gem → pusher}/LICENSE +1 -1
- data/vendor/pusher/README.md +186 -0
- data/vendor/{pusher-gem → pusher}/Rakefile +0 -0
- data/vendor/{pusher-gem → pusher}/examples/async_message.rb +0 -0
- data/vendor/pusher/lib/pusher.rb +60 -0
- data/vendor/{pusher-gem → pusher}/lib/pusher/channel.rb +47 -54
- data/vendor/pusher/lib/pusher/client.rb +306 -0
- data/vendor/pusher/lib/pusher/request.rb +107 -0
- data/vendor/pusher/lib/pusher/resource.rb +36 -0
- data/vendor/pusher/lib/pusher/webhook.rb +110 -0
- data/vendor/{pusher-gem → pusher}/pusher.gemspec +6 -5
- data/vendor/pusher/spec/channel_spec.rb +127 -0
- data/vendor/pusher/spec/client_spec.rb +464 -0
- data/vendor/{pusher-gem → pusher}/spec/spec_helper.rb +12 -0
- data/vendor/pusher/spec/web_hook_spec.rb +117 -0
- data/vendor/signature/.travis.yml +15 -0
- data/vendor/signature/Gemfile +1 -1
- data/vendor/signature/README.md +38 -28
- data/vendor/signature/lib/signature.rb +97 -15
- data/vendor/signature/lib/signature/query_encoder.rb +47 -0
- data/vendor/signature/lib/signature/version.rb +1 -1
- data/vendor/signature/signature.gemspec +3 -2
- data/vendor/signature/spec/signature_spec.rb +164 -55
- data/vendor/signature/spec/spec_helper.rb +2 -3
- metadata +120 -145
- data/vendor/json_pure/.gitignore +0 -12
- data/vendor/json_pure/.travis.yml +0 -20
- data/vendor/json_pure/CHANGES +0 -282
- data/vendor/json_pure/COPYING +0 -58
- data/vendor/json_pure/COPYING-json-jruby +0 -57
- data/vendor/json_pure/GPL +0 -340
- data/vendor/json_pure/Gemfile +0 -11
- data/vendor/json_pure/README-json-jruby.markdown +0 -33
- data/vendor/json_pure/README.rdoc +0 -358
- data/vendor/json_pure/Rakefile +0 -412
- data/vendor/json_pure/TODO +0 -1
- data/vendor/json_pure/VERSION +0 -1
- data/vendor/json_pure/data/example.json +0 -1
- data/vendor/json_pure/data/index.html +0 -38
- data/vendor/json_pure/data/prototype.js +0 -4184
- data/vendor/json_pure/ext/json/ext/fbuffer/fbuffer.h +0 -181
- data/vendor/json_pure/ext/json/ext/generator/depend +0 -1
- data/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -14
- data/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1435
- data/vendor/json_pure/ext/json/ext/generator/generator.h +0 -148
- data/vendor/json_pure/ext/json/ext/parser/depend +0 -1
- data/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -13
- data/vendor/json_pure/ext/json/ext/parser/parser.c +0 -2204
- data/vendor/json_pure/ext/json/ext/parser/parser.h +0 -77
- data/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -927
- data/vendor/json_pure/install.rb +0 -23
- data/vendor/json_pure/java/src/json/ext/ByteListTranscoder.java +0 -167
- data/vendor/json_pure/java/src/json/ext/Generator.java +0 -444
- data/vendor/json_pure/java/src/json/ext/GeneratorMethods.java +0 -232
- data/vendor/json_pure/java/src/json/ext/GeneratorService.java +0 -43
- data/vendor/json_pure/java/src/json/ext/GeneratorState.java +0 -543
- data/vendor/json_pure/java/src/json/ext/OptionsReader.java +0 -114
- data/vendor/json_pure/java/src/json/ext/Parser.java +0 -2644
- data/vendor/json_pure/java/src/json/ext/Parser.rl +0 -968
- data/vendor/json_pure/java/src/json/ext/ParserService.java +0 -35
- data/vendor/json_pure/java/src/json/ext/RuntimeInfo.java +0 -121
- data/vendor/json_pure/java/src/json/ext/StringDecoder.java +0 -167
- data/vendor/json_pure/java/src/json/ext/StringEncoder.java +0 -106
- data/vendor/json_pure/java/src/json/ext/Utils.java +0 -89
- data/vendor/json_pure/json-java.gemspec +0 -23
- data/vendor/json_pure/json.gemspec +0 -37
- data/vendor/json_pure/json_pure.gemspec +0 -39
- data/vendor/json_pure/lib/json.rb +0 -62
- data/vendor/json_pure/lib/json/add/bigdecimal.rb +0 -28
- data/vendor/json_pure/lib/json/add/complex.rb +0 -22
- data/vendor/json_pure/lib/json/add/core.rb +0 -11
- data/vendor/json_pure/lib/json/add/date.rb +0 -34
- data/vendor/json_pure/lib/json/add/date_time.rb +0 -50
- data/vendor/json_pure/lib/json/add/exception.rb +0 -31
- data/vendor/json_pure/lib/json/add/ostruct.rb +0 -31
- data/vendor/json_pure/lib/json/add/range.rb +0 -29
- data/vendor/json_pure/lib/json/add/rational.rb +0 -22
- data/vendor/json_pure/lib/json/add/regexp.rb +0 -30
- data/vendor/json_pure/lib/json/add/struct.rb +0 -30
- data/vendor/json_pure/lib/json/add/symbol.rb +0 -25
- data/vendor/json_pure/lib/json/add/time.rb +0 -38
- data/vendor/json_pure/lib/json/common.rb +0 -487
- data/vendor/json_pure/lib/json/ext.rb +0 -21
- data/vendor/json_pure/lib/json/ext/.keep +0 -0
- data/vendor/json_pure/lib/json/generic_object.rb +0 -70
- data/vendor/json_pure/lib/json/pure.rb +0 -21
- data/vendor/json_pure/lib/json/pure/generator.rb +0 -522
- data/vendor/json_pure/lib/json/pure/parser.rb +0 -359
- data/vendor/json_pure/lib/json/version.rb +0 -8
- data/vendor/json_pure/tests/fixtures/fail1.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail10.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail11.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail12.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail13.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail14.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail18.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail19.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail2.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail20.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail21.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail22.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail23.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail24.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail25.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail27.json +0 -2
- data/vendor/json_pure/tests/fixtures/fail28.json +0 -2
- data/vendor/json_pure/tests/fixtures/fail3.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail4.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail5.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail6.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail7.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail8.json +0 -1
- data/vendor/json_pure/tests/fixtures/fail9.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass1.json +0 -56
- data/vendor/json_pure/tests/fixtures/pass15.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass16.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass17.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass2.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass26.json +0 -1
- data/vendor/json_pure/tests/fixtures/pass3.json +0 -6
- data/vendor/json_pure/tests/setup_variant.rb +0 -11
- data/vendor/json_pure/tests/test_json.rb +0 -545
- data/vendor/json_pure/tests/test_json_addition.rb +0 -196
- data/vendor/json_pure/tests/test_json_encoding.rb +0 -65
- data/vendor/json_pure/tests/test_json_fixtures.rb +0 -35
- data/vendor/json_pure/tests/test_json_generate.rb +0 -322
- data/vendor/json_pure/tests/test_json_generic_object.rb +0 -75
- data/vendor/json_pure/tests/test_json_string_matching.rb +0 -39
- data/vendor/json_pure/tests/test_json_unicode.rb +0 -72
- data/vendor/json_pure/tools/fuzz.rb +0 -139
- data/vendor/json_pure/tools/server.rb +0 -62
- data/vendor/pusher-gem/Gemfile +0 -2
- data/vendor/pusher-gem/README.md +0 -80
- data/vendor/pusher-gem/lib/pusher.rb +0 -107
- data/vendor/pusher-gem/lib/pusher/request.rb +0 -107
- data/vendor/pusher-gem/spec/channel_spec.rb +0 -274
- data/vendor/pusher-gem/spec/pusher_spec.rb +0 -87
- data/vendor/ruby-hmac/History.txt +0 -15
- data/vendor/ruby-hmac/Manifest.txt +0 -11
- data/vendor/ruby-hmac/README.md +0 -41
- data/vendor/ruby-hmac/Rakefile +0 -23
- data/vendor/ruby-hmac/lib/hmac-md5.rb +0 -11
- data/vendor/ruby-hmac/lib/hmac-rmd160.rb +0 -11
- data/vendor/ruby-hmac/lib/hmac-sha1.rb +0 -11
- data/vendor/ruby-hmac/lib/hmac-sha2.rb +0 -25
- data/vendor/ruby-hmac/lib/hmac.rb +0 -118
- data/vendor/ruby-hmac/lib/ruby_hmac.rb +0 -2
- data/vendor/ruby-hmac/ruby-hmac.gemspec +0 -33
- data/vendor/ruby-hmac/test/test_hmac.rb +0 -89
- data/vendor/signature/VERSION +0 -1
@@ -0,0 +1,46 @@
|
|
1
|
+
## Contributing
|
2
|
+
In the spirit of [free software][free-sw], **everyone** is encouraged to help
|
3
|
+
improve this project.
|
4
|
+
|
5
|
+
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
6
|
+
|
7
|
+
Here are some ways *you* can contribute:
|
8
|
+
|
9
|
+
* by using alpha, beta, and prerelease versions
|
10
|
+
* by reporting bugs
|
11
|
+
* by suggesting new features
|
12
|
+
* by writing or editing documentation
|
13
|
+
* by writing specifications
|
14
|
+
* by writing code (**no patch is too small**: fix typos, add comments, clean up
|
15
|
+
inconsistent whitespace)
|
16
|
+
* by refactoring code
|
17
|
+
* by closing [issues][]
|
18
|
+
* by reviewing patches
|
19
|
+
|
20
|
+
[issues]: https://github.com/intridea/multi_json/issues
|
21
|
+
|
22
|
+
## Submitting an Issue
|
23
|
+
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
24
|
+
submitting a bug report or feature request, check to make sure it hasn't
|
25
|
+
already been submitted. When submitting a bug report, please include a [Gist][]
|
26
|
+
that includes a stack trace and any details that may be necessary to reproduce
|
27
|
+
the bug, including your gem version, Ruby version, and operating system.
|
28
|
+
Ideally, a bug report should include a pull request with failing specs.
|
29
|
+
|
30
|
+
[gist]: https://gist.github.com/
|
31
|
+
|
32
|
+
## Submitting a Pull Request
|
33
|
+
1. [Fork the repository.][fork]
|
34
|
+
2. [Create a topic branch.][branch]
|
35
|
+
3. Add specs for your unimplemented feature or bug fix.
|
36
|
+
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
|
37
|
+
5. Implement your feature or bug fix.
|
38
|
+
6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
|
39
|
+
7. Run `open coverage/index.html`. If your changes are not completely covered
|
40
|
+
by your tests, return to step 3.
|
41
|
+
8. Add, commit, and push your changes.
|
42
|
+
9. [Submit a pull request.][pr]
|
43
|
+
|
44
|
+
[fork]: http://help.github.com/fork-a-repo/
|
45
|
+
[branch]: http://learn.github.com/p/branching.html
|
46
|
+
[pr]: http://help.github.com/send-pull-requests/
|
@@ -0,0 +1,31 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'rake', '>= 0.9'
|
4
|
+
gem 'yard', '>= 0.8'
|
5
|
+
|
6
|
+
gem 'json', '~> 1.4', :require => nil
|
7
|
+
gem 'json_pure', '~> 1.4', :require => nil
|
8
|
+
|
9
|
+
platforms :ruby, :mswin, :mingw do
|
10
|
+
gem 'oj', '~> 2.0', :require => nil
|
11
|
+
gem 'yajl-ruby', '~> 1.0', :require => nil
|
12
|
+
end
|
13
|
+
|
14
|
+
platforms :jruby do
|
15
|
+
gem 'gson', '>= 0.6', :require => nil
|
16
|
+
gem 'jrjackson', '~> 0.1.1', :require => nil
|
17
|
+
end
|
18
|
+
|
19
|
+
group :development do
|
20
|
+
gem 'kramdown', '>= 0.14'
|
21
|
+
gem 'pry'
|
22
|
+
gem 'pry-debugger', :platforms => :mri_19
|
23
|
+
end
|
24
|
+
|
25
|
+
group :test do
|
26
|
+
gem 'coveralls', :require => false
|
27
|
+
gem 'rspec', '>= 2.14'
|
28
|
+
gem 'simplecov', :require => false
|
29
|
+
end
|
30
|
+
|
31
|
+
gemspec
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010-2013 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober, Pavel Pravosud
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# MultiJSON
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/multi_json.png)][gem]
|
4
|
+
[![Build Status](https://secure.travis-ci.org/intridea/multi_json.png?branch=master)][travis]
|
5
|
+
[![Dependency Status](https://gemnasium.com/intridea/multi_json.png?travis)][gemnasium]
|
6
|
+
[![Code Climate](https://codeclimate.com/github/intridea/multi_json.png)][codeclimate]
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/intridea/multi_json/badge.png?branch=master)][coveralls]
|
8
|
+
|
9
|
+
[gem]: https://rubygems.org/gems/multi_json
|
10
|
+
[travis]: http://travis-ci.org/intridea/multi_json
|
11
|
+
[gemnasium]: https://gemnasium.com/intridea/multi_json
|
12
|
+
[codeclimate]: https://codeclimate.com/github/intridea/multi_json
|
13
|
+
[coveralls]: https://coveralls.io/r/intridea/multi_json
|
14
|
+
|
15
|
+
Lots of Ruby libraries parse JSON and everyone has their favorite JSON coder.
|
16
|
+
Instead of choosing a single JSON coder and forcing users of your library to be
|
17
|
+
stuck with it, you can use MultiJSON instead, which will simply choose the
|
18
|
+
fastest available JSON coder. Here's how to use it:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
require 'multi_json'
|
22
|
+
|
23
|
+
MultiJson.load('{"abc":"def"}') #=> {"abc" => "def"}
|
24
|
+
MultiJson.load('{"abc":"def"}', :symbolize_keys => true) #=> {:abc => "def"}
|
25
|
+
MultiJson.dump({:abc => 'def'}) # convert Ruby back to JSON
|
26
|
+
MultiJson.dump({:abc => 'def'}, :pretty => true) # encoded in a pretty form (if supported by the coder)
|
27
|
+
```
|
28
|
+
|
29
|
+
When loading invalid JSON, multiJSON will throw a `MultiJson::LoadError`. `MultiJson::DecodeError` is an alias for backwards compatibility.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
MultiJson.load('invalid json') #=> MultiJson::LoadError
|
33
|
+
```
|
34
|
+
|
35
|
+
The `use` method, which sets the MultiJson adapter, takes either a symbol or a
|
36
|
+
class (to allow for custom JSON parsers) that responds to both `.load` and `.dump`
|
37
|
+
at the class level.
|
38
|
+
|
39
|
+
MultiJSON tries to have intelligent defaulting. That is, if you have any of the
|
40
|
+
supported engines already loaded, it will utilize them before attempting to
|
41
|
+
load any. When loading, libraries are ordered by speed. First Oj, then Yajl,
|
42
|
+
then the JSON gem, then JSON pure. If no other JSON library is available,
|
43
|
+
MultiJSON falls back to [OkJson][], a simple, vendorable JSON parser.
|
44
|
+
|
45
|
+
[okjson]: https://github.com/kr/okjson
|
46
|
+
|
47
|
+
## Supported JSON Engines
|
48
|
+
|
49
|
+
* [Oj](https://github.com/ohler55/oj) Optimized JSON by Peter Ohler
|
50
|
+
* [Yajl](https://github.com/brianmario/yajl-ruby) Yet Another JSON Library by Brian Lopez
|
51
|
+
* [JSON](https://github.com/flori/json) The default JSON gem with C-extensions (ships with Ruby 1.9)
|
52
|
+
* [JSON Pure](https://github.com/flori/json) A Ruby variant of the JSON gem
|
53
|
+
* [NSJSONSerialization](https://developer.apple.com/library/ios/#documentation/Foundation/Reference/NSJSONSerialization_Class/Reference/Reference.html) Wrapper for Apple's NSJSONSerialization in the Cocoa Framework (MacRuby only)
|
54
|
+
* [gson.rb](https://github.com/avsej/gson.rb) A Ruby wrapper for google-gson library (JRuby only)
|
55
|
+
* [JrJackson](https://github.com/guyboertje/jrjackson) JRuby wrapper for Jackson (JRuby only)
|
56
|
+
* [OkJson][okjson] A simple, vendorable JSON parser
|
57
|
+
|
58
|
+
## Supported Ruby Versions
|
59
|
+
This library aims to support and is [tested against][travis] the following Ruby
|
60
|
+
implementations:
|
61
|
+
|
62
|
+
* Ruby 1.8.7
|
63
|
+
* Ruby 1.9.2
|
64
|
+
* Ruby 1.9.3
|
65
|
+
* Ruby 2.0.0
|
66
|
+
* [JRuby][]
|
67
|
+
* [Rubinius][]
|
68
|
+
* [MacRuby][] (not tested on Travis CI)
|
69
|
+
|
70
|
+
[jruby]: http://www.jruby.org/
|
71
|
+
[rubinius]: http://rubini.us/
|
72
|
+
[macruby]: http://www.macruby.org/
|
73
|
+
|
74
|
+
If something doesn't work on one of these interpreters, it's a bug.
|
75
|
+
|
76
|
+
This library may inadvertently work (or seem to work) on other Ruby
|
77
|
+
implementations, however support will only be provided for the versions listed
|
78
|
+
above.
|
79
|
+
|
80
|
+
If you would like this library to support another Ruby version, you may
|
81
|
+
volunteer to be a maintainer. Being a maintainer entails making sure all tests
|
82
|
+
run and pass on that implementation. When something breaks on your
|
83
|
+
implementation, you will be responsible for providing patches in a timely
|
84
|
+
fashion. If critical issues for a particular implementation exist at the time
|
85
|
+
of a major release, support for that Ruby version may be dropped.
|
86
|
+
|
87
|
+
## Versioning
|
88
|
+
|
89
|
+
This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations
|
90
|
+
of this scheme should be reported as bugs. Specifically, if a minor or patch
|
91
|
+
version is released that breaks backward compatibility, that version should be
|
92
|
+
immediately yanked and/or a new version should be immediately released that
|
93
|
+
restores compatibility. Breaking changes to the public API will only be
|
94
|
+
introduced with new major versions. As a result of this policy, you can (and
|
95
|
+
should) specify a dependency on this gem using the [Pessimistic Version
|
96
|
+
Constraint][pvc] with two digits of precision. For example:
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
spec.add_dependency 'multi_json', '~> 1.0'
|
100
|
+
```
|
101
|
+
|
102
|
+
[semver]: http://semver.org/
|
103
|
+
[pvc]: http://docs.rubygems.org/read/chapter/16#page74
|
104
|
+
|
105
|
+
## Copyright
|
106
|
+
Copyright (c) 2010-2013 Michael Bleigh, Josh Kalderimis, Erik Michaels-Ober,
|
107
|
+
and Pavel Pravosud. See [LICENSE][] for details.
|
108
|
+
|
109
|
+
[license]: LICENSE.md
|
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'multi_json/options'
|
2
|
+
require 'multi_json/version'
|
3
|
+
require 'multi_json/load_error'
|
4
|
+
|
5
|
+
module MultiJson
|
6
|
+
include Options
|
7
|
+
extend self
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def cached_options
|
11
|
+
@cached_options ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset_cached_options!
|
15
|
+
@cached_options = {}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Since `default_options` is deprecated, the
|
20
|
+
# reader is aliased to `dump_options` and the
|
21
|
+
# writer sets both `dump_options` and `load_options`
|
22
|
+
alias default_options dump_options
|
23
|
+
|
24
|
+
def default_options=(value)
|
25
|
+
Kernel.warn "MultiJson.default_options setter is deprecated\n" +
|
26
|
+
"Use MultiJson.load_options and MultiJson.dump_options instead"
|
27
|
+
|
28
|
+
self.load_options = self.dump_options = value
|
29
|
+
end
|
30
|
+
|
31
|
+
ALIASES = { 'jrjackson' => :jr_jackson }
|
32
|
+
|
33
|
+
REQUIREMENT_MAP = [
|
34
|
+
['oj', :oj],
|
35
|
+
['yajl', :yajl],
|
36
|
+
['jrjackson', :jr_jackson],
|
37
|
+
['json/ext', :json_gem],
|
38
|
+
['gson', :gson],
|
39
|
+
['json/pure', :json_pure]
|
40
|
+
]
|
41
|
+
|
42
|
+
# The default adapter based on what you currently
|
43
|
+
# have loaded and installed. First checks to see
|
44
|
+
# if any adapters are already loaded, then checks
|
45
|
+
# to see which are installed if none are loaded.
|
46
|
+
def default_adapter
|
47
|
+
return :oj if defined?(::Oj)
|
48
|
+
return :yajl if defined?(::Yajl)
|
49
|
+
return :jr_jackson if defined?(::JrJackson)
|
50
|
+
return :json_gem if defined?(::JSON::JSON_LOADED)
|
51
|
+
return :gson if defined?(::Gson)
|
52
|
+
|
53
|
+
REQUIREMENT_MAP.each do |library, adapter|
|
54
|
+
begin
|
55
|
+
require library
|
56
|
+
return adapter
|
57
|
+
rescue ::LoadError
|
58
|
+
next
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
Kernel.warn '[WARNING] MultiJson is using the default adapter (ok_json). We recommend loading a different JSON library to improve performance.'
|
63
|
+
:ok_json
|
64
|
+
end
|
65
|
+
alias default_engine default_adapter
|
66
|
+
|
67
|
+
# Get the current adapter class.
|
68
|
+
def adapter
|
69
|
+
return @adapter if defined?(@adapter) && @adapter
|
70
|
+
|
71
|
+
self.use nil # load default adapter
|
72
|
+
|
73
|
+
@adapter
|
74
|
+
end
|
75
|
+
alias engine adapter
|
76
|
+
|
77
|
+
# Set the JSON parser utilizing a symbol, string, or class.
|
78
|
+
# Supported by default are:
|
79
|
+
#
|
80
|
+
# * <tt>:oj</tt>
|
81
|
+
# * <tt>:json_gem</tt>
|
82
|
+
# * <tt>:json_pure</tt>
|
83
|
+
# * <tt>:ok_json</tt>
|
84
|
+
# * <tt>:yajl</tt>
|
85
|
+
# * <tt>:nsjsonserialization</tt> (MacRuby only)
|
86
|
+
# * <tt>:gson</tt> (JRuby only)
|
87
|
+
# * <tt>:jr_jackson</tt> (JRuby only)
|
88
|
+
def use(new_adapter)
|
89
|
+
@adapter = load_adapter(new_adapter)
|
90
|
+
end
|
91
|
+
alias adapter= use
|
92
|
+
alias engine= use
|
93
|
+
|
94
|
+
def load_adapter(new_adapter)
|
95
|
+
case new_adapter
|
96
|
+
when String, Symbol
|
97
|
+
load_adapter_from_string_name new_adapter.to_s
|
98
|
+
when NilClass, FalseClass
|
99
|
+
load_adapter default_adapter
|
100
|
+
when Class, Module
|
101
|
+
new_adapter
|
102
|
+
else
|
103
|
+
raise ::LoadError
|
104
|
+
end
|
105
|
+
rescue ::LoadError
|
106
|
+
raise ArgumentError, 'Did not recognize your adapter specification.'
|
107
|
+
end
|
108
|
+
|
109
|
+
# Decode a JSON string into Ruby.
|
110
|
+
#
|
111
|
+
# <b>Options</b>
|
112
|
+
#
|
113
|
+
# <tt>:symbolize_keys</tt> :: If true, will use symbols instead of strings for the keys.
|
114
|
+
# <tt>:adapter</tt> :: If set, the selected adapter will be used for this call.
|
115
|
+
def load(string, options={})
|
116
|
+
adapter = current_adapter(options)
|
117
|
+
begin
|
118
|
+
adapter.load(string, options)
|
119
|
+
rescue adapter::ParseError => exception
|
120
|
+
raise LoadError.new(exception.message, exception.backtrace, string)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
alias decode load
|
124
|
+
|
125
|
+
def current_adapter(options={})
|
126
|
+
if new_adapter = options[:adapter]
|
127
|
+
load_adapter(new_adapter)
|
128
|
+
else
|
129
|
+
adapter
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Encodes a Ruby object as JSON.
|
134
|
+
def dump(object, options={})
|
135
|
+
current_adapter(options).dump(object, options)
|
136
|
+
end
|
137
|
+
alias encode dump
|
138
|
+
|
139
|
+
# Executes passed block using specified adapter.
|
140
|
+
def with_adapter(new_adapter)
|
141
|
+
old_adapter, self.adapter = adapter, new_adapter
|
142
|
+
yield
|
143
|
+
ensure
|
144
|
+
self.adapter = old_adapter
|
145
|
+
end
|
146
|
+
alias with_engine with_adapter
|
147
|
+
|
148
|
+
private
|
149
|
+
|
150
|
+
def load_adapter_from_string_name(name)
|
151
|
+
name = ALIASES.fetch(name, name)
|
152
|
+
require "multi_json/adapters/#{name}"
|
153
|
+
klass_name = name.to_s.split('_').map(&:capitalize) * ''
|
154
|
+
MultiJson::Adapters.const_get(klass_name)
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'multi_json/options'
|
3
|
+
|
4
|
+
module MultiJson
|
5
|
+
class Adapter
|
6
|
+
extend Options
|
7
|
+
include Singleton
|
8
|
+
class << self
|
9
|
+
|
10
|
+
def defaults(action, value)
|
11
|
+
metaclass = class << self; self; end
|
12
|
+
|
13
|
+
metaclass.instance_eval do
|
14
|
+
define_method("default_#{action}_options"){ value }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def load(string, options={})
|
19
|
+
instance.load(string, collect_load_options(options).clone)
|
20
|
+
end
|
21
|
+
|
22
|
+
def dump(object, options={})
|
23
|
+
instance.dump(object, collect_dump_options(options).clone)
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def collect_load_options(options)
|
29
|
+
cache('load', options){ collect_options(:load_options, options).merge(options) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def collect_dump_options(options)
|
33
|
+
cache('dump', options){ collect_options(:dump_options, options).merge(options) }
|
34
|
+
end
|
35
|
+
|
36
|
+
def collect_options(method, *args)
|
37
|
+
global, local = *[MultiJson, self].map{ |r| r.send(method, *args) }
|
38
|
+
local.merge(global)
|
39
|
+
end
|
40
|
+
|
41
|
+
def cache(method, options)
|
42
|
+
cache_key = [self, options].map(&:hash).join + method
|
43
|
+
MultiJson.cached_options[cache_key] ||= yield
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'gson' unless defined?(::Gson)
|
2
|
+
require 'multi_json/adapter'
|
3
|
+
|
4
|
+
module MultiJson
|
5
|
+
module Adapters
|
6
|
+
# Use the gson.rb library to dump/load.
|
7
|
+
class Gson < Adapter
|
8
|
+
ParseError = ::Gson::DecodeError
|
9
|
+
|
10
|
+
def load(string, options={})
|
11
|
+
::Gson::Decoder.new(options).decode(string)
|
12
|
+
end
|
13
|
+
|
14
|
+
def dump(object, options={})
|
15
|
+
::Gson::Encoder.new(options).encode(object)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|