benschwarz-smoke 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +6 -0
- data/VERSION.yml +1 -1
- metadata +65 -196
- data/Gemfile +0 -10
- data/bin/edit_json.rb +0 -3
- data/bin/restclient +0 -3
- data/vendor/gems/cache/crack-0.1.1.gem +0 -0
- data/vendor/gems/cache/fakeweb-1.2.5.gem +0 -0
- data/vendor/gems/cache/json-1.1.3.gem +0 -0
- data/vendor/gems/cache/rest-client-1.0.1.gem +0 -0
- data/vendor/gems/cache/simple-rss-1.2.gem +0 -0
- data/vendor/gems/cache/wycats-moneta-0.6.0.gem +0 -0
- data/vendor/gems/environment.rb +0 -83
- data/vendor/gems/gems/crack-0.1.1/LICENSE +0 -20
- data/vendor/gems/gems/crack-0.1.1/README.rdoc +0 -22
- data/vendor/gems/gems/crack-0.1.1/VERSION.yml +0 -4
- data/vendor/gems/gems/crack-0.1.1/lib/crack.rb +0 -7
- data/vendor/gems/gems/crack-0.1.1/lib/crack/core_extensions.rb +0 -126
- data/vendor/gems/gems/crack-0.1.1/lib/crack/json.rb +0 -66
- data/vendor/gems/gems/crack-0.1.1/lib/crack/xml.rb +0 -211
- data/vendor/gems/gems/crack-0.1.1/test/crack_test.rb +0 -4
- data/vendor/gems/gems/crack-0.1.1/test/json_test.rb +0 -42
- data/vendor/gems/gems/crack-0.1.1/test/test_helper.rb +0 -12
- data/vendor/gems/gems/crack-0.1.1/test/xml_test.rb +0 -451
- data/vendor/gems/gems/fakeweb-1.2.5/CHANGELOG +0 -163
- data/vendor/gems/gems/fakeweb-1.2.5/LICENSE.txt +0 -281
- data/vendor/gems/gems/fakeweb-1.2.5/README.rdoc +0 -193
- data/vendor/gems/gems/fakeweb-1.2.5/Rakefile +0 -76
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web.rb +0 -172
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/ext/net_http.rb +0 -71
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/registry.rb +0 -103
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/responder.rb +0 -113
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/response.rb +0 -10
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/stub_socket.rb +0 -15
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fake_web/utility.rb +0 -22
- data/vendor/gems/gems/fakeweb-1.2.5/lib/fakeweb.rb +0 -2
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_from_curl +0 -12
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_with_transfer_encoding +0 -17
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/google_response_without_transfer_encoding +0 -11
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_example.txt +0 -1
- data/vendor/gems/gems/fakeweb-1.2.5/test/fixtures/test_txt_file +0 -3
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_allow_net_connect.rb +0 -85
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_deprecations.rb +0 -54
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_authentication.rb +0 -92
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web.rb +0 -518
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_fake_web_open_uri.rb +0 -58
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_helper.rb +0 -74
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_missing_open_uri.rb +0 -25
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_precedence.rb +0 -51
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_query_string.rb +0 -45
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_regexes.rb +0 -103
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_response_headers.rb +0 -67
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_trailing_slashes.rb +0 -53
- data/vendor/gems/gems/fakeweb-1.2.5/test/test_utility.rb +0 -70
- data/vendor/gems/gems/json-1.1.3/CHANGES +0 -93
- data/vendor/gems/gems/json-1.1.3/GPL +0 -340
- data/vendor/gems/gems/json-1.1.3/README +0 -78
- data/vendor/gems/gems/json-1.1.3/RUBY +0 -58
- data/vendor/gems/gems/json-1.1.3/Rakefile +0 -309
- data/vendor/gems/gems/json-1.1.3/TODO +0 -1
- data/vendor/gems/gems/json-1.1.3/VERSION +0 -1
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark.txt +0 -133
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_generator.rb +0 -48
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_parser.rb +0 -26
- data/vendor/gems/gems/json-1.1.3/benchmarks/benchmark_rails.rb +0 -26
- data/vendor/gems/gems/json-1.1.3/bin/edit_json.rb +0 -10
- data/vendor/gems/gems/json-1.1.3/bin/prettify_json.rb +0 -76
- data/vendor/gems/gems/json-1.1.3/data/example.json +0 -1
- data/vendor/gems/gems/json-1.1.3/data/index.html +0 -38
- data/vendor/gems/gems/json-1.1.3/data/prototype.js +0 -4184
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/Makefile +0 -150
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/extconf.rb +0 -9
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.c +0 -875
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/generator.o +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.c +0 -182
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.h +0 -53
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/generator/unicode.o +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/Makefile +0 -150
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/extconf.rb +0 -9
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.bundle +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.c +0 -1758
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.o +0 -0
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/parser.rl +0 -638
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.c +0 -154
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.h +0 -58
- data/vendor/gems/gems/json-1.1.3/ext/json/ext/parser/unicode.o +0 -0
- data/vendor/gems/gems/json-1.1.3/install.rb +0 -26
- data/vendor/gems/gems/json-1.1.3/lib/json.rb +0 -235
- data/vendor/gems/gems/json-1.1.3/lib/json/Array.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/FalseClass.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/Hash.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/Key.xpm +0 -73
- data/vendor/gems/gems/json-1.1.3/lib/json/NilClass.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/Numeric.xpm +0 -28
- data/vendor/gems/gems/json-1.1.3/lib/json/String.xpm +0 -96
- data/vendor/gems/gems/json-1.1.3/lib/json/TrueClass.xpm +0 -21
- data/vendor/gems/gems/json-1.1.3/lib/json/add/core.rb +0 -135
- data/vendor/gems/gems/json-1.1.3/lib/json/add/rails.rb +0 -58
- data/vendor/gems/gems/json-1.1.3/lib/json/common.rb +0 -354
- data/vendor/gems/gems/json-1.1.3/lib/json/editor.rb +0 -1362
- data/vendor/gems/gems/json-1.1.3/lib/json/ext.rb +0 -13
- data/vendor/gems/gems/json-1.1.3/lib/json/json.xpm +0 -1499
- data/vendor/gems/gems/json-1.1.3/lib/json/pure.rb +0 -75
- data/vendor/gems/gems/json-1.1.3/lib/json/pure/generator.rb +0 -394
- data/vendor/gems/gems/json-1.1.3/lib/json/pure/parser.rb +0 -259
- data/vendor/gems/gems/json-1.1.3/lib/json/version.rb +0 -9
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail1.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail10.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail11.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail12.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail13.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail14.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail18.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail19.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail2.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail20.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail21.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail22.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail23.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail24.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail25.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail27.json +0 -2
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail28.json +0 -2
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail3.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail4.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail5.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail6.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail7.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail8.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/fail9.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass1.json +0 -56
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass15.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass16.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass17.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass2.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass26.json +0 -1
- data/vendor/gems/gems/json-1.1.3/tests/fixtures/pass3.json +0 -6
- data/vendor/gems/gems/json-1.1.3/tests/runner.rb +0 -25
- data/vendor/gems/gems/json-1.1.3/tests/test_json.rb +0 -293
- data/vendor/gems/gems/json-1.1.3/tests/test_json_addition.rb +0 -161
- data/vendor/gems/gems/json-1.1.3/tests/test_json_fixtures.rb +0 -30
- data/vendor/gems/gems/json-1.1.3/tests/test_json_generate.rb +0 -100
- data/vendor/gems/gems/json-1.1.3/tests/test_json_rails.rb +0 -118
- data/vendor/gems/gems/json-1.1.3/tests/test_json_unicode.rb +0 -61
- data/vendor/gems/gems/json-1.1.3/tools/fuzz.rb +0 -140
- data/vendor/gems/gems/json-1.1.3/tools/server.rb +0 -62
- data/vendor/gems/gems/rest-client-1.0.1/README.rdoc +0 -151
- data/vendor/gems/gems/rest-client-1.0.1/Rakefile +0 -85
- data/vendor/gems/gems/rest-client-1.0.1/bin/restclient +0 -87
- data/vendor/gems/gems/rest-client-1.0.1/lib/rest_client.rb +0 -2
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient.rb +0 -93
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/exceptions.rb +0 -84
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/mixin/response.rb +0 -43
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/raw_response.rb +0 -30
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/request.rb +0 -236
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/resource.rb +0 -146
- data/vendor/gems/gems/rest-client-1.0.1/lib/restclient/response.rb +0 -20
- data/vendor/gems/gems/rest-client-1.0.1/spec/base.rb +0 -4
- data/vendor/gems/gems/rest-client-1.0.1/spec/exceptions_spec.rb +0 -54
- data/vendor/gems/gems/rest-client-1.0.1/spec/mixin/response_spec.rb +0 -46
- data/vendor/gems/gems/rest-client-1.0.1/spec/raw_response_spec.rb +0 -17
- data/vendor/gems/gems/rest-client-1.0.1/spec/request_spec.rb +0 -462
- data/vendor/gems/gems/rest-client-1.0.1/spec/resource_spec.rb +0 -75
- data/vendor/gems/gems/rest-client-1.0.1/spec/response_spec.rb +0 -16
- data/vendor/gems/gems/rest-client-1.0.1/spec/restclient_spec.rb +0 -53
- data/vendor/gems/gems/simple-rss-1.2/LICENSE +0 -429
- data/vendor/gems/gems/simple-rss-1.2/README +0 -43
- data/vendor/gems/gems/simple-rss-1.2/Rakefile +0 -212
- data/vendor/gems/gems/simple-rss-1.2/lib/simple-rss.rb +0 -149
- data/vendor/gems/gems/simple-rss-1.2/test/base/base_test.rb +0 -51
- data/vendor/gems/gems/simple-rss-1.2/test/data/atom.xml +0 -45
- data/vendor/gems/gems/simple-rss-1.2/test/data/not-rss.xml +0 -8
- data/vendor/gems/gems/simple-rss-1.2/test/data/rss09.rdf +0 -79
- data/vendor/gems/gems/simple-rss-1.2/test/data/rss20.xml +0 -818
- data/vendor/gems/gems/simple-rss-1.2/test/test_helper.rb +0 -4
- data/vendor/gems/gems/wycats-moneta-0.6.0/LICENSE +0 -20
- data/vendor/gems/gems/wycats-moneta-0.6.0/README +0 -50
- data/vendor/gems/gems/wycats-moneta-0.6.0/Rakefile +0 -60
- data/vendor/gems/gems/wycats-moneta-0.6.0/TODO +0 -4
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta.rb +0 -76
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/datamapper.rb +0 -117
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/file.rb +0 -91
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memcache.rb +0 -52
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/memory.rb +0 -11
- data/vendor/gems/gems/wycats-moneta-0.6.0/lib/moneta/xattr.rb +0 -58
- data/vendor/gems/specifications/crack-0.1.1.gemspec +0 -29
- data/vendor/gems/specifications/fakeweb-1.2.5.gemspec +0 -34
- data/vendor/gems/specifications/json-1.1.3.gemspec +0 -33
- data/vendor/gems/specifications/rest-client-1.0.1.gemspec +0 -30
- data/vendor/gems/specifications/simple-rss-1.2.gemspec +0 -27
- data/vendor/gems/specifications/wycats-moneta-0.6.0.gemspec +0 -29
@@ -1,259 +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
|
-
\\["\\\/bfnrt] |
|
10
|
-
\\u[0-9a-fA-F]{4} |
|
11
|
-
\\[\x20-\xff])*)
|
12
|
-
"/nx
|
13
|
-
INTEGER = /(-?0|-?[1-9]\d*)/
|
14
|
-
FLOAT = /(-?
|
15
|
-
(?:0|[1-9]\d*)
|
16
|
-
(?:
|
17
|
-
\.\d+(?i:e[+-]?\d+) |
|
18
|
-
\.\d+ |
|
19
|
-
(?i:e[+-]?\d+)
|
20
|
-
)
|
21
|
-
)/x
|
22
|
-
NAN = /NaN/
|
23
|
-
INFINITY = /Infinity/
|
24
|
-
MINUS_INFINITY = /-Infinity/
|
25
|
-
OBJECT_OPEN = /\{/
|
26
|
-
OBJECT_CLOSE = /\}/
|
27
|
-
ARRAY_OPEN = /\[/
|
28
|
-
ARRAY_CLOSE = /\]/
|
29
|
-
PAIR_DELIMITER = /:/
|
30
|
-
COLLECTION_DELIMITER = /,/
|
31
|
-
TRUE = /true/
|
32
|
-
FALSE = /false/
|
33
|
-
NULL = /null/
|
34
|
-
IGNORE = %r(
|
35
|
-
(?:
|
36
|
-
//[^\n\r]*[\n\r]| # line comments
|
37
|
-
/\* # c-style comments
|
38
|
-
(?:
|
39
|
-
[^*/]| # normal chars
|
40
|
-
/[^*]| # slashes that do not start a nested comment
|
41
|
-
\*[^/]| # asterisks that do not end this comment
|
42
|
-
/(?=\*/) # single slash before this comment's end
|
43
|
-
)*
|
44
|
-
\*/ # the End of this comment
|
45
|
-
|[ \t\r\n]+ # whitespaces: space, horicontal tab, lf, cr
|
46
|
-
)+
|
47
|
-
)mx
|
48
|
-
|
49
|
-
UNPARSED = Object.new
|
50
|
-
|
51
|
-
# Creates a new JSON::Pure::Parser instance for the string _source_.
|
52
|
-
#
|
53
|
-
# It will be configured by the _opts_ hash. _opts_ can have the following
|
54
|
-
# keys:
|
55
|
-
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
|
56
|
-
# structures. Disable depth checking with :max_nesting => false|nil|0,
|
57
|
-
# it defaults to 19.
|
58
|
-
# * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
|
59
|
-
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
|
60
|
-
# to false.
|
61
|
-
# * *create_additions*: If set to false, the Parser doesn't create
|
62
|
-
# additions even if a matchin class and create_id was found. This option
|
63
|
-
# defaults to true.
|
64
|
-
def initialize(source, opts = {})
|
65
|
-
super
|
66
|
-
if !opts.key?(:max_nesting) # defaults to 19
|
67
|
-
@max_nesting = 19
|
68
|
-
elsif opts[:max_nesting]
|
69
|
-
@max_nesting = opts[:max_nesting]
|
70
|
-
else
|
71
|
-
@max_nesting = 0
|
72
|
-
end
|
73
|
-
@allow_nan = !!opts[:allow_nan]
|
74
|
-
ca = true
|
75
|
-
ca = opts[:create_additions] if opts.key?(:create_additions)
|
76
|
-
@create_id = ca ? JSON.create_id : nil
|
77
|
-
end
|
78
|
-
|
79
|
-
alias source string
|
80
|
-
|
81
|
-
# Parses the current JSON string _source_ and returns the complete data
|
82
|
-
# structure as a result.
|
83
|
-
def parse
|
84
|
-
reset
|
85
|
-
obj = nil
|
86
|
-
until eos?
|
87
|
-
case
|
88
|
-
when scan(OBJECT_OPEN)
|
89
|
-
obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
|
90
|
-
@current_nesting = 1
|
91
|
-
obj = parse_object
|
92
|
-
when scan(ARRAY_OPEN)
|
93
|
-
obj and raise ParserError, "source '#{peek(20)}' not in JSON!"
|
94
|
-
@current_nesting = 1
|
95
|
-
obj = parse_array
|
96
|
-
when skip(IGNORE)
|
97
|
-
;
|
98
|
-
else
|
99
|
-
raise ParserError, "source '#{peek(20)}' not in JSON!"
|
100
|
-
end
|
101
|
-
end
|
102
|
-
obj or raise ParserError, "source did not contain any JSON!"
|
103
|
-
obj
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
# Unescape characters in strings.
|
109
|
-
UNESCAPE_MAP = Hash.new { |h, k| h[k] = k.chr }
|
110
|
-
UNESCAPE_MAP.update({
|
111
|
-
?" => '"',
|
112
|
-
?\\ => '\\',
|
113
|
-
?/ => '/',
|
114
|
-
?b => "\b",
|
115
|
-
?f => "\f",
|
116
|
-
?n => "\n",
|
117
|
-
?r => "\r",
|
118
|
-
?t => "\t",
|
119
|
-
?u => nil,
|
120
|
-
})
|
121
|
-
|
122
|
-
def parse_string
|
123
|
-
if scan(STRING)
|
124
|
-
return '' if self[1].empty?
|
125
|
-
self[1].gsub(%r((?:\\[\\bfnrt"/]|(?:\\u(?:[A-Fa-f\d]{4}))+|\\[\x20-\xff]))n) do |c|
|
126
|
-
if u = UNESCAPE_MAP[$&[1]]
|
127
|
-
u
|
128
|
-
else # \uXXXX
|
129
|
-
bytes = ''
|
130
|
-
i = 0
|
131
|
-
while c[6 * i] == ?\\ && c[6 * i + 1] == ?u
|
132
|
-
bytes << c[6 * i + 2, 2].to_i(16) << c[6 * i + 4, 2].to_i(16)
|
133
|
-
i += 1
|
134
|
-
end
|
135
|
-
JSON::UTF16toUTF8.iconv(bytes)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
else
|
139
|
-
UNPARSED
|
140
|
-
end
|
141
|
-
rescue Iconv::Failure => e
|
142
|
-
raise GeneratorError, "Caught #{e.class}: #{e}"
|
143
|
-
end
|
144
|
-
|
145
|
-
def parse_value
|
146
|
-
case
|
147
|
-
when scan(FLOAT)
|
148
|
-
Float(self[1])
|
149
|
-
when scan(INTEGER)
|
150
|
-
Integer(self[1])
|
151
|
-
when scan(TRUE)
|
152
|
-
true
|
153
|
-
when scan(FALSE)
|
154
|
-
false
|
155
|
-
when scan(NULL)
|
156
|
-
nil
|
157
|
-
when (string = parse_string) != UNPARSED
|
158
|
-
string
|
159
|
-
when scan(ARRAY_OPEN)
|
160
|
-
@current_nesting += 1
|
161
|
-
ary = parse_array
|
162
|
-
@current_nesting -= 1
|
163
|
-
ary
|
164
|
-
when scan(OBJECT_OPEN)
|
165
|
-
@current_nesting += 1
|
166
|
-
obj = parse_object
|
167
|
-
@current_nesting -= 1
|
168
|
-
obj
|
169
|
-
when @allow_nan && scan(NAN)
|
170
|
-
NaN
|
171
|
-
when @allow_nan && scan(INFINITY)
|
172
|
-
Infinity
|
173
|
-
when @allow_nan && scan(MINUS_INFINITY)
|
174
|
-
MinusInfinity
|
175
|
-
else
|
176
|
-
UNPARSED
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
def parse_array
|
181
|
-
raise NestingError, "nesting of #@current_nesting is to deep" if
|
182
|
-
@max_nesting.nonzero? && @current_nesting > @max_nesting
|
183
|
-
result = []
|
184
|
-
delim = false
|
185
|
-
until eos?
|
186
|
-
case
|
187
|
-
when (value = parse_value) != UNPARSED
|
188
|
-
delim = false
|
189
|
-
result << value
|
190
|
-
skip(IGNORE)
|
191
|
-
if scan(COLLECTION_DELIMITER)
|
192
|
-
delim = true
|
193
|
-
elsif match?(ARRAY_CLOSE)
|
194
|
-
;
|
195
|
-
else
|
196
|
-
raise ParserError, "expected ',' or ']' in array at '#{peek(20)}'!"
|
197
|
-
end
|
198
|
-
when scan(ARRAY_CLOSE)
|
199
|
-
if delim
|
200
|
-
raise ParserError, "expected next element in array at '#{peek(20)}'!"
|
201
|
-
end
|
202
|
-
break
|
203
|
-
when skip(IGNORE)
|
204
|
-
;
|
205
|
-
else
|
206
|
-
raise ParserError, "unexpected token in array at '#{peek(20)}'!"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
result
|
210
|
-
end
|
211
|
-
|
212
|
-
def parse_object
|
213
|
-
raise NestingError, "nesting of #@current_nesting is to deep" if
|
214
|
-
@max_nesting.nonzero? && @current_nesting > @max_nesting
|
215
|
-
result = {}
|
216
|
-
delim = false
|
217
|
-
until eos?
|
218
|
-
case
|
219
|
-
when (string = parse_string) != UNPARSED
|
220
|
-
skip(IGNORE)
|
221
|
-
unless scan(PAIR_DELIMITER)
|
222
|
-
raise ParserError, "expected ':' in object at '#{peek(20)}'!"
|
223
|
-
end
|
224
|
-
skip(IGNORE)
|
225
|
-
unless (value = parse_value).equal? UNPARSED
|
226
|
-
result[string] = value
|
227
|
-
delim = false
|
228
|
-
skip(IGNORE)
|
229
|
-
if scan(COLLECTION_DELIMITER)
|
230
|
-
delim = true
|
231
|
-
elsif match?(OBJECT_CLOSE)
|
232
|
-
;
|
233
|
-
else
|
234
|
-
raise ParserError, "expected ',' or '}' in object at '#{peek(20)}'!"
|
235
|
-
end
|
236
|
-
else
|
237
|
-
raise ParserError, "expected value in object at '#{peek(20)}'!"
|
238
|
-
end
|
239
|
-
when scan(OBJECT_CLOSE)
|
240
|
-
if delim
|
241
|
-
raise ParserError, "expected next name, value pair in object at '#{peek(20)}'!"
|
242
|
-
end
|
243
|
-
if @create_id and klassname = result[@create_id]
|
244
|
-
klass = JSON.deep_const_get klassname
|
245
|
-
break unless klass and klass.json_creatable?
|
246
|
-
result = klass.json_create(result)
|
247
|
-
end
|
248
|
-
break
|
249
|
-
when skip(IGNORE)
|
250
|
-
;
|
251
|
-
else
|
252
|
-
raise ParserError, "unexpected token in object at '#{peek(20)}'!"
|
253
|
-
end
|
254
|
-
end
|
255
|
-
result
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module JSON
|
2
|
-
# JSON version
|
3
|
-
VERSION = '1.1.3'
|
4
|
-
VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
|
5
|
-
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
6
|
-
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
7
|
-
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
8
|
-
VARIANT_BINARY = false
|
9
|
-
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,}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
[
|
2
|
-
"JSON Test Pattern pass1",
|
3
|
-
{"object with 1 member":["array with 1 element"]},
|
4
|
-
{},
|
5
|
-
[],
|
6
|
-
-42,
|
7
|
-
true,
|
8
|
-
false,
|
9
|
-
null,
|
10
|
-
{
|
11
|
-
"integer": 1234567890,
|
12
|
-
"real": -9876.543210,
|
13
|
-
"e": 0.123456789e-12,
|
14
|
-
"E": 1.234567890E+34,
|
15
|
-
"": 23456789012E666,
|
16
|
-
"zero": 0,
|
17
|
-
"one": 1,
|
18
|
-
"space": " ",
|
19
|
-
"quote": "\"",
|
20
|
-
"backslash": "\\",
|
21
|
-
"controls": "\b\f\n\r\t",
|
22
|
-
"slash": "/ & \/",
|
23
|
-
"alpha": "abcdefghijklmnopqrstuvwyz",
|
24
|
-
"ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ",
|
25
|
-
"digit": "0123456789",
|
26
|
-
"special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?",
|
27
|
-
"hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A",
|
28
|
-
"true": true,
|
29
|
-
"false": false,
|
30
|
-
"null": null,
|
31
|
-
"array":[ ],
|
32
|
-
"object":{ },
|
33
|
-
"address": "50 St. James Street",
|
34
|
-
"url": "http://www.JSON.org/",
|
35
|
-
"comment": "// /* <!-- --",
|
36
|
-
"# -- --> */": " ",
|
37
|
-
" s p a c e d " :[1,2 , 3
|
38
|
-
|
39
|
-
,
|
40
|
-
|
41
|
-
4 , 5 , 6 ,7 ],
|
42
|
-
"compact": [1,2,3,4,5,6,7],
|
43
|
-
"jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}",
|
44
|
-
"quotes": "" \u0022 %22 0x22 034 "",
|
45
|
-
"\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?"
|
46
|
-
: "A key can be any string"
|
47
|
-
},
|
48
|
-
0.5 ,98.6
|
49
|
-
,
|
50
|
-
99.44
|
51
|
-
,
|
52
|
-
|
53
|
-
1066
|
54
|
-
|
55
|
-
|
56
|
-
,"rosebud"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Illegal backslash escape: \x15"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Illegal backslash escape: \'"]
|
@@ -1 +0,0 @@
|
|
1
|
-
["Illegal backslash escape: \017"]
|
@@ -1 +0,0 @@
|
|
1
|
-
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
|
@@ -1 +0,0 @@
|
|
1
|
-
["tab\ character\ in\ string\ "]
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'test/unit/ui/console/testrunner'
|
4
|
-
require 'test/unit/testsuite'
|
5
|
-
$:.unshift File.expand_path(File.dirname($0))
|
6
|
-
$:.unshift 'tests'
|
7
|
-
require 'test_json'
|
8
|
-
require 'test_json_generate'
|
9
|
-
require 'test_json_unicode'
|
10
|
-
require 'test_json_addition'
|
11
|
-
require 'test_json_rails'
|
12
|
-
require 'test_json_fixtures'
|
13
|
-
|
14
|
-
class TS_AllTests
|
15
|
-
def self.suite
|
16
|
-
suite = Test::Unit::TestSuite.new name
|
17
|
-
suite << TC_JSONGenerate.suite
|
18
|
-
suite << TC_JSON.suite
|
19
|
-
suite << TC_JSONUnicode.suite
|
20
|
-
suite << TC_JSONAddition.suite
|
21
|
-
suite << TC_JSONRails.suite
|
22
|
-
suite << TC_JSONFixtures.suite
|
23
|
-
end
|
24
|
-
end
|
25
|
-
Test::Unit::UI::Console::TestRunner.run(TS_AllTests)
|