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,35 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
|
3
|
-
*
|
4
|
-
* Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
|
5
|
-
* for details.
|
6
|
-
*/
|
7
|
-
package json.ext;
|
8
|
-
|
9
|
-
import java.io.IOException;
|
10
|
-
import java.lang.ref.WeakReference;
|
11
|
-
|
12
|
-
import org.jruby.Ruby;
|
13
|
-
import org.jruby.RubyClass;
|
14
|
-
import org.jruby.RubyModule;
|
15
|
-
import org.jruby.runtime.load.BasicLibraryService;
|
16
|
-
|
17
|
-
/**
|
18
|
-
* The service invoked by JRuby's {@link org.jruby.runtime.load.LoadService LoadService}.
|
19
|
-
* Defines the <code>JSON::Ext::Parser</code> class.
|
20
|
-
* @author mernen
|
21
|
-
*/
|
22
|
-
public class ParserService implements BasicLibraryService {
|
23
|
-
public boolean basicLoad(Ruby runtime) throws IOException {
|
24
|
-
runtime.getLoadService().require("json/common");
|
25
|
-
RuntimeInfo info = RuntimeInfo.initRuntime(runtime);
|
26
|
-
|
27
|
-
info.jsonModule = new WeakReference<RubyModule>(runtime.defineModule("JSON"));
|
28
|
-
RubyModule jsonExtModule = info.jsonModule.get().defineModuleUnder("Ext");
|
29
|
-
RubyClass parserClass =
|
30
|
-
jsonExtModule.defineClassUnder("Parser", runtime.getObject(),
|
31
|
-
Parser.ALLOCATOR);
|
32
|
-
parserClass.defineAnnotatedMethods(Parser.class);
|
33
|
-
return true;
|
34
|
-
}
|
35
|
-
}
|
@@ -1,121 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
|
3
|
-
*
|
4
|
-
* Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
|
5
|
-
* for details.
|
6
|
-
*/
|
7
|
-
package json.ext;
|
8
|
-
|
9
|
-
import java.lang.ref.WeakReference;
|
10
|
-
import java.util.HashMap;
|
11
|
-
import java.util.Map;
|
12
|
-
import java.util.WeakHashMap;
|
13
|
-
import org.jruby.Ruby;
|
14
|
-
import org.jruby.RubyClass;
|
15
|
-
import org.jruby.RubyEncoding;
|
16
|
-
import org.jruby.RubyModule;
|
17
|
-
import org.jruby.runtime.ThreadContext;
|
18
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
19
|
-
|
20
|
-
|
21
|
-
final class RuntimeInfo {
|
22
|
-
// since the vast majority of cases runs just one runtime,
|
23
|
-
// we optimize for that
|
24
|
-
private static WeakReference<Ruby> runtime1 = new WeakReference<Ruby>(null);
|
25
|
-
private static RuntimeInfo info1;
|
26
|
-
// store remaining runtimes here (does not include runtime1)
|
27
|
-
private static Map<Ruby, RuntimeInfo> runtimes;
|
28
|
-
|
29
|
-
// these fields are filled by the service loaders
|
30
|
-
// Use WeakReferences so that RuntimeInfo doesn't indirectly hold a hard reference to
|
31
|
-
// the Ruby runtime object, which would cause memory leaks in the runtimes map above.
|
32
|
-
/** JSON */
|
33
|
-
WeakReference<RubyModule> jsonModule;
|
34
|
-
/** JSON::Ext::Generator::GeneratorMethods::String::Extend */
|
35
|
-
WeakReference<RubyModule> stringExtendModule;
|
36
|
-
/** JSON::Ext::Generator::State */
|
37
|
-
WeakReference<RubyClass> generatorStateClass;
|
38
|
-
/** JSON::SAFE_STATE_PROTOTYPE */
|
39
|
-
WeakReference<GeneratorState> safeStatePrototype;
|
40
|
-
|
41
|
-
final WeakReference<RubyEncoding> utf8;
|
42
|
-
final WeakReference<RubyEncoding> ascii8bit;
|
43
|
-
// other encodings
|
44
|
-
private final Map<String, WeakReference<RubyEncoding>> encodings;
|
45
|
-
|
46
|
-
private RuntimeInfo(Ruby runtime) {
|
47
|
-
RubyClass encodingClass = runtime.getEncoding();
|
48
|
-
if (encodingClass == null) { // 1.8 mode
|
49
|
-
utf8 = ascii8bit = null;
|
50
|
-
encodings = null;
|
51
|
-
} else {
|
52
|
-
ThreadContext context = runtime.getCurrentContext();
|
53
|
-
|
54
|
-
utf8 = new WeakReference<RubyEncoding>((RubyEncoding)RubyEncoding.find(context,
|
55
|
-
encodingClass, runtime.newString("utf-8")));
|
56
|
-
ascii8bit = new WeakReference<RubyEncoding>((RubyEncoding)RubyEncoding.find(context,
|
57
|
-
encodingClass, runtime.newString("ascii-8bit")));
|
58
|
-
encodings = new HashMap<String, WeakReference<RubyEncoding>>();
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
static RuntimeInfo initRuntime(Ruby runtime) {
|
63
|
-
synchronized (RuntimeInfo.class) {
|
64
|
-
if (runtime1.get() == runtime) {
|
65
|
-
return info1;
|
66
|
-
} else if (runtime1.get() == null) {
|
67
|
-
runtime1 = new WeakReference<Ruby>(runtime);
|
68
|
-
info1 = new RuntimeInfo(runtime);
|
69
|
-
return info1;
|
70
|
-
} else {
|
71
|
-
if (runtimes == null) {
|
72
|
-
runtimes = new WeakHashMap<Ruby, RuntimeInfo>(1);
|
73
|
-
}
|
74
|
-
RuntimeInfo cache = runtimes.get(runtime);
|
75
|
-
if (cache == null) {
|
76
|
-
cache = new RuntimeInfo(runtime);
|
77
|
-
runtimes.put(runtime, cache);
|
78
|
-
}
|
79
|
-
return cache;
|
80
|
-
}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
|
84
|
-
public static RuntimeInfo forRuntime(Ruby runtime) {
|
85
|
-
synchronized (RuntimeInfo.class) {
|
86
|
-
if (runtime1.get() == runtime) return info1;
|
87
|
-
RuntimeInfo cache = null;
|
88
|
-
if (runtimes != null) cache = runtimes.get(runtime);
|
89
|
-
assert cache != null : "Runtime given has not initialized JSON::Ext";
|
90
|
-
return cache;
|
91
|
-
}
|
92
|
-
}
|
93
|
-
|
94
|
-
public boolean encodingsSupported() {
|
95
|
-
return utf8 != null && utf8.get() != null;
|
96
|
-
}
|
97
|
-
|
98
|
-
public RubyEncoding getEncoding(ThreadContext context, String name) {
|
99
|
-
synchronized (encodings) {
|
100
|
-
WeakReference<RubyEncoding> encoding = encodings.get(name);
|
101
|
-
if (encoding == null) {
|
102
|
-
Ruby runtime = context.getRuntime();
|
103
|
-
encoding = new WeakReference<RubyEncoding>((RubyEncoding)RubyEncoding.find(context,
|
104
|
-
runtime.getEncoding(), runtime.newString(name)));
|
105
|
-
encodings.put(name, encoding);
|
106
|
-
}
|
107
|
-
return encoding.get();
|
108
|
-
}
|
109
|
-
}
|
110
|
-
|
111
|
-
public GeneratorState getSafeStatePrototype(ThreadContext context) {
|
112
|
-
if (safeStatePrototype == null) {
|
113
|
-
IRubyObject value = jsonModule.get().getConstant("SAFE_STATE_PROTOTYPE");
|
114
|
-
if (!(value instanceof GeneratorState)) {
|
115
|
-
throw context.getRuntime().newTypeError(value, generatorStateClass.get());
|
116
|
-
}
|
117
|
-
safeStatePrototype = new WeakReference<GeneratorState>((GeneratorState)value);
|
118
|
-
}
|
119
|
-
return safeStatePrototype.get();
|
120
|
-
}
|
121
|
-
}
|
@@ -1,167 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
|
3
|
-
*
|
4
|
-
* Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
|
5
|
-
* for details.
|
6
|
-
*/
|
7
|
-
package json.ext;
|
8
|
-
|
9
|
-
import org.jruby.exceptions.RaiseException;
|
10
|
-
import org.jruby.runtime.ThreadContext;
|
11
|
-
import org.jruby.util.ByteList;
|
12
|
-
|
13
|
-
/**
|
14
|
-
* A decoder that reads a JSON-encoded string from the given sources and
|
15
|
-
* returns its decoded form on a new ByteList. Escaped Unicode characters
|
16
|
-
* are encoded as UTF-8.
|
17
|
-
*/
|
18
|
-
final class StringDecoder extends ByteListTranscoder {
|
19
|
-
/**
|
20
|
-
* Stores the offset of the high surrogate when reading a surrogate pair,
|
21
|
-
* or -1 when not.
|
22
|
-
*/
|
23
|
-
private int surrogatePairStart = -1;
|
24
|
-
|
25
|
-
// Array used for writing multi-byte characters into the buffer at once
|
26
|
-
private final byte[] aux = new byte[4];
|
27
|
-
|
28
|
-
StringDecoder(ThreadContext context) {
|
29
|
-
super(context);
|
30
|
-
}
|
31
|
-
|
32
|
-
ByteList decode(ByteList src, int start, int end) {
|
33
|
-
ByteList out = new ByteList(end - start);
|
34
|
-
out.setEncoding(src.getEncoding());
|
35
|
-
init(src, start, end, out);
|
36
|
-
while (hasNext()) {
|
37
|
-
handleChar(readUtf8Char());
|
38
|
-
}
|
39
|
-
quoteStop(pos);
|
40
|
-
return out;
|
41
|
-
}
|
42
|
-
|
43
|
-
private void handleChar(int c) {
|
44
|
-
if (c == '\\') {
|
45
|
-
quoteStop(charStart);
|
46
|
-
handleEscapeSequence();
|
47
|
-
} else {
|
48
|
-
quoteStart();
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
private void handleEscapeSequence() {
|
53
|
-
ensureMin(1);
|
54
|
-
switch (readUtf8Char()) {
|
55
|
-
case 'b':
|
56
|
-
append('\b');
|
57
|
-
break;
|
58
|
-
case 'f':
|
59
|
-
append('\f');
|
60
|
-
break;
|
61
|
-
case 'n':
|
62
|
-
append('\n');
|
63
|
-
break;
|
64
|
-
case 'r':
|
65
|
-
append('\r');
|
66
|
-
break;
|
67
|
-
case 't':
|
68
|
-
append('\t');
|
69
|
-
break;
|
70
|
-
case 'u':
|
71
|
-
ensureMin(4);
|
72
|
-
int cp = readHex();
|
73
|
-
if (Character.isHighSurrogate((char)cp)) {
|
74
|
-
handleLowSurrogate((char)cp);
|
75
|
-
} else if (Character.isLowSurrogate((char)cp)) {
|
76
|
-
// low surrogate with no high surrogate
|
77
|
-
throw invalidUtf8();
|
78
|
-
} else {
|
79
|
-
writeUtf8Char(cp);
|
80
|
-
}
|
81
|
-
break;
|
82
|
-
default: // '\\', '"', '/'...
|
83
|
-
quoteStart();
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
|
-
private void handleLowSurrogate(char highSurrogate) {
|
88
|
-
surrogatePairStart = charStart;
|
89
|
-
ensureMin(1);
|
90
|
-
int lowSurrogate = readUtf8Char();
|
91
|
-
|
92
|
-
if (lowSurrogate == '\\') {
|
93
|
-
ensureMin(5);
|
94
|
-
if (readUtf8Char() != 'u') throw invalidUtf8();
|
95
|
-
lowSurrogate = readHex();
|
96
|
-
}
|
97
|
-
|
98
|
-
if (Character.isLowSurrogate((char)lowSurrogate)) {
|
99
|
-
writeUtf8Char(Character.toCodePoint(highSurrogate,
|
100
|
-
(char)lowSurrogate));
|
101
|
-
surrogatePairStart = -1;
|
102
|
-
} else {
|
103
|
-
throw invalidUtf8();
|
104
|
-
}
|
105
|
-
}
|
106
|
-
|
107
|
-
private void writeUtf8Char(int codePoint) {
|
108
|
-
if (codePoint < 0x80) {
|
109
|
-
append(codePoint);
|
110
|
-
} else if (codePoint < 0x800) {
|
111
|
-
aux[0] = (byte)(0xc0 | (codePoint >>> 6));
|
112
|
-
aux[1] = tailByte(codePoint & 0x3f);
|
113
|
-
append(aux, 0, 2);
|
114
|
-
} else if (codePoint < 0x10000) {
|
115
|
-
aux[0] = (byte)(0xe0 | (codePoint >>> 12));
|
116
|
-
aux[1] = tailByte(codePoint >>> 6);
|
117
|
-
aux[2] = tailByte(codePoint);
|
118
|
-
append(aux, 0, 3);
|
119
|
-
} else {
|
120
|
-
aux[0] = (byte)(0xf0 | codePoint >>> 18);
|
121
|
-
aux[1] = tailByte(codePoint >>> 12);
|
122
|
-
aux[2] = tailByte(codePoint >>> 6);
|
123
|
-
aux[3] = tailByte(codePoint);
|
124
|
-
append(aux, 0, 4);
|
125
|
-
}
|
126
|
-
}
|
127
|
-
|
128
|
-
private byte tailByte(int value) {
|
129
|
-
return (byte)(0x80 | (value & 0x3f));
|
130
|
-
}
|
131
|
-
|
132
|
-
/**
|
133
|
-
* Reads a 4-digit unsigned hexadecimal number from the source.
|
134
|
-
*/
|
135
|
-
private int readHex() {
|
136
|
-
int numberStart = pos;
|
137
|
-
int result = 0;
|
138
|
-
int length = 4;
|
139
|
-
for (int i = 0; i < length; i++) {
|
140
|
-
int digit = readUtf8Char();
|
141
|
-
int digitValue;
|
142
|
-
if (digit >= '0' && digit <= '9') {
|
143
|
-
digitValue = digit - '0';
|
144
|
-
} else if (digit >= 'a' && digit <= 'f') {
|
145
|
-
digitValue = 10 + digit - 'a';
|
146
|
-
} else if (digit >= 'A' && digit <= 'F') {
|
147
|
-
digitValue = 10 + digit - 'A';
|
148
|
-
} else {
|
149
|
-
throw new NumberFormatException("Invalid base 16 number "
|
150
|
-
+ src.subSequence(numberStart, numberStart + length));
|
151
|
-
}
|
152
|
-
result = result * 16 + digitValue;
|
153
|
-
}
|
154
|
-
return result;
|
155
|
-
}
|
156
|
-
|
157
|
-
@Override
|
158
|
-
protected RaiseException invalidUtf8() {
|
159
|
-
ByteList message = new ByteList(
|
160
|
-
ByteList.plain("partial character in source, " +
|
161
|
-
"but hit end near "));
|
162
|
-
int start = surrogatePairStart != -1 ? surrogatePairStart : charStart;
|
163
|
-
message.append(src, start, srcEnd - start);
|
164
|
-
return Utils.newException(context, Utils.M_PARSER_ERROR,
|
165
|
-
context.getRuntime().newString(message));
|
166
|
-
}
|
167
|
-
}
|
@@ -1,106 +0,0 @@
|
|
1
|
-
package json.ext;
|
2
|
-
|
3
|
-
import org.jruby.exceptions.RaiseException;
|
4
|
-
import org.jruby.runtime.ThreadContext;
|
5
|
-
import org.jruby.util.ByteList;
|
6
|
-
|
7
|
-
/**
|
8
|
-
* An encoder that reads from the given source and outputs its representation
|
9
|
-
* to another ByteList. The source string is fully checked for UTF-8 validity,
|
10
|
-
* and throws a GeneratorError if any problem is found.
|
11
|
-
*/
|
12
|
-
final class StringEncoder extends ByteListTranscoder {
|
13
|
-
private final boolean asciiOnly;
|
14
|
-
|
15
|
-
// Escaped characters will reuse this array, to avoid new allocations
|
16
|
-
// or appending them byte-by-byte
|
17
|
-
private final byte[] aux =
|
18
|
-
new byte[] {/* First unicode character */
|
19
|
-
'\\', 'u', 0, 0, 0, 0,
|
20
|
-
/* Second unicode character (for surrogate pairs) */
|
21
|
-
'\\', 'u', 0, 0, 0, 0,
|
22
|
-
/* "\X" characters */
|
23
|
-
'\\', 0};
|
24
|
-
// offsets on the array above
|
25
|
-
private static final int ESCAPE_UNI1_OFFSET = 0;
|
26
|
-
private static final int ESCAPE_UNI2_OFFSET = ESCAPE_UNI1_OFFSET + 6;
|
27
|
-
private static final int ESCAPE_CHAR_OFFSET = ESCAPE_UNI2_OFFSET + 6;
|
28
|
-
/** Array used for code point decomposition in surrogates */
|
29
|
-
private final char[] utf16 = new char[2];
|
30
|
-
|
31
|
-
private static final byte[] HEX =
|
32
|
-
new byte[] {'0', '1', '2', '3', '4', '5', '6', '7',
|
33
|
-
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
|
34
|
-
|
35
|
-
StringEncoder(ThreadContext context, boolean asciiOnly) {
|
36
|
-
super(context);
|
37
|
-
this.asciiOnly = asciiOnly;
|
38
|
-
}
|
39
|
-
|
40
|
-
void encode(ByteList src, ByteList out) {
|
41
|
-
init(src, out);
|
42
|
-
append('"');
|
43
|
-
while (hasNext()) {
|
44
|
-
handleChar(readUtf8Char());
|
45
|
-
}
|
46
|
-
quoteStop(pos);
|
47
|
-
append('"');
|
48
|
-
}
|
49
|
-
|
50
|
-
private void handleChar(int c) {
|
51
|
-
switch (c) {
|
52
|
-
case '"':
|
53
|
-
case '\\':
|
54
|
-
escapeChar((char)c);
|
55
|
-
break;
|
56
|
-
case '\n':
|
57
|
-
escapeChar('n');
|
58
|
-
break;
|
59
|
-
case '\r':
|
60
|
-
escapeChar('r');
|
61
|
-
break;
|
62
|
-
case '\t':
|
63
|
-
escapeChar('t');
|
64
|
-
break;
|
65
|
-
case '\f':
|
66
|
-
escapeChar('f');
|
67
|
-
break;
|
68
|
-
case '\b':
|
69
|
-
escapeChar('b');
|
70
|
-
break;
|
71
|
-
default:
|
72
|
-
if (c >= 0x20 && c <= 0x7f ||
|
73
|
-
(c >= 0x80 && !asciiOnly)) {
|
74
|
-
quoteStart();
|
75
|
-
} else {
|
76
|
-
quoteStop(charStart);
|
77
|
-
escapeUtf8Char(c);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
private void escapeChar(char c) {
|
83
|
-
quoteStop(charStart);
|
84
|
-
aux[ESCAPE_CHAR_OFFSET + 1] = (byte)c;
|
85
|
-
append(aux, ESCAPE_CHAR_OFFSET, 2);
|
86
|
-
}
|
87
|
-
|
88
|
-
private void escapeUtf8Char(int codePoint) {
|
89
|
-
int numChars = Character.toChars(codePoint, utf16, 0);
|
90
|
-
escapeCodeUnit(utf16[0], ESCAPE_UNI1_OFFSET + 2);
|
91
|
-
if (numChars > 1) escapeCodeUnit(utf16[1], ESCAPE_UNI2_OFFSET + 2);
|
92
|
-
append(aux, ESCAPE_UNI1_OFFSET, 6 * numChars);
|
93
|
-
}
|
94
|
-
|
95
|
-
private void escapeCodeUnit(char c, int auxOffset) {
|
96
|
-
for (int i = 0; i < 4; i++) {
|
97
|
-
aux[auxOffset + i] = HEX[(c >>> (12 - 4 * i)) & 0xf];
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
@Override
|
102
|
-
protected RaiseException invalidUtf8() {
|
103
|
-
return Utils.newException(context, Utils.M_GENERATOR_ERROR,
|
104
|
-
"source sequence is illegal/malformed utf-8");
|
105
|
-
}
|
106
|
-
}
|
@@ -1,89 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This code is copyrighted work by Daniel Luz <dev at mernen dot com>.
|
3
|
-
*
|
4
|
-
* Distributed under the Ruby and GPLv2 licenses; see COPYING and GPL files
|
5
|
-
* for details.
|
6
|
-
*/
|
7
|
-
package json.ext;
|
8
|
-
|
9
|
-
import org.jruby.Ruby;
|
10
|
-
import org.jruby.RubyArray;
|
11
|
-
import org.jruby.RubyClass;
|
12
|
-
import org.jruby.RubyException;
|
13
|
-
import org.jruby.RubyHash;
|
14
|
-
import org.jruby.RubyString;
|
15
|
-
import org.jruby.exceptions.RaiseException;
|
16
|
-
import org.jruby.runtime.Block;
|
17
|
-
import org.jruby.runtime.ThreadContext;
|
18
|
-
import org.jruby.runtime.builtin.IRubyObject;
|
19
|
-
import org.jruby.util.ByteList;
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Library of miscellaneous utility functions
|
23
|
-
*/
|
24
|
-
final class Utils {
|
25
|
-
public static final String M_GENERATOR_ERROR = "GeneratorError";
|
26
|
-
public static final String M_NESTING_ERROR = "NestingError";
|
27
|
-
public static final String M_PARSER_ERROR = "ParserError";
|
28
|
-
|
29
|
-
private Utils() {
|
30
|
-
throw new RuntimeException();
|
31
|
-
}
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Safe {@link RubyArray} type-checking.
|
35
|
-
* Returns the given object if it is an <code>Array</code>,
|
36
|
-
* or throws an exception if not.
|
37
|
-
* @param object The object to test
|
38
|
-
* @return The given object if it is an <code>Array</code>
|
39
|
-
* @throws RaiseException <code>TypeError</code> if the object is not
|
40
|
-
* of the expected type
|
41
|
-
*/
|
42
|
-
static RubyArray ensureArray(IRubyObject object) throws RaiseException {
|
43
|
-
if (object instanceof RubyArray) return (RubyArray)object;
|
44
|
-
Ruby runtime = object.getRuntime();
|
45
|
-
throw runtime.newTypeError(object, runtime.getArray());
|
46
|
-
}
|
47
|
-
|
48
|
-
static RubyHash ensureHash(IRubyObject object) throws RaiseException {
|
49
|
-
if (object instanceof RubyHash) return (RubyHash)object;
|
50
|
-
Ruby runtime = object.getRuntime();
|
51
|
-
throw runtime.newTypeError(object, runtime.getHash());
|
52
|
-
}
|
53
|
-
|
54
|
-
static RubyString ensureString(IRubyObject object) throws RaiseException {
|
55
|
-
if (object instanceof RubyString) return (RubyString)object;
|
56
|
-
Ruby runtime = object.getRuntime();
|
57
|
-
throw runtime.newTypeError(object, runtime.getString());
|
58
|
-
}
|
59
|
-
|
60
|
-
static RaiseException newException(ThreadContext context,
|
61
|
-
String className, String message) {
|
62
|
-
return newException(context, className,
|
63
|
-
context.getRuntime().newString(message));
|
64
|
-
}
|
65
|
-
|
66
|
-
static RaiseException newException(ThreadContext context,
|
67
|
-
String className, RubyString message) {
|
68
|
-
RuntimeInfo info = RuntimeInfo.forRuntime(context.getRuntime());
|
69
|
-
RubyClass klazz = info.jsonModule.get().getClass(className);
|
70
|
-
RubyException excptn =
|
71
|
-
(RubyException)klazz.newInstance(context,
|
72
|
-
new IRubyObject[] {message}, Block.NULL_BLOCK);
|
73
|
-
return new RaiseException(excptn);
|
74
|
-
}
|
75
|
-
|
76
|
-
static byte[] repeat(ByteList a, int n) {
|
77
|
-
return repeat(a.unsafeBytes(), a.begin(), a.length(), n);
|
78
|
-
}
|
79
|
-
|
80
|
-
static byte[] repeat(byte[] a, int begin, int length, int n) {
|
81
|
-
if (length == 0) return ByteList.NULL_ARRAY;
|
82
|
-
int resultLen = length * n;
|
83
|
-
byte[] result = new byte[resultLen];
|
84
|
-
for (int pos = 0; pos < resultLen; pos += length) {
|
85
|
-
System.arraycopy(a, begin, result, pos, length);
|
86
|
-
}
|
87
|
-
return result;
|
88
|
-
}
|
89
|
-
}
|