benschwarz-smoke 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +47 -0
- data/VERSION.yml +2 -2
- data/lib/core_ext/string.rb +6 -0
- data/lib/smoke/cache.rb +38 -23
- data/lib/smoke/request.rb +4 -8
- data/lib/smoke.rb +7 -2
- data/rdoc/classes/Smoke/Origin.html +340 -0
- data/rdoc/classes/Smoke/Source/Data.html +126 -0
- data/rdoc/classes/Smoke/Source/Feed.html +117 -0
- data/rdoc/classes/Smoke/Source/YQL.html +223 -0
- data/rdoc/classes/Smoke.html +260 -0
- data/rdoc/created.rid +1 -0
- data/rdoc/files/README_markdown.html +180 -0
- data/rdoc/files/lib/core_ext/hash_rb.html +49 -0
- data/rdoc/files/lib/smoke/origin_rb.html +49 -0
- data/rdoc/files/lib/smoke/request_rb.html +49 -0
- data/rdoc/files/lib/smoke/source/data_rb.html +49 -0
- data/rdoc/files/lib/smoke/source/feed_rb.html +49 -0
- data/rdoc/files/lib/smoke/source/join_rb.html +49 -0
- data/rdoc/files/lib/smoke/source/yql_rb.html +49 -0
- data/rdoc/files/lib/smoke_rb.html +65 -0
- data/rdoc/fr_class_index.html +21 -0
- data/rdoc/fr_file_index.html +28 -0
- data/rdoc/fr_method_index.html +4459 -0
- data/rdoc/index.html +15 -0
- data/rdoc/rdoc-style.css +319 -0
- data/spec/smoke/cache_spec.rb +28 -6
- data/vendor/crack/History +15 -0
- data/vendor/crack/LICENSE +20 -0
- data/vendor/crack/README.rdoc +42 -0
- data/vendor/crack/Rakefile +49 -0
- data/vendor/crack/VERSION.yml +4 -0
- data/vendor/crack/crack.gemspec +61 -0
- data/vendor/crack/lib/crack/core_extensions.rb +128 -0
- data/vendor/crack/lib/crack/json.rb +68 -0
- data/vendor/crack/lib/crack/xml.rb +214 -0
- data/vendor/crack/lib/crack.rb +7 -0
- data/vendor/crack/test/crack_test.rb +4 -0
- data/vendor/crack/test/data/twittersearch-firefox.json +1 -0
- data/vendor/crack/test/data/twittersearch-ie.json +1 -0
- data/vendor/crack/test/hash_test.rb +56 -0
- data/vendor/crack/test/json_test.rb +66 -0
- data/vendor/crack/test/string_test.rb +31 -0
- data/vendor/crack/test/test_helper.rb +12 -0
- data/vendor/crack/test/xml_test.rb +489 -0
- data/vendor/dependencies/README.markdown +113 -0
- data/vendor/dependencies/Rakefile +5 -0
- data/vendor/dependencies/bin/dep +83 -0
- data/vendor/dependencies/dependencies.gemspec +15 -0
- data/vendor/dependencies/dependencies.gemspec.erb +27 -0
- data/vendor/dependencies/lib/dependencies/dep.rb +99 -0
- data/vendor/dependencies/lib/dependencies.rb +5 -0
- data/vendor/dependencies/test/dependencies_test.rb +228 -0
- data/vendor/dependencies/test/foobaz-0.3.gem +0 -0
- data/vendor/fakeweb/CHANGELOG +163 -0
- data/vendor/fakeweb/LICENSE.txt +281 -0
- data/vendor/fakeweb/README.rdoc +193 -0
- data/vendor/fakeweb/Rakefile +76 -0
- data/vendor/fakeweb/fakeweb.gemspec +21 -0
- data/vendor/fakeweb/lib/fake_web/ext/net_http.rb +71 -0
- data/vendor/fakeweb/lib/fake_web/registry.rb +103 -0
- data/vendor/fakeweb/lib/fake_web/responder.rb +113 -0
- data/vendor/fakeweb/lib/fake_web/response.rb +10 -0
- data/vendor/fakeweb/lib/fake_web/stub_socket.rb +15 -0
- data/vendor/fakeweb/lib/fake_web/utility.rb +22 -0
- data/vendor/fakeweb/lib/fake_web.rb +172 -0
- data/vendor/fakeweb/lib/fakeweb.rb +2 -0
- data/vendor/fakeweb/test/fixtures/google_response_from_curl +12 -0
- data/vendor/fakeweb/test/fixtures/google_response_with_transfer_encoding +17 -0
- data/vendor/fakeweb/test/fixtures/google_response_without_transfer_encoding +11 -0
- data/vendor/fakeweb/test/fixtures/test_example.txt +1 -0
- data/vendor/fakeweb/test/fixtures/test_txt_file +3 -0
- data/vendor/fakeweb/test/test_allow_net_connect.rb +85 -0
- data/vendor/fakeweb/test/test_deprecations.rb +54 -0
- data/vendor/fakeweb/test/test_fake_authentication.rb +92 -0
- data/vendor/fakeweb/test/test_fake_web.rb +535 -0
- data/vendor/fakeweb/test/test_fake_web_open_uri.rb +58 -0
- data/vendor/fakeweb/test/test_helper.rb +74 -0
- data/vendor/fakeweb/test/test_missing_open_uri.rb +25 -0
- data/vendor/fakeweb/test/test_precedence.rb +51 -0
- data/vendor/fakeweb/test/test_query_string.rb +45 -0
- data/vendor/fakeweb/test/test_regexes.rb +103 -0
- data/vendor/fakeweb/test/test_response_headers.rb +73 -0
- data/vendor/fakeweb/test/test_trailing_slashes.rb +53 -0
- data/vendor/fakeweb/test/test_utility.rb +70 -0
- data/vendor/json-1.1.3/CHANGES +93 -0
- data/vendor/json-1.1.3/GPL +340 -0
- data/vendor/json-1.1.3/README +78 -0
- data/vendor/json-1.1.3/RUBY +58 -0
- data/vendor/json-1.1.3/Rakefile +309 -0
- data/vendor/json-1.1.3/TODO +1 -0
- data/vendor/json-1.1.3/VERSION +1 -0
- data/vendor/json-1.1.3/benchmarks/benchmark.txt +133 -0
- data/vendor/json-1.1.3/benchmarks/benchmark_generator.rb +48 -0
- data/vendor/json-1.1.3/benchmarks/benchmark_parser.rb +26 -0
- data/vendor/json-1.1.3/benchmarks/benchmark_rails.rb +26 -0
- data/vendor/json-1.1.3/bin/edit_json.rb +10 -0
- data/vendor/json-1.1.3/bin/prettify_json.rb +76 -0
- data/vendor/json-1.1.3/data/example.json +1 -0
- data/vendor/json-1.1.3/data/index.html +38 -0
- data/vendor/json-1.1.3/data/prototype.js +4184 -0
- data/vendor/json-1.1.3/ext/json/ext/generator/extconf.rb +9 -0
- data/vendor/json-1.1.3/ext/json/ext/generator/generator.c +875 -0
- data/vendor/json-1.1.3/ext/json/ext/generator/unicode.c +182 -0
- data/vendor/json-1.1.3/ext/json/ext/generator/unicode.h +53 -0
- data/vendor/json-1.1.3/ext/json/ext/parser/extconf.rb +9 -0
- data/vendor/json-1.1.3/ext/json/ext/parser/parser.c +1758 -0
- data/vendor/json-1.1.3/ext/json/ext/parser/parser.rl +638 -0
- data/vendor/json-1.1.3/ext/json/ext/parser/unicode.c +154 -0
- data/vendor/json-1.1.3/ext/json/ext/parser/unicode.h +58 -0
- data/vendor/json-1.1.3/install.rb +26 -0
- data/vendor/json-1.1.3/lib/json/Array.xpm +21 -0
- data/vendor/json-1.1.3/lib/json/FalseClass.xpm +21 -0
- data/vendor/json-1.1.3/lib/json/Hash.xpm +21 -0
- data/vendor/json-1.1.3/lib/json/Key.xpm +73 -0
- data/vendor/json-1.1.3/lib/json/NilClass.xpm +21 -0
- data/vendor/json-1.1.3/lib/json/Numeric.xpm +28 -0
- data/vendor/json-1.1.3/lib/json/String.xpm +96 -0
- data/vendor/json-1.1.3/lib/json/TrueClass.xpm +21 -0
- data/vendor/json-1.1.3/lib/json/add/core.rb +135 -0
- data/vendor/json-1.1.3/lib/json/add/rails.rb +58 -0
- data/vendor/json-1.1.3/lib/json/common.rb +354 -0
- data/vendor/json-1.1.3/lib/json/editor.rb +1362 -0
- data/vendor/json-1.1.3/lib/json/ext.rb +13 -0
- data/vendor/json-1.1.3/lib/json/json.xpm +1499 -0
- data/vendor/json-1.1.3/lib/json/pure/generator.rb +394 -0
- data/vendor/json-1.1.3/lib/json/pure/parser.rb +259 -0
- data/vendor/json-1.1.3/lib/json/pure.rb +75 -0
- data/vendor/json-1.1.3/lib/json/version.rb +9 -0
- data/vendor/json-1.1.3/lib/json.rb +235 -0
- data/vendor/json-1.1.3/tests/fixtures/fail1.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail10.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail11.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail12.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail13.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail14.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail18.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail19.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail2.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail20.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail21.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail22.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail23.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail24.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail25.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail27.json +2 -0
- data/vendor/json-1.1.3/tests/fixtures/fail28.json +2 -0
- data/vendor/json-1.1.3/tests/fixtures/fail3.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail4.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail5.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail6.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail7.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail8.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/fail9.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/pass1.json +56 -0
- data/vendor/json-1.1.3/tests/fixtures/pass15.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/pass16.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/pass17.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/pass2.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/pass26.json +1 -0
- data/vendor/json-1.1.3/tests/fixtures/pass3.json +6 -0
- data/vendor/json-1.1.3/tests/runner.rb +25 -0
- data/vendor/json-1.1.3/tests/test_json.rb +293 -0
- data/vendor/json-1.1.3/tests/test_json_addition.rb +161 -0
- data/vendor/json-1.1.3/tests/test_json_fixtures.rb +30 -0
- data/vendor/json-1.1.3/tests/test_json_generate.rb +100 -0
- data/vendor/json-1.1.3/tests/test_json_rails.rb +118 -0
- data/vendor/json-1.1.3/tests/test_json_unicode.rb +61 -0
- data/vendor/json-1.1.3/tools/fuzz.rb +140 -0
- data/vendor/json-1.1.3/tools/server.rb +62 -0
- data/vendor/moneta/LICENSE +20 -0
- data/vendor/moneta/README +51 -0
- data/vendor/moneta/Rakefile +60 -0
- data/vendor/moneta/TODO +4 -0
- data/vendor/moneta/benchmarks/various.rb +234 -0
- data/vendor/moneta/lib/moneta/basic_file.rb +111 -0
- data/vendor/moneta/lib/moneta/berkeley.rb +53 -0
- data/vendor/moneta/lib/moneta/couch.rb +63 -0
- data/vendor/moneta/lib/moneta/datamapper.rb +117 -0
- data/vendor/moneta/lib/moneta/file.rb +91 -0
- data/vendor/moneta/lib/moneta/lmc.rb +52 -0
- data/vendor/moneta/lib/moneta/memcache.rb +53 -0
- data/vendor/moneta/lib/moneta/memory.rb +11 -0
- data/vendor/moneta/lib/moneta/mongodb.rb +58 -0
- data/vendor/moneta/lib/moneta/redis.rb +49 -0
- data/vendor/moneta/lib/moneta/rufus.rb +41 -0
- data/vendor/moneta/lib/moneta/s3.rb +162 -0
- data/vendor/moneta/lib/moneta/sdbm.rb +33 -0
- data/vendor/moneta/lib/moneta/tyrant.rb +58 -0
- data/vendor/moneta/lib/moneta/xattr.rb +58 -0
- data/vendor/moneta/lib/moneta.rb +76 -0
- data/vendor/moneta/moneta.gemspec +32 -0
- data/vendor/moneta/script/destroy +14 -0
- data/vendor/moneta/script/generate +14 -0
- data/vendor/moneta/spec/moneta_basic_file_spec.rb +50 -0
- data/vendor/moneta/spec/moneta_berkeley_spec.rb +20 -0
- data/vendor/moneta/spec/moneta_couch_spec.rb +22 -0
- data/vendor/moneta/spec/moneta_datamapper_spec.rb +79 -0
- data/vendor/moneta/spec/moneta_file_spec.rb +21 -0
- data/vendor/moneta/spec/moneta_lmc_spec.rb +24 -0
- data/vendor/moneta/spec/moneta_memcache_spec.rb +16 -0
- data/vendor/moneta/spec/moneta_memory_spec.rb +12 -0
- data/vendor/moneta/spec/moneta_mongodb_spec.rb +16 -0
- data/vendor/moneta/spec/moneta_redis_spec.rb +16 -0
- data/vendor/moneta/spec/moneta_rufus_spec.rb +15 -0
- data/vendor/moneta/spec/moneta_s3_spec.rb +19 -0
- data/vendor/moneta/spec/moneta_sdbm_spec.rb +21 -0
- data/vendor/moneta/spec/moneta_tyrant_spec.rb +15 -0
- data/vendor/moneta/spec/moneta_xattr_spec.rb +21 -0
- data/vendor/moneta/spec/shared.rb +122 -0
- data/vendor/moneta/spec/spec_helper.rb +7 -0
- data/vendor/rest-client/README.rdoc +151 -0
- data/vendor/rest-client/Rakefile +58 -0
- data/vendor/rest-client/VERSION +1 -0
- data/vendor/rest-client/bin/restclient +87 -0
- data/vendor/rest-client/lib/rest_client.rb +2 -0
- data/vendor/rest-client/lib/restclient/exceptions.rb +88 -0
- data/vendor/rest-client/lib/restclient/mixin/response.rb +43 -0
- data/vendor/rest-client/lib/restclient/raw_response.rb +30 -0
- data/vendor/rest-client/lib/restclient/request.rb +238 -0
- data/vendor/rest-client/lib/restclient/resource.rb +146 -0
- data/vendor/rest-client/lib/restclient/response.rb +20 -0
- data/vendor/rest-client/lib/restclient.rb +99 -0
- data/vendor/rest-client/rest-client.gemspec +66 -0
- data/vendor/rest-client/spec/base.rb +4 -0
- data/vendor/rest-client/spec/exceptions_spec.rb +65 -0
- data/vendor/rest-client/spec/mixin/response_spec.rb +46 -0
- data/vendor/rest-client/spec/raw_response_spec.rb +17 -0
- data/vendor/rest-client/spec/request_spec.rb +476 -0
- data/vendor/rest-client/spec/resource_spec.rb +75 -0
- data/vendor/rest-client/spec/response_spec.rb +16 -0
- data/vendor/rest-client/spec/restclient_spec.rb +53 -0
- data/vendor/simple-rss/LICENSE +429 -0
- data/vendor/simple-rss/README +43 -0
- data/vendor/simple-rss/Rakefile +212 -0
- data/vendor/simple-rss/install.rb +40 -0
- data/vendor/simple-rss/lib/simple-rss.rb +150 -0
- data/vendor/simple-rss/simple-rss.gemspec +12 -0
- data/vendor/simple-rss/test/base/base_test.rb +51 -0
- data/vendor/simple-rss/test/data/atom.xml +45 -0
- data/vendor/simple-rss/test/data/not-rss.xml +8 -0
- data/vendor/simple-rss/test/data/rss09.rdf +79 -0
- data/vendor/simple-rss/test/data/rss20.xml +818 -0
- data/vendor/simple-rss/test/test_helper.rb +4 -0
- metadata +314 -40
@@ -0,0 +1,154 @@
|
|
1
|
+
#include "unicode.h"
|
2
|
+
|
3
|
+
/*
|
4
|
+
* Copyright 2001-2004 Unicode, Inc.
|
5
|
+
*
|
6
|
+
* Disclaimer
|
7
|
+
*
|
8
|
+
* This source code is provided as is by Unicode, Inc. No claims are
|
9
|
+
* made as to fitness for any particular purpose. No warranties of any
|
10
|
+
* kind are expressed or implied. The recipient agrees to determine
|
11
|
+
* applicability of information provided. If this file has been
|
12
|
+
* purchased on magnetic or optical media from Unicode, Inc., the
|
13
|
+
* sole remedy for any claim will be exchange of defective media
|
14
|
+
* within 90 days of receipt.
|
15
|
+
*
|
16
|
+
* Limitations on Rights to Redistribute This Code
|
17
|
+
*
|
18
|
+
* Unicode, Inc. hereby grants the right to freely use the information
|
19
|
+
* supplied in this file in the creation of products supporting the
|
20
|
+
* Unicode Standard, and to make copies of this file in any form
|
21
|
+
* for internal or external distribution as long as this notice
|
22
|
+
* remains attached.
|
23
|
+
*/
|
24
|
+
|
25
|
+
/*
|
26
|
+
* Index into the table below with the first byte of a UTF-8 sequence to
|
27
|
+
* get the number of trailing bytes that are supposed to follow it.
|
28
|
+
* Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
|
29
|
+
* left as-is for anyone who may want to do such conversion, which was
|
30
|
+
* allowed in earlier algorithms.
|
31
|
+
*/
|
32
|
+
static const char trailingBytesForUTF8[256] = {
|
33
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
34
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
35
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
36
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
37
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
38
|
+
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
39
|
+
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
40
|
+
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
|
41
|
+
};
|
42
|
+
|
43
|
+
/*
|
44
|
+
* Magic values subtracted from a buffer value during UTF8 conversion.
|
45
|
+
* This table contains as many values as there might be trailing bytes
|
46
|
+
* in a UTF-8 sequence.
|
47
|
+
*/
|
48
|
+
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
|
49
|
+
0x03C82080UL, 0xFA082080UL, 0x82082080UL };
|
50
|
+
|
51
|
+
/*
|
52
|
+
* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
|
53
|
+
* into the first byte, depending on how many bytes follow. There are
|
54
|
+
* as many entries in this table as there are UTF-8 sequence types.
|
55
|
+
* (I.e., one byte sequence, two byte... etc.). Remember that sequencs
|
56
|
+
* for *legal* UTF-8 will be 4 or fewer bytes total.
|
57
|
+
*/
|
58
|
+
static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
|
59
|
+
|
60
|
+
char *JSON_convert_UTF16_to_UTF8 (
|
61
|
+
VALUE buffer,
|
62
|
+
char *source,
|
63
|
+
char *sourceEnd,
|
64
|
+
ConversionFlags flags)
|
65
|
+
{
|
66
|
+
UTF16 *tmp, *tmpPtr, *tmpEnd;
|
67
|
+
char buf[5];
|
68
|
+
long n = 0, i;
|
69
|
+
char *p = source - 1;
|
70
|
+
|
71
|
+
while (p < sourceEnd && p[0] == '\\' && p[1] == 'u') {
|
72
|
+
p += 6;
|
73
|
+
n++;
|
74
|
+
}
|
75
|
+
p = source + 1;
|
76
|
+
buf[4] = 0;
|
77
|
+
tmpPtr = tmp = ALLOC_N(UTF16, n);
|
78
|
+
tmpEnd = tmp + n;
|
79
|
+
for (i = 0; i < n; i++) {
|
80
|
+
buf[0] = *p++;
|
81
|
+
buf[1] = *p++;
|
82
|
+
buf[2] = *p++;
|
83
|
+
buf[3] = *p++;
|
84
|
+
tmpPtr[i] = strtol(buf, NULL, 16);
|
85
|
+
p += 2;
|
86
|
+
}
|
87
|
+
|
88
|
+
while (tmpPtr < tmpEnd) {
|
89
|
+
UTF32 ch;
|
90
|
+
unsigned short bytesToWrite = 0;
|
91
|
+
const UTF32 byteMask = 0xBF;
|
92
|
+
const UTF32 byteMark = 0x80;
|
93
|
+
ch = *tmpPtr++;
|
94
|
+
/* If we have a surrogate pair, convert to UTF32 first. */
|
95
|
+
if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
|
96
|
+
/* If the 16 bits following the high surrogate are in the source
|
97
|
+
* buffer... */
|
98
|
+
if (tmpPtr < tmpEnd) {
|
99
|
+
UTF32 ch2 = *tmpPtr;
|
100
|
+
/* If it's a low surrogate, convert to UTF32. */
|
101
|
+
if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
|
102
|
+
ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
|
103
|
+
+ (ch2 - UNI_SUR_LOW_START) + halfBase;
|
104
|
+
++tmpPtr;
|
105
|
+
} else if (flags == strictConversion) { /* it's an unpaired high surrogate */
|
106
|
+
free(tmp);
|
107
|
+
rb_raise(rb_path2class("JSON::ParserError"),
|
108
|
+
"source sequence is illegal/malformed near %s", source);
|
109
|
+
}
|
110
|
+
} else { /* We don't have the 16 bits following the high surrogate. */
|
111
|
+
free(tmp);
|
112
|
+
rb_raise(rb_path2class("JSON::ParserError"),
|
113
|
+
"partial character in source, but hit end near %s", source);
|
114
|
+
break;
|
115
|
+
}
|
116
|
+
} else if (flags == strictConversion) {
|
117
|
+
/* UTF-16 surrogate values are illegal in UTF-32 */
|
118
|
+
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
|
119
|
+
free(tmp);
|
120
|
+
rb_raise(rb_path2class("JSON::ParserError"),
|
121
|
+
"source sequence is illegal/malformed near %s", source);
|
122
|
+
}
|
123
|
+
}
|
124
|
+
/* Figure out how many bytes the result will require */
|
125
|
+
if (ch < (UTF32) 0x80) {
|
126
|
+
bytesToWrite = 1;
|
127
|
+
} else if (ch < (UTF32) 0x800) {
|
128
|
+
bytesToWrite = 2;
|
129
|
+
} else if (ch < (UTF32) 0x10000) {
|
130
|
+
bytesToWrite = 3;
|
131
|
+
} else if (ch < (UTF32) 0x110000) {
|
132
|
+
bytesToWrite = 4;
|
133
|
+
} else {
|
134
|
+
bytesToWrite = 3;
|
135
|
+
ch = UNI_REPLACEMENT_CHAR;
|
136
|
+
}
|
137
|
+
|
138
|
+
buf[0] = 0;
|
139
|
+
buf[1] = 0;
|
140
|
+
buf[2] = 0;
|
141
|
+
buf[3] = 0;
|
142
|
+
p = buf + bytesToWrite;
|
143
|
+
switch (bytesToWrite) { /* note: everything falls through. */
|
144
|
+
case 4: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
|
145
|
+
case 3: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
|
146
|
+
case 2: *--p = (UTF8) ((ch | byteMark) & byteMask); ch >>= 6;
|
147
|
+
case 1: *--p = (UTF8) (ch | firstByteMark[bytesToWrite]);
|
148
|
+
}
|
149
|
+
rb_str_buf_cat(buffer, p, bytesToWrite);
|
150
|
+
}
|
151
|
+
free(tmp);
|
152
|
+
source += 5 + (n - 1) * 6;
|
153
|
+
return source;
|
154
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
|
2
|
+
#ifndef _PARSER_UNICODE_H_
|
3
|
+
#define _PARSER_UNICODE_H_
|
4
|
+
|
5
|
+
#include "ruby.h"
|
6
|
+
|
7
|
+
typedef unsigned long UTF32; /* at least 32 bits */
|
8
|
+
typedef unsigned short UTF16; /* at least 16 bits */
|
9
|
+
typedef unsigned char UTF8; /* typically 8 bits */
|
10
|
+
|
11
|
+
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
|
12
|
+
#define UNI_MAX_BMP (UTF32)0x0000FFFF
|
13
|
+
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
|
14
|
+
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
|
15
|
+
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
|
16
|
+
|
17
|
+
#define UNI_SUR_HIGH_START (UTF32)0xD800
|
18
|
+
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
|
19
|
+
#define UNI_SUR_LOW_START (UTF32)0xDC00
|
20
|
+
#define UNI_SUR_LOW_END (UTF32)0xDFFF
|
21
|
+
|
22
|
+
static const int halfShift = 10; /* used for shifting by 10 bits */
|
23
|
+
|
24
|
+
static const UTF32 halfBase = 0x0010000UL;
|
25
|
+
static const UTF32 halfMask = 0x3FFUL;
|
26
|
+
|
27
|
+
typedef enum {
|
28
|
+
conversionOK = 0, /* conversion successful */
|
29
|
+
sourceExhausted, /* partial character in source, but hit end */
|
30
|
+
targetExhausted, /* insuff. room in target for conversion */
|
31
|
+
sourceIllegal /* source sequence is illegal/malformed */
|
32
|
+
} ConversionResult;
|
33
|
+
|
34
|
+
typedef enum {
|
35
|
+
strictConversion = 0,
|
36
|
+
lenientConversion
|
37
|
+
} ConversionFlags;
|
38
|
+
|
39
|
+
char *JSON_convert_UTF16_to_UTF8 (
|
40
|
+
VALUE buffer,
|
41
|
+
char *source,
|
42
|
+
char *sourceEnd,
|
43
|
+
ConversionFlags flags);
|
44
|
+
|
45
|
+
#ifndef RARRAY_PTR
|
46
|
+
#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
|
47
|
+
#endif
|
48
|
+
#ifndef RARRAY_LEN
|
49
|
+
#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
|
50
|
+
#endif
|
51
|
+
#ifndef RSTRING_PTR
|
52
|
+
#define RSTRING_PTR(string) RSTRING(string)->ptr
|
53
|
+
#endif
|
54
|
+
#ifndef RSTRING_LEN
|
55
|
+
#define RSTRING_LEN(string) RSTRING(string)->len
|
56
|
+
#endif
|
57
|
+
|
58
|
+
#endif
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbconfig'
|
4
|
+
require 'fileutils'
|
5
|
+
include FileUtils::Verbose
|
6
|
+
|
7
|
+
include Config
|
8
|
+
|
9
|
+
bindir = CONFIG["bindir"]
|
10
|
+
cd 'bin' do
|
11
|
+
filename = 'edit_json.rb'
|
12
|
+
#install(filename, bindir)
|
13
|
+
end
|
14
|
+
sitelibdir = CONFIG["sitelibdir"]
|
15
|
+
cd 'lib' do
|
16
|
+
install('json.rb', sitelibdir)
|
17
|
+
mkdir_p File.join(sitelibdir, 'json')
|
18
|
+
for file in Dir['json/**/*.{rb,xpm}']
|
19
|
+
d = File.join(sitelibdir, file)
|
20
|
+
mkdir_p File.dirname(d)
|
21
|
+
install(file, d)
|
22
|
+
end
|
23
|
+
install(File.join('json', 'editor.rb'), File.join(sitelibdir,'json'))
|
24
|
+
install(File.join('json', 'json.xpm'), File.join(sitelibdir,'json'))
|
25
|
+
end
|
26
|
+
warn " *** Installed PURE ruby library."
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * Array_xpm[] = {
|
3
|
+
"16 16 2 1",
|
4
|
+
" c None",
|
5
|
+
". c #000000",
|
6
|
+
" ",
|
7
|
+
" ",
|
8
|
+
" ",
|
9
|
+
" .......... ",
|
10
|
+
" . . ",
|
11
|
+
" . . ",
|
12
|
+
" . . ",
|
13
|
+
" . . ",
|
14
|
+
" . . ",
|
15
|
+
" . . ",
|
16
|
+
" . . ",
|
17
|
+
" . . ",
|
18
|
+
" .......... ",
|
19
|
+
" ",
|
20
|
+
" ",
|
21
|
+
" "};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * False_xpm[] = {
|
3
|
+
"16 16 2 1",
|
4
|
+
" c None",
|
5
|
+
". c #FF0000",
|
6
|
+
" ",
|
7
|
+
" ",
|
8
|
+
" ",
|
9
|
+
" ...... ",
|
10
|
+
" . ",
|
11
|
+
" . ",
|
12
|
+
" . ",
|
13
|
+
" ...... ",
|
14
|
+
" . ",
|
15
|
+
" . ",
|
16
|
+
" . ",
|
17
|
+
" . ",
|
18
|
+
" . ",
|
19
|
+
" ",
|
20
|
+
" ",
|
21
|
+
" "};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * Hash_xpm[] = {
|
3
|
+
"16 16 2 1",
|
4
|
+
" c None",
|
5
|
+
". c #000000",
|
6
|
+
" ",
|
7
|
+
" ",
|
8
|
+
" ",
|
9
|
+
" . . ",
|
10
|
+
" . . ",
|
11
|
+
" . . ",
|
12
|
+
" ......... ",
|
13
|
+
" . . ",
|
14
|
+
" . . ",
|
15
|
+
" ......... ",
|
16
|
+
" . . ",
|
17
|
+
" . . ",
|
18
|
+
" . . ",
|
19
|
+
" ",
|
20
|
+
" ",
|
21
|
+
" "};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * Key_xpm[] = {
|
3
|
+
"16 16 54 1",
|
4
|
+
" c None",
|
5
|
+
". c #110007",
|
6
|
+
"+ c #0E0900",
|
7
|
+
"@ c #000013",
|
8
|
+
"# c #070600",
|
9
|
+
"$ c #F6F006",
|
10
|
+
"% c #ECE711",
|
11
|
+
"& c #E5EE00",
|
12
|
+
"* c #16021E",
|
13
|
+
"= c #120900",
|
14
|
+
"- c #EDF12B",
|
15
|
+
"; c #000033",
|
16
|
+
"> c #0F0000",
|
17
|
+
", c #FFFE03",
|
18
|
+
"' c #E6E500",
|
19
|
+
") c #16021B",
|
20
|
+
"! c #F7F502",
|
21
|
+
"~ c #000E00",
|
22
|
+
"{ c #130000",
|
23
|
+
"] c #FFF000",
|
24
|
+
"^ c #FFE711",
|
25
|
+
"/ c #140005",
|
26
|
+
"( c #190025",
|
27
|
+
"_ c #E9DD27",
|
28
|
+
": c #E7DC04",
|
29
|
+
"< c #FFEC09",
|
30
|
+
"[ c #FFE707",
|
31
|
+
"} c #FFDE10",
|
32
|
+
"| c #150021",
|
33
|
+
"1 c #160700",
|
34
|
+
"2 c #FAF60E",
|
35
|
+
"3 c #EFE301",
|
36
|
+
"4 c #FEF300",
|
37
|
+
"5 c #E7E000",
|
38
|
+
"6 c #FFFF08",
|
39
|
+
"7 c #0E0206",
|
40
|
+
"8 c #040000",
|
41
|
+
"9 c #03052E",
|
42
|
+
"0 c #041212",
|
43
|
+
"a c #070300",
|
44
|
+
"b c #F2E713",
|
45
|
+
"c c #F9DE13",
|
46
|
+
"d c #36091E",
|
47
|
+
"e c #00001C",
|
48
|
+
"f c #1F0010",
|
49
|
+
"g c #FFF500",
|
50
|
+
"h c #DEDE00",
|
51
|
+
"i c #050A00",
|
52
|
+
"j c #FAF14A",
|
53
|
+
"k c #F5F200",
|
54
|
+
"l c #040404",
|
55
|
+
"m c #1A0D00",
|
56
|
+
"n c #EDE43D",
|
57
|
+
"o c #ECE007",
|
58
|
+
" ",
|
59
|
+
" ",
|
60
|
+
" .+@ ",
|
61
|
+
" #$%&* ",
|
62
|
+
" =-;>,') ",
|
63
|
+
" >!~{]^/ ",
|
64
|
+
" (_:<[}| ",
|
65
|
+
" 1234567 ",
|
66
|
+
" 890abcd ",
|
67
|
+
" efghi ",
|
68
|
+
" >jkl ",
|
69
|
+
" mnol ",
|
70
|
+
" >kl ",
|
71
|
+
" ll ",
|
72
|
+
" ",
|
73
|
+
" "};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * False_xpm[] = {
|
3
|
+
"16 16 2 1",
|
4
|
+
" c None",
|
5
|
+
". c #000000",
|
6
|
+
" ",
|
7
|
+
" ",
|
8
|
+
" ",
|
9
|
+
" ... ",
|
10
|
+
" . . ",
|
11
|
+
" . . ",
|
12
|
+
" . . ",
|
13
|
+
" . . ",
|
14
|
+
" . . ",
|
15
|
+
" . . ",
|
16
|
+
" . . ",
|
17
|
+
" . . ",
|
18
|
+
" ... ",
|
19
|
+
" ",
|
20
|
+
" ",
|
21
|
+
" "};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * Numeric_xpm[] = {
|
3
|
+
"16 16 9 1",
|
4
|
+
" c None",
|
5
|
+
". c #FF0000",
|
6
|
+
"+ c #0000FF",
|
7
|
+
"@ c #0023DB",
|
8
|
+
"# c #00EA14",
|
9
|
+
"$ c #00FF00",
|
10
|
+
"% c #004FAF",
|
11
|
+
"& c #0028D6",
|
12
|
+
"* c #00F20C",
|
13
|
+
" ",
|
14
|
+
" ",
|
15
|
+
" ",
|
16
|
+
" ... +++@#$$$$ ",
|
17
|
+
" .+ %& $$ ",
|
18
|
+
" . + $ ",
|
19
|
+
" . + $$ ",
|
20
|
+
" . ++$$$$ ",
|
21
|
+
" . + $$ ",
|
22
|
+
" . + $ ",
|
23
|
+
" . + $ ",
|
24
|
+
" . + $ $$ ",
|
25
|
+
" .....++++*$$ ",
|
26
|
+
" ",
|
27
|
+
" ",
|
28
|
+
" "};
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * String_xpm[] = {
|
3
|
+
"16 16 77 1",
|
4
|
+
" c None",
|
5
|
+
". c #000000",
|
6
|
+
"+ c #040404",
|
7
|
+
"@ c #080806",
|
8
|
+
"# c #090606",
|
9
|
+
"$ c #EEEAE1",
|
10
|
+
"% c #E7E3DA",
|
11
|
+
"& c #E0DBD1",
|
12
|
+
"* c #D4B46F",
|
13
|
+
"= c #0C0906",
|
14
|
+
"- c #E3C072",
|
15
|
+
"; c #E4C072",
|
16
|
+
"> c #060505",
|
17
|
+
", c #0B0A08",
|
18
|
+
"' c #D5B264",
|
19
|
+
") c #D3AF5A",
|
20
|
+
"! c #080602",
|
21
|
+
"~ c #E1B863",
|
22
|
+
"{ c #DDB151",
|
23
|
+
"] c #DBAE4A",
|
24
|
+
"^ c #DDB152",
|
25
|
+
"/ c #DDB252",
|
26
|
+
"( c #070705",
|
27
|
+
"_ c #0C0A07",
|
28
|
+
": c #D3A33B",
|
29
|
+
"< c #020201",
|
30
|
+
"[ c #DAAA41",
|
31
|
+
"} c #040302",
|
32
|
+
"| c #E4D9BF",
|
33
|
+
"1 c #0B0907",
|
34
|
+
"2 c #030201",
|
35
|
+
"3 c #020200",
|
36
|
+
"4 c #C99115",
|
37
|
+
"5 c #080704",
|
38
|
+
"6 c #DBC8A2",
|
39
|
+
"7 c #E7D7B4",
|
40
|
+
"8 c #E0CD9E",
|
41
|
+
"9 c #080601",
|
42
|
+
"0 c #040400",
|
43
|
+
"a c #010100",
|
44
|
+
"b c #0B0B08",
|
45
|
+
"c c #DCBF83",
|
46
|
+
"d c #DCBC75",
|
47
|
+
"e c #DEB559",
|
48
|
+
"f c #040301",
|
49
|
+
"g c #BC8815",
|
50
|
+
"h c #120E07",
|
51
|
+
"i c #060402",
|
52
|
+
"j c #0A0804",
|
53
|
+
"k c #D4A747",
|
54
|
+
"l c #D6A12F",
|
55
|
+
"m c #0E0C05",
|
56
|
+
"n c #C8C1B0",
|
57
|
+
"o c #1D1B15",
|
58
|
+
"p c #D7AD51",
|
59
|
+
"q c #070502",
|
60
|
+
"r c #080804",
|
61
|
+
"s c #BC953B",
|
62
|
+
"t c #C4BDAD",
|
63
|
+
"u c #0B0807",
|
64
|
+
"v c #DBAC47",
|
65
|
+
"w c #1B150A",
|
66
|
+
"x c #B78A2C",
|
67
|
+
"y c #D8A83C",
|
68
|
+
"z c #D4A338",
|
69
|
+
"A c #0F0B03",
|
70
|
+
"B c #181105",
|
71
|
+
"C c #C59325",
|
72
|
+
"D c #C18E1F",
|
73
|
+
"E c #060600",
|
74
|
+
"F c #CC992D",
|
75
|
+
"G c #B98B25",
|
76
|
+
"H c #B3831F",
|
77
|
+
"I c #C08C1C",
|
78
|
+
"J c #060500",
|
79
|
+
"K c #0E0C03",
|
80
|
+
"L c #0D0A00",
|
81
|
+
" ",
|
82
|
+
" .+@# ",
|
83
|
+
" .$%&*= ",
|
84
|
+
" .-;>,')! ",
|
85
|
+
" .~. .{]. ",
|
86
|
+
" .^/. (_:< ",
|
87
|
+
" .[.}|$12 ",
|
88
|
+
" 345678}90 ",
|
89
|
+
" a2bcdefgh ",
|
90
|
+
" ijkl.mno ",
|
91
|
+
" <pq. rstu ",
|
92
|
+
" .]v. wx= ",
|
93
|
+
" .yzABCDE ",
|
94
|
+
" .FGHIJ ",
|
95
|
+
" 0KL0 ",
|
96
|
+
" "};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * TrueClass_xpm[] = {
|
3
|
+
"16 16 2 1",
|
4
|
+
" c None",
|
5
|
+
". c #0BF311",
|
6
|
+
" ",
|
7
|
+
" ",
|
8
|
+
" ",
|
9
|
+
" ......... ",
|
10
|
+
" . ",
|
11
|
+
" . ",
|
12
|
+
" . ",
|
13
|
+
" . ",
|
14
|
+
" . ",
|
15
|
+
" . ",
|
16
|
+
" . ",
|
17
|
+
" . ",
|
18
|
+
" . ",
|
19
|
+
" ",
|
20
|
+
" ",
|
21
|
+
" "};
|
@@ -0,0 +1,135 @@
|
|
1
|
+
# This file contains implementations of ruby core's custom objects for
|
2
|
+
# serialisation/deserialisation.
|
3
|
+
|
4
|
+
unless Object.const_defined?(:JSON) and ::JSON.const_defined?(:JSON_LOADED) and
|
5
|
+
::JSON::JSON_LOADED
|
6
|
+
require 'json'
|
7
|
+
end
|
8
|
+
require 'date'
|
9
|
+
|
10
|
+
class Time
|
11
|
+
def self.json_create(object)
|
12
|
+
if usec = object.delete('u') # used to be tv_usec -> tv_nsec
|
13
|
+
object['n'] = usec * 1000
|
14
|
+
end
|
15
|
+
if respond_to?(:tv_nsec)
|
16
|
+
at(*object.values_at('s', 'n'))
|
17
|
+
else
|
18
|
+
at(object['s'], object['n'] / 1000)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_json(*args)
|
23
|
+
{
|
24
|
+
'json_class' => self.class.name,
|
25
|
+
's' => tv_sec,
|
26
|
+
'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000
|
27
|
+
}.to_json(*args)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Date
|
32
|
+
def self.json_create(object)
|
33
|
+
civil(*object.values_at('y', 'm', 'd', 'sg'))
|
34
|
+
end
|
35
|
+
|
36
|
+
alias start sg unless method_defined?(:start)
|
37
|
+
|
38
|
+
def to_json(*args)
|
39
|
+
{
|
40
|
+
'json_class' => self.class.name,
|
41
|
+
'y' => year,
|
42
|
+
'm' => month,
|
43
|
+
'd' => day,
|
44
|
+
'sg' => start,
|
45
|
+
}.to_json(*args)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class DateTime
|
50
|
+
def self.json_create(object)
|
51
|
+
args = object.values_at('y', 'm', 'd', 'H', 'M', 'S')
|
52
|
+
of_a, of_b = object['of'].split('/')
|
53
|
+
if of_b and of_b != '0'
|
54
|
+
args << Rational(of_a.to_i, of_b.to_i)
|
55
|
+
else
|
56
|
+
args << of_a
|
57
|
+
end
|
58
|
+
args << object['sg']
|
59
|
+
civil(*args)
|
60
|
+
end
|
61
|
+
|
62
|
+
alias start sg unless method_defined?(:start)
|
63
|
+
|
64
|
+
def to_json(*args)
|
65
|
+
{
|
66
|
+
'json_class' => self.class.name,
|
67
|
+
'y' => year,
|
68
|
+
'm' => month,
|
69
|
+
'd' => day,
|
70
|
+
'H' => hour,
|
71
|
+
'M' => min,
|
72
|
+
'S' => sec,
|
73
|
+
'of' => offset.to_s,
|
74
|
+
'sg' => start,
|
75
|
+
}.to_json(*args)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Range
|
80
|
+
def self.json_create(object)
|
81
|
+
new(*object['a'])
|
82
|
+
end
|
83
|
+
|
84
|
+
def to_json(*args)
|
85
|
+
{
|
86
|
+
'json_class' => self.class.name,
|
87
|
+
'a' => [ first, last, exclude_end? ]
|
88
|
+
}.to_json(*args)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class Struct
|
93
|
+
def self.json_create(object)
|
94
|
+
new(*object['v'])
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_json(*args)
|
98
|
+
klass = self.class.name
|
99
|
+
klass.empty? and raise JSON::JSONError, "Only named structs are supported!"
|
100
|
+
{
|
101
|
+
'json_class' => klass,
|
102
|
+
'v' => values,
|
103
|
+
}.to_json(*args)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
class Exception
|
108
|
+
def self.json_create(object)
|
109
|
+
result = new(object['m'])
|
110
|
+
result.set_backtrace object['b']
|
111
|
+
result
|
112
|
+
end
|
113
|
+
|
114
|
+
def to_json(*args)
|
115
|
+
{
|
116
|
+
'json_class' => self.class.name,
|
117
|
+
'm' => message,
|
118
|
+
'b' => backtrace,
|
119
|
+
}.to_json(*args)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
class Regexp
|
124
|
+
def self.json_create(object)
|
125
|
+
new(object['s'], object['o'])
|
126
|
+
end
|
127
|
+
|
128
|
+
def to_json(*)
|
129
|
+
{
|
130
|
+
'json_class' => self.class.name,
|
131
|
+
'o' => options,
|
132
|
+
's' => source,
|
133
|
+
}.to_json
|
134
|
+
end
|
135
|
+
end
|