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,20 @@
|
|
1
|
+
module MultiJson
|
2
|
+
class Version
|
3
|
+
MAJOR = 1 unless defined? MultiJson::Version::MAJOR
|
4
|
+
MINOR = 7 unless defined? MultiJson::Version::MINOR
|
5
|
+
PATCH = 9 unless defined? MultiJson::Version::PATCH
|
6
|
+
PRE = nil unless defined? MultiJson::Version::PRE
|
7
|
+
|
8
|
+
class << self
|
9
|
+
|
10
|
+
# @return [String]
|
11
|
+
def to_s
|
12
|
+
[MAJOR, MINOR, PATCH, PRE].compact.join('.')
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
VERSION = Version.to_s.freeze
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'multi_json/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
8
|
+
spec.authors = ["Michael Bleigh", "Josh Kalderimis", "Erik Michaels-Ober", "Pavel Pravosud"]
|
9
|
+
spec.cert_chain = %w(certs/rwz.pem)
|
10
|
+
spec.description = %q{A common interface to multiple JSON libraries, including Oj, Yajl, the JSON gem (with C-extensions), the pure-Ruby JSON gem, NSJSONSerialization, gson.rb, JrJackson, and OkJson.}
|
11
|
+
spec.email = ['michael@intridea.com', 'josh.kalderimis@gmail.com', 'sferik@gmail.com']
|
12
|
+
spec.files = Dir['.yardopts', 'CHANGELOG.md', 'CONTRIBUTING.md', 'LICENSE.md', 'README.md', 'Rakefile', 'multi_json.gemspec', 'Gemfile', '.document', '.rspec', '.travis.yml' ,'spec/**/*', 'lib/**/*']
|
13
|
+
spec.homepage = 'http://github.com/intridea/multi_json'
|
14
|
+
spec.licenses = ['MIT']
|
15
|
+
spec.name = 'multi_json'
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
spec.required_rubygems_version = '>= 1.3.5'
|
18
|
+
spec.signing_key = File.expand_path("~/.gem/private_key.pem") if $0 =~ /gem\z/
|
19
|
+
spec.summary = %q{A common interface to multiple JSON libraries.}
|
20
|
+
spec.test_files = Dir['spec/**/*']
|
21
|
+
spec.version = MultiJson::Version
|
22
|
+
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
shared_examples_for 'an adapter' do |adapter|
|
4
|
+
|
5
|
+
before do
|
6
|
+
begin
|
7
|
+
MultiJson.use adapter
|
8
|
+
rescue LoadError
|
9
|
+
pending "Adapter #{adapter} couldn't be loaded (not installed?)"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it_behaves_like 'has options', lambda{ MultiJson.adapter }
|
14
|
+
|
15
|
+
it 'does not modify argument hashes' do
|
16
|
+
options = { :symbolize_keys => true, :pretty => false, :adapter => :json_pure }
|
17
|
+
expect{MultiJson.load('{}', options)}.to_not change{options}
|
18
|
+
expect{MultiJson.dump([42], options)}.to_not change{options}
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.dump' do
|
22
|
+
describe '#dump_options' do
|
23
|
+
before{ MultiJson.dump_options = MultiJson.adapter.dump_options = {} }
|
24
|
+
|
25
|
+
after do
|
26
|
+
expect(MultiJson.adapter.instance).to receive(:dump).with(1, :foo => 'bar', :fizz => 'buzz')
|
27
|
+
MultiJson.dump(1, :fizz => 'buzz')
|
28
|
+
MultiJson.dump_options = MultiJson.adapter.dump_options = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'respects global dump options' do
|
32
|
+
MultiJson.dump_options = {:foo => 'bar'}
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'respects per-adapter dump options' do
|
36
|
+
MultiJson.adapter.dump_options = {:foo => 'bar'}
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'adapter-specific are overridden by global options' do
|
40
|
+
MultiJson.adapter.dump_options = {:foo => 'foo'}
|
41
|
+
MultiJson.dump_options = {:foo => 'bar'}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'writes decodable JSON' do
|
46
|
+
[
|
47
|
+
{'abc' => 'def'},
|
48
|
+
[1, 2, 3, '4', true, false, nil]
|
49
|
+
].each do |example|
|
50
|
+
expect(MultiJson.load(MultiJson.dump(example))).to eq example
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
unless 'json_pure' == adapter || 'json_gem' == adapter
|
55
|
+
it 'dumps time in correct format' do
|
56
|
+
time = Time.at(1355218745).utc
|
57
|
+
|
58
|
+
# time does not respond to to_json method
|
59
|
+
class << time
|
60
|
+
undef_method :to_json
|
61
|
+
end
|
62
|
+
|
63
|
+
dumped_json = MultiJson.dump(time)
|
64
|
+
expected = if RUBY_VERSION > '1.9'
|
65
|
+
'2012-12-11 09:39:05 UTC'
|
66
|
+
else
|
67
|
+
'Tue Dec 11 09:39:05 UTC 2012'
|
68
|
+
end
|
69
|
+
expect(MultiJson.load(dumped_json)).to eq expected
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'dumps symbol and fixnum keys as strings' do
|
74
|
+
[
|
75
|
+
[
|
76
|
+
{:foo => {:bar => 'baz'}},
|
77
|
+
{'foo' => {'bar' => 'baz'}},
|
78
|
+
],
|
79
|
+
[
|
80
|
+
[{:foo => {:bar => 'baz'}}],
|
81
|
+
[{'foo' => {'bar' => 'baz'}}],
|
82
|
+
],
|
83
|
+
[
|
84
|
+
{:foo => [{:bar => 'baz'}]},
|
85
|
+
{'foo' => [{'bar' => 'baz'}]},
|
86
|
+
],
|
87
|
+
[
|
88
|
+
{1 => {2 => {3 => 'bar'}}},
|
89
|
+
{'1' => {'2' => {'3' => 'bar'}}}
|
90
|
+
]
|
91
|
+
].each do |example, expected|
|
92
|
+
dumped_json = MultiJson.dump(example)
|
93
|
+
expect(MultiJson.load(dumped_json)).to eq expected
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'dumps rootless JSON' do
|
98
|
+
expect(MultiJson.dump('random rootless string')).to eq '"random rootless string"'
|
99
|
+
expect(MultiJson.dump(123)).to eq '123'
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'passes options to the adapter' do
|
103
|
+
expect(MultiJson.adapter).to receive(:dump).with('foo', {:bar => :baz})
|
104
|
+
MultiJson.dump('foo', :bar => :baz)
|
105
|
+
end
|
106
|
+
|
107
|
+
# This behavior is currently not supported by gson.rb
|
108
|
+
# See discussion at https://github.com/intridea/multi_json/pull/71
|
109
|
+
unless %w(gson jr_jackson).include?(adapter)
|
110
|
+
it 'dumps custom objects that implement to_json' do
|
111
|
+
klass = Class.new do
|
112
|
+
def to_json(*)
|
113
|
+
'"foobar"'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
expect(MultiJson.dump(klass.new)).to eq '"foobar"'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'allows to dump JSON values' do
|
121
|
+
expect(MultiJson.dump(42)).to eq '42'
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'allows to dump JSON with UTF-8 characters' do
|
125
|
+
expect(MultiJson.dump({'color' => 'żółć'})).to eq('{"color":"żółć"}')
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '.load' do
|
130
|
+
describe '#load_options' do
|
131
|
+
before{ MultiJson.load_options = MultiJson.adapter.load_options = {} }
|
132
|
+
|
133
|
+
after do
|
134
|
+
expect(MultiJson.adapter.instance).to receive(:load).with('1', :foo => 'bar', :fizz => 'buzz')
|
135
|
+
MultiJson.load('1', :fizz => 'buzz')
|
136
|
+
MultiJson.load_options = MultiJson.adapter.load_options = nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'respects global load options' do
|
140
|
+
MultiJson.load_options = {:foo => 'bar'}
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'respects per-adapter load options' do
|
144
|
+
MultiJson.adapter.load_options = {:foo => 'bar'}
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'adapter-specific are overridden by global options' do
|
148
|
+
MultiJson.adapter.load_options = {:foo => 'foo'}
|
149
|
+
MultiJson.load_options = {:foo => 'bar'}
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'does not modify input' do
|
154
|
+
input = %Q{\n\n {"foo":"bar"} \n\n\t}
|
155
|
+
expect{
|
156
|
+
MultiJson.load(input)
|
157
|
+
}.to_not change{ input }
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'does not modify input encoding' do
|
161
|
+
pending 'only in 1.9' unless RUBY_VERSION > '1.9'
|
162
|
+
|
163
|
+
input = '[123]'
|
164
|
+
input.force_encoding('iso-8859-1')
|
165
|
+
|
166
|
+
expect{
|
167
|
+
MultiJson.load(input)
|
168
|
+
}.to_not change{ input.encoding }
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'properly loads valid JSON' do
|
172
|
+
expect(MultiJson.load('{"abc":"def"}')).to eq({'abc' => 'def'})
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'raises MultiJson::LoadError on invalid JSON' do
|
176
|
+
expect{MultiJson.load('{"abc"}')}.to raise_error(MultiJson::LoadError)
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'raises MultiJson::LoadError with data on invalid JSON' do
|
180
|
+
data = '{invalid}'
|
181
|
+
begin
|
182
|
+
MultiJson.load(data)
|
183
|
+
rescue MultiJson::LoadError => le
|
184
|
+
expect(le.data).to eq data
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'catches MultiJson::DecodeError for legacy support' do
|
189
|
+
data = '{invalid}'
|
190
|
+
begin
|
191
|
+
MultiJson.load(data)
|
192
|
+
rescue MultiJson::DecodeError => de
|
193
|
+
expect(de.data).to eq data
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'stringifys symbol keys when encoding' do
|
198
|
+
dumped_json = MultiJson.dump(:a => 1, :b => {:c => 2})
|
199
|
+
loaded_json = MultiJson.load(dumped_json)
|
200
|
+
expect(loaded_json).to eq({'a' => 1, 'b' => {'c' => 2}})
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'properly loads valid JSON in StringIOs' do
|
204
|
+
json = StringIO.new('{"abc":"def"}')
|
205
|
+
expect(MultiJson.load(json)).to eq({'abc' => 'def'})
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'allows for symbolization of keys' do
|
209
|
+
[
|
210
|
+
[
|
211
|
+
'{"abc":{"def":"hgi"}}',
|
212
|
+
{:abc => {:def => 'hgi'}},
|
213
|
+
],
|
214
|
+
[
|
215
|
+
'[{"abc":{"def":"hgi"}}]',
|
216
|
+
[{:abc => {:def => 'hgi'}}],
|
217
|
+
],
|
218
|
+
[
|
219
|
+
'{"abc":[{"def":"hgi"}]}',
|
220
|
+
{:abc => [{:def => 'hgi'}]},
|
221
|
+
],
|
222
|
+
].each do |example, expected|
|
223
|
+
expect(MultiJson.load(example, :symbolize_keys => true)).to eq expected
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'allows to load JSON values' do
|
228
|
+
expect(MultiJson.load('42')).to eq 42
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'allows to load JSON with UTF-8 characters' do
|
232
|
+
expect(MultiJson.load('{"color":"żółć"}')).to eq({'color' => 'żółć'})
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
shared_examples_for 'has options' do |object|
|
2
|
+
|
3
|
+
if object.respond_to?(:call)
|
4
|
+
subject{ object.call }
|
5
|
+
else
|
6
|
+
subject{ object }
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "dump options" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
subject.dump_options = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
after do
|
16
|
+
subject.dump_options = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns default options if not set' do
|
20
|
+
expect(subject.dump_options).to eq(subject.default_dump_options)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'allows hashes' do
|
24
|
+
subject.dump_options = {:foo => 'bar'}
|
25
|
+
expect(subject.dump_options).to eq(:foo => 'bar')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'allows objects that implement #to_hash' do
|
29
|
+
value = Class.new do
|
30
|
+
def to_hash
|
31
|
+
{:foo => 'bar'}
|
32
|
+
end
|
33
|
+
end.new
|
34
|
+
|
35
|
+
subject.dump_options = value
|
36
|
+
expect(subject.dump_options).to eq(:foo => 'bar')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'evaluates lambda returning options (with args)' do
|
40
|
+
subject.dump_options = lambda{ |a1, a2| { a1 => a2 }}
|
41
|
+
expect(subject.dump_options('1', '2')).to eq('1' => '2')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'evaluates lambda returning options (with no args)' do
|
45
|
+
subject.dump_options = lambda{{:foo => 'bar'}}
|
46
|
+
expect(subject.dump_options).to eq(:foo => 'bar')
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'returns empty hash in all other cases' do
|
50
|
+
subject.dump_options = true
|
51
|
+
expect(subject.dump_options).to eq(subject.default_dump_options)
|
52
|
+
|
53
|
+
subject.dump_options = false
|
54
|
+
expect(subject.dump_options).to eq(subject.default_dump_options)
|
55
|
+
|
56
|
+
subject.dump_options = 10
|
57
|
+
expect(subject.dump_options).to eq(subject.default_dump_options)
|
58
|
+
|
59
|
+
subject.dump_options = nil
|
60
|
+
expect(subject.dump_options).to eq(subject.default_dump_options)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "load options" do
|
65
|
+
|
66
|
+
before do
|
67
|
+
subject.load_options = nil
|
68
|
+
end
|
69
|
+
|
70
|
+
after do
|
71
|
+
subject.load_options = nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns default options if not set' do
|
75
|
+
expect(subject.load_options).to eq(subject.default_load_options)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'allows hashes' do
|
79
|
+
subject.load_options = {:foo => 'bar'}
|
80
|
+
expect(subject.load_options).to eq(:foo => 'bar')
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'allows objects that implement #to_hash' do
|
84
|
+
value = Class.new do
|
85
|
+
def to_hash
|
86
|
+
{:foo => 'bar'}
|
87
|
+
end
|
88
|
+
end.new
|
89
|
+
|
90
|
+
subject.load_options = value
|
91
|
+
expect(subject.load_options).to eq(:foo => 'bar')
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'evaluates lambda returning options (with args)' do
|
95
|
+
subject.load_options = lambda{ |a1, a2| { a1 => a2 }}
|
96
|
+
expect(subject.load_options('1', '2')).to eq('1' => '2')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'evaluates lambda returning options (with no args)' do
|
100
|
+
subject.load_options = lambda{{:foo => 'bar'}}
|
101
|
+
expect(subject.load_options).to eq(:foo => 'bar')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'returns empty hash in all other cases' do
|
105
|
+
subject.load_options = true
|
106
|
+
expect(subject.load_options).to eq(subject.default_load_options)
|
107
|
+
|
108
|
+
subject.load_options = false
|
109
|
+
expect(subject.load_options).to eq(subject.default_load_options)
|
110
|
+
|
111
|
+
subject.load_options = 10
|
112
|
+
expect(subject.load_options).to eq(subject.default_load_options)
|
113
|
+
|
114
|
+
subject.load_options = nil
|
115
|
+
expect(subject.load_options).to eq(subject.default_load_options)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start do
|
9
|
+
add_filter 'spec'
|
10
|
+
add_filter 'vendor'
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'multi_json'
|
14
|
+
require 'rspec'
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.expect_with :rspec do |c|
|
18
|
+
c.syntax = :expect
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def silence_warnings
|
23
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
24
|
+
yield
|
25
|
+
ensure
|
26
|
+
$VERBOSE = old_verbose
|
27
|
+
end
|
28
|
+
|
29
|
+
def macruby?
|
30
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'macruby'
|
31
|
+
end
|
32
|
+
|
33
|
+
def jruby?
|
34
|
+
defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
shared_examples_for 'JSON-like adapter' do |adapter|
|
2
|
+
before{ MultiJson.use adapter }
|
3
|
+
|
4
|
+
describe '.dump' do
|
5
|
+
before{ MultiJson.dump_options = MultiJson.adapter.dump_options = nil }
|
6
|
+
|
7
|
+
describe 'with :pretty option set to true' do
|
8
|
+
it 'passes default pretty options' do
|
9
|
+
object = 'foo'
|
10
|
+
expect(object).to receive(:to_json).with(JSON::PRETTY_STATE_PROTOTYPE.to_h)
|
11
|
+
MultiJson.dump(object, :pretty => true)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'with :indent option' do
|
16
|
+
it 'passes it on dump' do
|
17
|
+
object = 'foo'
|
18
|
+
expect(object).to receive(:to_json).with(:indent => "\t")
|
19
|
+
MultiJson.dump(object, :indent => "\t")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.load' do
|
25
|
+
it 'passes :quirks_mode option' do
|
26
|
+
expect(::JSON).to receive(:parse).with('[123]', {:quirks_mode => false, :create_additions => false})
|
27
|
+
MultiJson.load('[123]', :quirks_mode => false)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|