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
@@ -1,359 +0,0 @@
|
|
1
|
-
require 'strscan'
|
2
|
-
|
3
|
-
module JSON
|
4
|
-
module Pure
|
5
|
-
# This class implements the JSON parser that is used to parse a JSON string
|
6
|
-
# into a Ruby data structure.
|
7
|
-
class Parser < StringScanner
|
8
|
-
STRING = /" ((?:[^\x0-\x1f"\\] |
|
9
|
-
# escaped special characters:
|
10
|
-
\\["\\\/bfnrt] |
|
11
|
-
\\u[0-9a-fA-F]{4} |
|
12
|
-
# match all but escaped special characters:
|
13
|
-
\\[\x20-\x21\x23-\x2e\x30-\x5b\x5d-\x61\x63-\x65\x67-\x6d\x6f-\x71\x73\x75-\xff])*)
|
14
|
-
"/nx
|
15
|
-
INTEGER = /(-?0|-?[1-9]\d*)/
|
16
|
-
FLOAT = /(-?
|
17
|
-
(?:0|[1-9]\d*)
|
18
|
-
(?:
|
19
|
-
\.\d+(?i:e[+-]?\d+) |
|
20
|
-
\.\d+ |
|
21
|
-
(?i:e[+-]?\d+)
|
22
|
-
)
|
23
|
-
)/x
|
24
|
-
NAN = /NaN/
|
25
|
-
INFINITY = /Infinity/
|
26
|
-
MINUS_INFINITY = /-Infinity/
|
27
|
-
OBJECT_OPEN = /\{/
|
28
|
-
OBJECT_CLOSE = /\}/
|
29
|
-
ARRAY_OPEN = /\[/
|
30
|
-
ARRAY_CLOSE = /\]/
|
31
|
-
PAIR_DELIMITER = /:/
|
32
|
-
COLLECTION_DELIMITER = /,/
|
33
|
-
TRUE = /true/
|
34
|
-
FALSE = /false/
|
35
|
-
NULL = /null/
|
36
|
-
IGNORE = %r(
|
37
|
-
(?:
|
38
|
-
//[^\n\r]*[\n\r]| # line comments
|
39
|
-
/\* # c-style comments
|
40
|
-
(?:
|
41
|
-
[^*/]| # normal chars
|
42
|
-
/[^*]| # slashes that do not start a nested comment
|
43
|
-
\*[^/]| # asterisks that do not end this comment
|
44
|
-
/(?=\*/) # single slash before this comment's end
|
45
|
-
)*
|
46
|
-
\*/ # the End of this comment
|
47
|
-
|[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
|
48
|
-
)+
|
49
|
-
)mx
|
50
|
-
|
51
|
-
UNPARSED = Object.new
|
52
|
-
|
53
|
-
# Creates a new JSON::Pure::Parser instance for the string _source_.
|
54
|
-
#
|
55
|
-
# It will be configured by the _opts_ hash. _opts_ can have the following
|
56
|
-
# keys:
|
57
|
-
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
|
58
|
-
# structures. Disable depth checking with :max_nesting => false|nil|0,
|
59
|
-
# it defaults to 100.
|
60
|
-
# * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
|
61
|
-
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
|
62
|
-
# to false.
|
63
|
-
# * *symbolize_names*: If set to true, returns symbols for the names
|
64
|
-
# (keys) in a JSON object. Otherwise strings are returned, which is also
|
65
|
-
# the default.
|
66
|
-
# * *create_additions*: If set to true, the Parser creates
|
67
|
-
# additions when if a matching class and create_id was found. This
|
68
|
-
# option defaults to false.
|
69
|
-
# * *object_class*: Defaults to Hash
|
70
|
-
# * *array_class*: Defaults to Array
|
71
|
-
# * *quirks_mode*: Enables quirks_mode for parser, that is for example
|
72
|
-
# parsing single JSON values instead of documents is possible.
|
73
|
-
def initialize(source, opts = {})
|
74
|
-
opts ||= {}
|
75
|
-
unless @quirks_mode = opts[:quirks_mode]
|
76
|
-
source = convert_encoding source
|
77
|
-
end
|
78
|
-
super source
|
79
|
-
if !opts.key?(:max_nesting) # defaults to 100
|
80
|
-
@max_nesting = 100
|
81
|
-
elsif opts[:max_nesting]
|
82
|
-
@max_nesting = opts[:max_nesting]
|
83
|
-
else
|
84
|
-
@max_nesting = 0
|
85
|
-
end
|
86
|
-
@allow_nan = !!opts[:allow_nan]
|
87
|
-
@symbolize_names = !!opts[:symbolize_names]
|
88
|
-
if opts.key?(:create_additions)
|
89
|
-
@create_additions = !!opts[:create_additions]
|
90
|
-
else
|
91
|
-
@create_additions = false
|
92
|
-
end
|
93
|
-
@create_id = @create_additions ? JSON.create_id : nil
|
94
|
-
@object_class = opts[:object_class] || Hash
|
95
|
-
@array_class = opts[:array_class] || Array
|
96
|
-
@match_string = opts[:match_string]
|
97
|
-
end
|
98
|
-
|
99
|
-
alias source string
|
100
|
-
|
101
|
-
def quirks_mode?
|
102
|
-
!!@quirks_mode
|
103
|
-
end
|
104
|
-
|
105
|
-
def reset
|
106
|
-
super
|
107
|
-
@current_nesting = 0
|
108
|
-
end
|
109
|
-
|
110
|
-
# Parses the current JSON string _source_ and returns the complete data
|
111
|
-
# structure as a result.
|
112
|
-
def parse
|
113
|
-
reset
|
114
|
-
obj = nil
|
115
|
-
if @quirks_mode
|
116
|
-
while !eos? && skip(IGNORE)
|
117
|
-
end
|
118
|
-
if eos?
|
119
|
-
raise ParserError, "source did not contain any JSON!"
|
120
|
-
else
|
121
|
-
obj = parse_value
|
122
|
-
obj == UNPARSED and raise ParserError, "source did not contain any JSON!"
|
123
|
-
end
|
124
|
-
else
|
125
|
-
until eos?
|
126
|
-
case
|
127
|
-
when scan(OBJECT_OPEN)
|
128
|
-
obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
|
129
|
-
@current_nesting = 1
|
130
|
-
obj = parse_object
|
131
|
-
when scan(ARRAY_OPEN)
|
132
|
-
obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
|
133
|
-
@current_nesting = 1
|
134
|
-
obj = parse_array
|
135
|
-
when skip(IGNORE)
|
136
|
-
;
|
137
|
-
else
|
138
|
-
raise ParserError, "source '#{peek(20)}' not in JSON!"
|
139
|
-
end
|
140
|
-
end
|
141
|
-
obj or raise ParserError, "source did not contain any JSON!"
|
142
|
-
end
|
143
|
-
obj
|
144
|
-
end
|
145
|
-
|
146
|
-
private
|
147
|
-
|
148
|
-
def convert_encoding(source)
|
149
|
-
if source.respond_to?(:to_str)
|
150
|
-
source = source.to_str
|
151
|
-
else
|
152
|
-
raise TypeError, "#{source.inspect} is not like a string"
|
153
|
-
end
|
154
|
-
if defined?(::Encoding)
|
155
|
-
if source.encoding == ::Encoding::ASCII_8BIT
|
156
|
-
b = source[0, 4].bytes.to_a
|
157
|
-
source =
|
158
|
-
case
|
159
|
-
when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
|
160
|
-
source.dup.force_encoding(::Encoding::UTF_32BE).encode!(::Encoding::UTF_8)
|
161
|
-
when b.size >= 4 && b[0] == 0 && b[2] == 0
|
162
|
-
source.dup.force_encoding(::Encoding::UTF_16BE).encode!(::Encoding::UTF_8)
|
163
|
-
when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
|
164
|
-
source.dup.force_encoding(::Encoding::UTF_32LE).encode!(::Encoding::UTF_8)
|
165
|
-
when b.size >= 4 && b[1] == 0 && b[3] == 0
|
166
|
-
source.dup.force_encoding(::Encoding::UTF_16LE).encode!(::Encoding::UTF_8)
|
167
|
-
else
|
168
|
-
source.dup
|
169
|
-
end
|
170
|
-
else
|
171
|
-
source = source.encode(::Encoding::UTF_8)
|
172
|
-
end
|
173
|
-
source.force_encoding(::Encoding::ASCII_8BIT)
|
174
|
-
else
|
175
|
-
b = source
|
176
|
-
source =
|
177
|
-
case
|
178
|
-
when b.size >= 4 && b[0] == 0 && b[1] == 0 && b[2] == 0
|
179
|
-
JSON.iconv('utf-8', 'utf-32be', b)
|
180
|
-
when b.size >= 4 && b[0] == 0 && b[2] == 0
|
181
|
-
JSON.iconv('utf-8', 'utf-16be', b)
|
182
|
-
when b.size >= 4 && b[1] == 0 && b[2] == 0 && b[3] == 0
|
183
|
-
JSON.iconv('utf-8', 'utf-32le', b)
|
184
|
-
when b.size >= 4 && b[1] == 0 && b[3] == 0
|
185
|
-
JSON.iconv('utf-8', 'utf-16le', b)
|
186
|
-
else
|
187
|
-
b
|
188
|
-
end
|
189
|
-
end
|
190
|
-
source
|
191
|
-
end
|
192
|
-
|
193
|
-
# Unescape characters in strings.
|
194
|
-
UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
|
195
|
-
UNESCAPE_MAP.update({
|
196
|
-
?" => '"',
|
197
|
-
?\\ => '\\',
|
198
|
-
?/ => '/',
|
199
|
-
?b => "\b",
|
200
|
-
?f => "\f",
|
201
|
-
?n => "\n",
|
202
|
-
?r => "\r",
|
203
|
-
?t => "\t",
|
204
|
-
?u => nil,
|
205
|
-
})
|
206
|
-
|
207
|
-
EMPTY_8BIT_STRING = ''
|
208
|
-
if ::String.method_defined?(:encode)
|
209
|
-
EMPTY_8BIT_STRING.force_encoding Encoding::ASCII_8BIT
|
210
|
-
end
|
211
|
-
|
212
|
-
def parse_string
|
213
|
-
if scan(STRING)
|
214
|
-
return '' if self[1].empty?
|
215
|
-
string = self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
|
216
|
-
if u = UNESCAPE_MAP[$&[1]]
|
217
|
-
u
|
218
|
-
else # \uXXXX
|
219
|
-
bytes = EMPTY_8BIT_STRING.dup
|
220
|
-
i = 0
|
221
|
-
while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
|
222
|
-
bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
|
223
|
-
i += 1
|
224
|
-
end
|
225
|
-
JSON.iconv('utf-8', 'utf-16be', bytes)
|
226
|
-
end
|
227
|
-
end
|
228
|
-
if string.respond_to?(:force_encoding)
|
229
|
-
string.force_encoding(::Encoding::UTF_8)
|
230
|
-
end
|
231
|
-
if @create_additions and @match_string
|
232
|
-
for (regexp, klass) in @match_string
|
233
|
-
klass.json_creatable? or next
|
234
|
-
string =~ regexp and return klass.json_create(string)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
string
|
238
|
-
else
|
239
|
-
UNPARSED
|
240
|
-
end
|
241
|
-
rescue => e
|
242
|
-
raise ParserError, "Caught #{e.class} at '#{peek(20)}': #{e}"
|
243
|
-
end
|
244
|
-
|
245
|
-
def parse_value
|
246
|
-
case
|
247
|
-
when scan(FLOAT)
|
248
|
-
Float(self[1])
|
249
|
-
when scan(INTEGER)
|
250
|
-
Integer(self[1])
|
251
|
-
when scan(TRUE)
|
252
|
-
true
|
253
|
-
when scan(FALSE)
|
254
|
-
false
|
255
|
-
when scan(NULL)
|
256
|
-
nil
|
257
|
-
when (string = parse_string) != UNPARSED
|
258
|
-
string
|
259
|
-
when scan(ARRAY_OPEN)
|
260
|
-
@current_nesting += 1
|
261
|
-
ary = parse_array
|
262
|
-
@current_nesting -= 1
|
263
|
-
ary
|
264
|
-
when scan(OBJECT_OPEN)
|
265
|
-
@current_nesting += 1
|
266
|
-
obj = parse_object
|
267
|
-
@current_nesting -= 1
|
268
|
-
obj
|
269
|
-
when @allow_nan && scan(NAN)
|
270
|
-
NaN
|
271
|
-
when @allow_nan && scan(INFINITY)
|
272
|
-
Infinity
|
273
|
-
when @allow_nan && scan(MINUS_INFINITY)
|
274
|
-
MinusInfinity
|
275
|
-
else
|
276
|
-
UNPARSED
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
def parse_array
|
281
|
-
raise NestingError, "nesting of #@current_nesting is too deep" if
|
282
|
-
@max_nesting.nonzero? && @current_nesting > @max_nesting
|
283
|
-
result = @array_class.new
|
284
|
-
delim = false
|
285
|
-
until eos?
|
286
|
-
case
|
287
|
-
when (value = parse_value) != UNPARSED
|
288
|
-
delim = false
|
289
|
-
result << value
|
290
|
-
skip(IGNORE)
|
291
|
-
if scan(COLLECTION_DELIMITER)
|
292
|
-
delim = true
|
293
|
-
elsif match?(ARRAY_CLOSE)
|
294
|
-
;
|
295
|
-
else
|
296
|
-
raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
|
297
|
-
end
|
298
|
-
when scan(ARRAY_CLOSE)
|
299
|
-
if delim
|
300
|
-
raise ParserError, "expected next element in array at '#{peek(20)}'!"
|
301
|
-
end
|
302
|
-
break
|
303
|
-
when skip(IGNORE)
|
304
|
-
;
|
305
|
-
else
|
306
|
-
raise ParserError, "unexpected token in array at '#{peek(20)}'!"
|
307
|
-
end
|
308
|
-
end
|
309
|
-
result
|
310
|
-
end
|
311
|
-
|
312
|
-
def parse_object
|
313
|
-
raise NestingError, "nesting of #@current_nesting is too deep" if
|
314
|
-
@max_nesting.nonzero? && @current_nesting > @max_nesting
|
315
|
-
result = @object_class.new
|
316
|
-
delim = false
|
317
|
-
until eos?
|
318
|
-
case
|
319
|
-
when (string = parse_string) != UNPARSED
|
320
|
-
skip(IGNORE)
|
321
|
-
unless scan(PAIR_DELIMITER)
|
322
|
-
raise ParserError, "expected ':' in object at '#{peek(20)}'!"
|
323
|
-
end
|
324
|
-
skip(IGNORE)
|
325
|
-
unless (value = parse_value).equal? UNPARSED
|
326
|
-
result[@symbolize_names ? string.to_sym : string] = value
|
327
|
-
delim = false
|
328
|
-
skip(IGNORE)
|
329
|
-
if scan(COLLECTION_DELIMITER)
|
330
|
-
delim = true
|
331
|
-
elsif match?(OBJECT_CLOSE)
|
332
|
-
;
|
333
|
-
else
|
334
|
-
raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
|
335
|
-
end
|
336
|
-
else
|
337
|
-
raise ParserError, "expected value in object at '#{peek(20)}'!"
|
338
|
-
end
|
339
|
-
when scan(OBJECT_CLOSE)
|
340
|
-
if delim
|
341
|
-
raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
|
342
|
-
end
|
343
|
-
if @create_additions and klassname = result[@create_id]
|
344
|
-
klass = JSON.deep_const_get klassname
|
345
|
-
break unless klass and klass.json_creatable?
|
346
|
-
result = klass.json_create(result)
|
347
|
-
end
|
348
|
-
break
|
349
|
-
when skip(IGNORE)
|
350
|
-
;
|
351
|
-
else
|
352
|
-
raise ParserError, "unexpected token in object at '#{peek(20)}'!"
|
353
|
-
end
|
354
|
-
end
|
355
|
-
result
|
356
|
-
end
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
"A JSON payload should be an object or array, not a string."
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Extra value after close": true} "misplaced quoted value"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Illegal expression": 1 + 2}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Illegal invocation": alert()}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Numbers cannot have leading zeroes": 013}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Numbers cannot be hex": 0x14}
|
@@ -1 +0,0 @@
|
|
1
|
-
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Missing colon" null}
|
@@ -1 +0,0 @@
|
|
1
|
-
["Unclosed array"
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Double colon":: null}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Comma instead of colon", null}
|
@@ -1 +0,0 @@
|
|
1
|
-
["Colon instead of comma": false]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Bad value", truth]
|
@@ -1 +0,0 @@
|
|
1
|
-
['single quote']
|
@@ -1 +0,0 @@
|
|
1
|
-
["tab character in string "]
|
@@ -1 +0,0 @@
|
|
1
|
-
{unquoted_key: "keys must be quoted"}
|
@@ -1 +0,0 @@
|
|
1
|
-
["extra comma",]
|
@@ -1 +0,0 @@
|
|
1
|
-
["double extra comma",,]
|
@@ -1 +0,0 @@
|
|
1
|
-
[ , "<-- missing value"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Comma after the close"],
|
@@ -1 +0,0 @@
|
|
1
|
-
["Extra close"]]
|
@@ -1 +0,0 @@
|
|
1
|
-
{"Extra comma": true,}
|