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,309 @@
|
|
1
|
+
begin
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
require 'rake/clean'
|
6
|
+
|
7
|
+
require 'rbconfig'
|
8
|
+
include Config
|
9
|
+
|
10
|
+
ON_WINDOWS = RUBY_PLATFORM =~ /mswin32/i
|
11
|
+
PKG_NAME = 'json'
|
12
|
+
PKG_VERSION = File.read('VERSION').chomp
|
13
|
+
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|coverage|Makefile/).exclude(/\.(so|bundle|o|#{CONFIG['DLEXT']})$/)
|
14
|
+
EXT_ROOT_DIR = 'ext/json/ext'
|
15
|
+
EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
|
16
|
+
EXT_PARSER_DL = "#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}"
|
17
|
+
EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
|
18
|
+
PKG_FILES << EXT_PARSER_SRC
|
19
|
+
EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
|
20
|
+
EXT_GENERATOR_DL = "#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
|
21
|
+
EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
|
22
|
+
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd].find { |c| system(c, '-v') }
|
23
|
+
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd].find { |c| system(c, '-v') }
|
24
|
+
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
|
25
|
+
CLEAN.include 'doc', 'coverage', FileList['diagrams/*.*'],
|
26
|
+
FileList["ext/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def}"],
|
27
|
+
FileList["ext/**/Makefile"]
|
28
|
+
|
29
|
+
|
30
|
+
desc "Installing library (pure)"
|
31
|
+
task :install_pure => :version do
|
32
|
+
ruby 'install.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :install_ext_really do
|
36
|
+
sitearchdir = CONFIG["sitearchdir"]
|
37
|
+
cd 'ext' do
|
38
|
+
for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
|
39
|
+
d = File.join(sitearchdir, file)
|
40
|
+
mkdir_p File.dirname(d)
|
41
|
+
install(file, d)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Installing library (extension)"
|
47
|
+
task :install_ext => [ :compile, :install_pure, :install_ext_really ]
|
48
|
+
|
49
|
+
task :install => :install_ext
|
50
|
+
|
51
|
+
desc "Compiling extension"
|
52
|
+
task :compile => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
|
53
|
+
|
54
|
+
file EXT_PARSER_DL => EXT_PARSER_SRC do
|
55
|
+
cd EXT_PARSER_DIR do
|
56
|
+
ruby 'extconf.rb'
|
57
|
+
if ON_WINDOWS
|
58
|
+
sh 'nmake'
|
59
|
+
sh "mt -manifest parser.#{CONFIG['DLEXT']}.manifest -outputresource:parser.#{CONFIG['DLEXT']};2"
|
60
|
+
else
|
61
|
+
sh 'make'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
65
|
+
end
|
66
|
+
|
67
|
+
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
|
68
|
+
cd EXT_GENERATOR_DIR do
|
69
|
+
ruby 'extconf.rb'
|
70
|
+
if ON_WINDOWS
|
71
|
+
sh 'nmake'
|
72
|
+
sh "mt -manifest generator.#{CONFIG['DLEXT']}.manifest -outputresource:generator.#{CONFIG['DLEXT']};2"
|
73
|
+
else
|
74
|
+
sh 'make'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Generate parser with ragel"
|
81
|
+
task :ragel => EXT_PARSER_SRC
|
82
|
+
|
83
|
+
task :ragel_clean do
|
84
|
+
rm_rf EXT_PARSER_SRC
|
85
|
+
end
|
86
|
+
|
87
|
+
file EXT_PARSER_SRC => RAGEL_PATH do
|
88
|
+
cd EXT_PARSER_DIR do
|
89
|
+
sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Generate diagrams of ragel parser (ps)"
|
94
|
+
task :ragel_dot_ps do
|
95
|
+
root = 'diagrams'
|
96
|
+
specs = []
|
97
|
+
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
98
|
+
for s in specs
|
99
|
+
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Generate diagrams of ragel parser (png)"
|
104
|
+
task :ragel_dot_png do
|
105
|
+
root = 'diagrams'
|
106
|
+
specs = []
|
107
|
+
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
108
|
+
for s in specs
|
109
|
+
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Generate diagrams of ragel parser"
|
114
|
+
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
|
115
|
+
|
116
|
+
desc "Testing library (pure ruby)"
|
117
|
+
task :test_pure => :clean do
|
118
|
+
ruby '-v -I lib tests/runner.rb'
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "Testing library (extension)"
|
122
|
+
task :test_ext => :compile do
|
123
|
+
ruby '-v -I ext:lib tests/runner.rb'
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "Benchmarking parser (pure)"
|
127
|
+
task :benchmark_parser_pure do
|
128
|
+
ruby '-I lib benchmarks/benchmark_parser.rb pure'
|
129
|
+
end
|
130
|
+
|
131
|
+
desc "Benchmarking generator (pure)"
|
132
|
+
task :benchmark_generator_pure do
|
133
|
+
ruby '-I lib benchmarks/benchmark_generator.rb pure'
|
134
|
+
ruby 'benchmarks/benchmark_rails.rb'
|
135
|
+
end
|
136
|
+
|
137
|
+
desc "Benchmarking library (pure)"
|
138
|
+
task :benchmark_pure => [ :benchmark_parser_pure, :benchmark_generator_pure ]
|
139
|
+
|
140
|
+
desc "Benchmarking parser (extension)"
|
141
|
+
task :benchmark_parser_ext => :compile do
|
142
|
+
ruby '-I ext:lib benchmarks/benchmark_parser.rb ext'
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "Benchmarking generator (extension)"
|
146
|
+
task :benchmark_generator_ext => :compile do
|
147
|
+
ruby '-I ext:lib benchmarks/benchmark_generator.rb ext'
|
148
|
+
ruby 'benchmarks/benchmark_rails.rb'
|
149
|
+
end
|
150
|
+
|
151
|
+
desc "Benchmarking library (extension)"
|
152
|
+
task :benchmark_ext => [ :benchmark_parser_ext, :benchmark_generator_ext ]
|
153
|
+
|
154
|
+
task :benchmark do
|
155
|
+
puts "Benchmarking extension variant"
|
156
|
+
Rake::Task[:benchmark_ext].invoke
|
157
|
+
puts "Benchmarking pure variant"
|
158
|
+
Rake::Task[:benchmark_pure].invoke
|
159
|
+
end
|
160
|
+
|
161
|
+
desc "Testing library with coverage" # XXX broken
|
162
|
+
task :coverage do
|
163
|
+
system 'RUBYOPT="" rcov -x tests -Ilib tests/runner.rb'
|
164
|
+
end
|
165
|
+
|
166
|
+
desc "Create RDOC documentation"
|
167
|
+
task :doc => [ :version, EXT_PARSER_SRC ] do
|
168
|
+
sh "rdoc -m JSON -S -o doc lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
|
169
|
+
end
|
170
|
+
|
171
|
+
if defined? Gem
|
172
|
+
spec_pure = Gem::Specification.new do |s|
|
173
|
+
s.name = 'json_pure'
|
174
|
+
s.version = PKG_VERSION
|
175
|
+
s.summary = "A JSON implementation in Ruby"
|
176
|
+
s.description = ""
|
177
|
+
|
178
|
+
s.files = PKG_FILES
|
179
|
+
|
180
|
+
s.require_path = 'lib'
|
181
|
+
|
182
|
+
s.bindir = "bin"
|
183
|
+
s.executables = ["edit_json.rb"]
|
184
|
+
s.default_executable = "edit_json.rb"
|
185
|
+
|
186
|
+
s.has_rdoc = true
|
187
|
+
s.rdoc_options <<
|
188
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
189
|
+
'--main' << 'JSON' << '--line-numbers'
|
190
|
+
s.test_files << 'tests/runner.rb'
|
191
|
+
|
192
|
+
s.author = "Florian Frank"
|
193
|
+
s.email = "flori@ping.de"
|
194
|
+
s.homepage = "http://json.rubyforge.org"
|
195
|
+
s.rubyforge_project = "json"
|
196
|
+
end
|
197
|
+
|
198
|
+
Rake::GemPackageTask.new(spec_pure) do |pkg|
|
199
|
+
pkg.need_tar = true
|
200
|
+
pkg.package_files += PKG_FILES
|
201
|
+
end
|
202
|
+
|
203
|
+
spec_ext = Gem::Specification.new do |s|
|
204
|
+
s.name = 'json'
|
205
|
+
s.version = PKG_VERSION
|
206
|
+
s.summary = "A JSON implementation as a Ruby extension"
|
207
|
+
s.description = ""
|
208
|
+
|
209
|
+
s.files = PKG_FILES
|
210
|
+
|
211
|
+
s.extensions <<
|
212
|
+
"#{EXT_PARSER_DIR}/extconf.rb" <<
|
213
|
+
"#{EXT_GENERATOR_DIR}/extconf.rb"
|
214
|
+
|
215
|
+
s.require_path = EXT_ROOT_DIR
|
216
|
+
s.require_paths << 'ext'
|
217
|
+
s.require_paths << 'lib'
|
218
|
+
|
219
|
+
s.bindir = "bin"
|
220
|
+
s.executables = ["edit_json.rb"]
|
221
|
+
s.default_executable = "edit_json.rb"
|
222
|
+
|
223
|
+
s.has_rdoc = true
|
224
|
+
s.rdoc_options <<
|
225
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
226
|
+
'--main' << 'JSON' << '--line-numbers'
|
227
|
+
s.test_files << 'tests/runner.rb'
|
228
|
+
|
229
|
+
s.author = "Florian Frank"
|
230
|
+
s.email = "flori@ping.de"
|
231
|
+
s.homepage = "http://json.rubyforge.org"
|
232
|
+
s.rubyforge_project = "json"
|
233
|
+
end
|
234
|
+
|
235
|
+
Rake::GemPackageTask.new(spec_ext) do |pkg|
|
236
|
+
pkg.need_tar = true
|
237
|
+
pkg.package_files += PKG_FILES
|
238
|
+
end
|
239
|
+
|
240
|
+
task :package_win => :compile do
|
241
|
+
mkdir_p 'pkg'
|
242
|
+
spec_win_ext = Gem::Specification.new do |s|
|
243
|
+
s.name = 'json'
|
244
|
+
s.platform = Gem::Platform::WIN32
|
245
|
+
s.version = PKG_VERSION
|
246
|
+
s.summary = "A JSON implementation as a Ruby extension"
|
247
|
+
s.description = ""
|
248
|
+
|
249
|
+
s.files = PKG_FILES.to_a <<
|
250
|
+
"#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}" <<
|
251
|
+
"#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
|
252
|
+
|
253
|
+
s.require_path = EXT_ROOT_DIR
|
254
|
+
s.require_paths << 'ext'
|
255
|
+
s.require_paths << 'lib'
|
256
|
+
|
257
|
+
s.bindir = "bin"
|
258
|
+
s.executables = ["edit_json.rb", "prettify_json.rb"]
|
259
|
+
s.default_executable = "edit_json.rb"
|
260
|
+
|
261
|
+
s.has_rdoc = true
|
262
|
+
s.rdoc_options <<
|
263
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
264
|
+
'--main' << 'JSON' << '--line-numbers'
|
265
|
+
s.test_files << 'tests/runner.rb'
|
266
|
+
|
267
|
+
s.author = "Florian Frank"
|
268
|
+
s.email = "flori@ping.de"
|
269
|
+
s.homepage = "http://json.rubyforge.org"
|
270
|
+
s.rubyforge_project = "json"
|
271
|
+
end
|
272
|
+
|
273
|
+
gem_file = "json-#{spec_win_ext.version}-#{spec_win_ext.platform}.gem"
|
274
|
+
Gem::Builder.new(spec_win_ext).build
|
275
|
+
mv gem_file, 'pkg'
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
task :mrproper => [ :ragel_clean, :clean ] do
|
280
|
+
for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ]
|
281
|
+
cd(dir) { rm_f 'Makefile' }
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
desc m = "Writing version information for #{PKG_VERSION}"
|
286
|
+
task :version do
|
287
|
+
puts m
|
288
|
+
File.open(File.join('lib', 'json', 'version.rb'), 'w') do |v|
|
289
|
+
v.puts <<EOT
|
290
|
+
module JSON
|
291
|
+
# JSON version
|
292
|
+
VERSION = '#{PKG_VERSION}'
|
293
|
+
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
294
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
295
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
296
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
297
|
+
VARIANT_BINARY = #{!!ON_WINDOWS}
|
298
|
+
end
|
299
|
+
EOT
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
if ON_WINDOWS
|
304
|
+
task :release => [ :version, :clean, :package_win ]
|
305
|
+
else
|
306
|
+
task :release => [ :version, :mrproper, :package ]
|
307
|
+
end
|
308
|
+
|
309
|
+
task :default => [ :version, :compile ]
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
1.1.3
|
@@ -0,0 +1,133 @@
|
|
1
|
+
(in /home/flori/json)
|
2
|
+
Ragel Code Generator version 5.17 January 2007
|
3
|
+
Copyright (c) 2001-2006 by Adrian Thurston
|
4
|
+
Benchmarking extension variant
|
5
|
+
First run for warmup.
|
6
|
+
Running 'BC_Parser' for a duration of 10 secs per method:
|
7
|
+
real total utime stime cutime cstime
|
8
|
+
parser: 10.005944 10.010000 9.970000 0.040000 0.000000 0.000000
|
9
|
+
5091 508.591409 0.001966
|
10
|
+
calls calls/sec secs/call
|
11
|
+
--------------------------------------------------------------------------------
|
12
|
+
Running 'BC_Parser' for a duration of 10 secs per method:
|
13
|
+
real total utime stime cutime cstime
|
14
|
+
parser: 10.006881 10.000000 9.950000 0.050000 0.000000 0.000000
|
15
|
+
5055 505.500000 0.001978
|
16
|
+
calls calls/sec secs/call
|
17
|
+
--------------------------------------------------------------------------------
|
18
|
+
================================================================================
|
19
|
+
|
20
|
+
|
21
|
+
[null,false,true,"f\u00d6\u00df\u00c4r",["n\u20acst\u20acd",true],{"quux":true,"foo\u00df":"b\u00e4r"}]
|
22
|
+
First run for warmup.
|
23
|
+
Running 'BC_Generator' for a duration of 10 secs per method:
|
24
|
+
real total utime stime cutime cstime
|
25
|
+
generator_pretty: 10.001066 10.010000 9.990000 0.020000 0.000000 0.000000
|
26
|
+
3492 348.851149 0.002867
|
27
|
+
generator_fast : 10.002910 10.000000 9.980000 0.020000 0.000000 0.000000
|
28
|
+
5416 541.600000 0.001846
|
29
|
+
generator_safe : 10.003107 10.010000 10.000000 0.010000 0.000000 0.000000
|
30
|
+
4926 492.107892 0.002032
|
31
|
+
calls calls/sec secs/call
|
32
|
+
--------------------------------------------------------------------------------
|
33
|
+
Running 'BC_Generator' for a duration of 10 secs per method:
|
34
|
+
real total utime stime cutime cstime
|
35
|
+
generator_pretty: 10.009150 10.010000 10.010000 0.000000 0.000000 0.000000
|
36
|
+
3511 350.749251 0.002851
|
37
|
+
generator_fast : 10.014407 10.020000 10.020000 0.000000 0.000000 0.000000
|
38
|
+
5411 540.019960 0.001852
|
39
|
+
generator_safe : 10.010055 10.000000 10.000000 0.000000 0.000000 0.000000
|
40
|
+
4933 493.300000 0.002027
|
41
|
+
calls calls/sec secs/call
|
42
|
+
--------------------------------------------------------------------------------
|
43
|
+
================================================================================
|
44
|
+
|
45
|
+
Comparison in BC_Generator:
|
46
|
+
secs/call speed
|
47
|
+
generator_fast : 0.002 -> 1.540x
|
48
|
+
generator_safe : 0.002 -> 1.406x
|
49
|
+
generator_pretty: 0.003 -> 1.000x
|
50
|
+
--------------------------------------------------------------------------------
|
51
|
+
|
52
|
+
[null, false, true, "f\u00d6\u00df\u00c4r", ["n\u20acst\u20acd", true], {quux: true, "foo\u00df": "b\u00e4r"}]
|
53
|
+
First run for warmup.
|
54
|
+
Running 'BC_Rails' for a duration of 10 secs per method:
|
55
|
+
real total utime stime cutime cstime
|
56
|
+
generator: 10.026043 10.020000 10.020000 0.000000 0.000000 0.000000
|
57
|
+
239 23.852295 0.041925
|
58
|
+
calls calls/sec secs/call
|
59
|
+
--------------------------------------------------------------------------------
|
60
|
+
Running 'BC_Rails' for a duration of 10 secs per method:
|
61
|
+
real total utime stime cutime cstime
|
62
|
+
generator: 10.010931 10.020000 10.010000 0.010000 0.000000 0.000000
|
63
|
+
238 23.752495 0.042101
|
64
|
+
calls calls/sec secs/call
|
65
|
+
--------------------------------------------------------------------------------
|
66
|
+
================================================================================
|
67
|
+
|
68
|
+
|
69
|
+
Benchmarking pure variant
|
70
|
+
First run for warmup.
|
71
|
+
Running 'BC_Parser' for a duration of 10 secs per method:
|
72
|
+
real total utime stime cutime cstime
|
73
|
+
parser: 10.022352 10.030000 10.020000 0.010000 0.000000 0.000000
|
74
|
+
288 28.713858 0.034826
|
75
|
+
calls calls/sec secs/call
|
76
|
+
--------------------------------------------------------------------------------
|
77
|
+
Running 'BC_Parser' for a duration of 10 secs per method:
|
78
|
+
real total utime stime cutime cstime
|
79
|
+
parser: 10.006552 10.000000 10.000000 0.000000 0.000000 0.000000
|
80
|
+
289 28.900000 0.034602
|
81
|
+
calls calls/sec secs/call
|
82
|
+
--------------------------------------------------------------------------------
|
83
|
+
================================================================================
|
84
|
+
|
85
|
+
|
86
|
+
[null,false,true,"f\u00d6\u00df\u00c4r",["n\u20acst\u20acd",true],{"quux":true,"foo\u00df":"b\u00e4r"}]
|
87
|
+
First run for warmup.
|
88
|
+
Running 'BC_Generator' for a duration of 10 secs per method:
|
89
|
+
real total utime stime cutime cstime
|
90
|
+
generator_fast : 10.011644 10.010000 10.010000 0.000000 0.000000 0.000000
|
91
|
+
411 41.058941 0.024355
|
92
|
+
generator_safe : 10.007100 10.010000 10.010000 0.000000 0.000000 0.000000
|
93
|
+
352 35.164835 0.028438
|
94
|
+
generator_pretty: 10.008156 10.010000 10.010000 0.000000 0.000000 0.000000
|
95
|
+
341 34.065934 0.029355
|
96
|
+
calls calls/sec secs/call
|
97
|
+
--------------------------------------------------------------------------------
|
98
|
+
Running 'BC_Generator' for a duration of 10 secs per method:
|
99
|
+
real total utime stime cutime cstime
|
100
|
+
generator_fast : 10.005185 10.010000 10.010000 0.000000 0.000000 0.000000
|
101
|
+
411 41.058941 0.024355
|
102
|
+
generator_safe : 10.006932 10.010000 10.010000 0.000000 0.000000 0.000000
|
103
|
+
351 35.064935 0.028519
|
104
|
+
generator_pretty: 10.007414 10.000000 10.000000 0.000000 0.000000 0.000000
|
105
|
+
340 34.000000 0.029412
|
106
|
+
calls calls/sec secs/call
|
107
|
+
--------------------------------------------------------------------------------
|
108
|
+
================================================================================
|
109
|
+
|
110
|
+
Comparison in BC_Generator:
|
111
|
+
secs/call speed
|
112
|
+
generator_fast : 0.024 -> 1.208x
|
113
|
+
generator_safe : 0.029 -> 1.031x
|
114
|
+
generator_pretty: 0.029 -> 1.000x
|
115
|
+
--------------------------------------------------------------------------------
|
116
|
+
|
117
|
+
[null, false, true, "f\u00d6\u00df\u00c4r", ["n\u20acst\u20acd", true], {quux: true, "foo\u00df": "b\u00e4r"}]
|
118
|
+
First run for warmup.
|
119
|
+
Running 'BC_Rails' for a duration of 10 secs per method:
|
120
|
+
real total utime stime cutime cstime
|
121
|
+
generator: 10.005748 10.000000 10.000000 0.000000 0.000000 0.000000
|
122
|
+
240 24.000000 0.041667
|
123
|
+
calls calls/sec secs/call
|
124
|
+
--------------------------------------------------------------------------------
|
125
|
+
Running 'BC_Rails' for a duration of 10 secs per method:
|
126
|
+
real total utime stime cutime cstime
|
127
|
+
generator: 10.006764 10.010000 10.010000 0.000000 0.000000 0.000000
|
128
|
+
239 23.876124 0.041883
|
129
|
+
calls calls/sec secs/call
|
130
|
+
--------------------------------------------------------------------------------
|
131
|
+
================================================================================
|
132
|
+
|
133
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bullshit'
|
4
|
+
$KCODE='utf8'
|
5
|
+
if ARGV.shift == 'pure'
|
6
|
+
require 'json/pure'
|
7
|
+
else
|
8
|
+
require 'json/ext'
|
9
|
+
end
|
10
|
+
|
11
|
+
class BC_Generator < Bullshit::TimeCase
|
12
|
+
include JSON
|
13
|
+
|
14
|
+
warmup true
|
15
|
+
duration 10
|
16
|
+
|
17
|
+
def setup
|
18
|
+
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
19
|
+
puts JSON[a]
|
20
|
+
@big = a * 100
|
21
|
+
end
|
22
|
+
|
23
|
+
def benchmark_generator_fast
|
24
|
+
@result = JSON.fast_generate(@big)
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset_benchmark_generator_fast
|
28
|
+
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def benchmark_generator_safe
|
32
|
+
@result = JSON.generate(@big)
|
33
|
+
end
|
34
|
+
|
35
|
+
def reset_benchmark_generator_safe
|
36
|
+
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def benchmark_generator_pretty
|
40
|
+
@result = JSON.pretty_generate(@big)
|
41
|
+
end
|
42
|
+
|
43
|
+
def reset_benchmark_generator_pretty
|
44
|
+
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
compare :generator_fast, :generator_safe, :generator_pretty
|
48
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bullshit'
|
4
|
+
if ARGV.shift == 'pure'
|
5
|
+
require 'json/pure'
|
6
|
+
else
|
7
|
+
require 'json/ext'
|
8
|
+
end
|
9
|
+
|
10
|
+
class BC_Parser < Bullshit::TimeCase
|
11
|
+
include JSON
|
12
|
+
|
13
|
+
warmup true
|
14
|
+
duration 10
|
15
|
+
|
16
|
+
def setup
|
17
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
18
|
+
@big = a * 100
|
19
|
+
@json = JSON.generate(@big)
|
20
|
+
end
|
21
|
+
|
22
|
+
def benchmark_parser
|
23
|
+
a = JSON.parse(@json)
|
24
|
+
a == @big or raise "not equal"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bullshit'
|
4
|
+
require 'active_support'
|
5
|
+
|
6
|
+
class BC_Rails < Bullshit::TimeCase
|
7
|
+
warmup true
|
8
|
+
duration 10
|
9
|
+
|
10
|
+
def setup
|
11
|
+
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
12
|
+
puts a.to_json
|
13
|
+
@big = a * 100
|
14
|
+
end
|
15
|
+
|
16
|
+
def benchmark_generator
|
17
|
+
@result = @big.to_json
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset_benchmark_generator
|
21
|
+
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
22
|
+
if stack = Thread.current[:json_reference_stack]
|
23
|
+
stack.clear
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$KCODE = 'U'
|
4
|
+
require 'json'
|
5
|
+
require 'fileutils'
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
# Parses the argument array _args_, according to the pattern _s_, to
|
9
|
+
# retrieve the single character command line options from it. If _s_ is
|
10
|
+
# 'xy:' an option '-x' without an option argument is searched, and an
|
11
|
+
# option '-y foo' with an option argument ('foo').
|
12
|
+
#
|
13
|
+
# An option hash is returned with all found options set to true or the
|
14
|
+
# found option argument.
|
15
|
+
def go(s, args = ARGV)
|
16
|
+
b, v = s.scan(/(.)(:?)/).inject([{},{}]) { |t,(o,a)|
|
17
|
+
t[a.empty? ? 0 : 1][o] = a.empty? ? false : nil
|
18
|
+
t
|
19
|
+
}
|
20
|
+
while a = args.shift
|
21
|
+
a !~ /\A-(.+)/ and args.unshift a and break
|
22
|
+
p = $1
|
23
|
+
until p == ''
|
24
|
+
o = p.slice!(0, 1)
|
25
|
+
if v.key?(o)
|
26
|
+
v[o] = if p == '' then args.shift or break 1 else p end
|
27
|
+
break
|
28
|
+
elsif b.key?(o)
|
29
|
+
b[o] = true
|
30
|
+
else
|
31
|
+
args.unshift a
|
32
|
+
break 1
|
33
|
+
end
|
34
|
+
end and break
|
35
|
+
end
|
36
|
+
b.merge(v)
|
37
|
+
end
|
38
|
+
|
39
|
+
opts = go 'slhi:', args = ARGV.dup
|
40
|
+
if opts['h'] || opts['l'] && opts['s']
|
41
|
+
puts <<EOT
|
42
|
+
Usage: #{File.basename($0)} [OPTION] [FILE]
|
43
|
+
|
44
|
+
If FILE is skipped, this scripts waits for input from STDIN. Otherwise
|
45
|
+
FILE is opened, read, and used as input for the prettifier.
|
46
|
+
|
47
|
+
OPTION can be
|
48
|
+
-s to output the shortest possible JSON (precludes -l)
|
49
|
+
-l to output a longer, better formatted JSON (precludes -s)
|
50
|
+
-i EXT prettifies FILE in place, saving a backup to FILE.EXT
|
51
|
+
-h this help
|
52
|
+
EOT
|
53
|
+
exit 0
|
54
|
+
end
|
55
|
+
|
56
|
+
filename = nil
|
57
|
+
json = JSON[
|
58
|
+
if args.empty?
|
59
|
+
STDIN.read
|
60
|
+
else
|
61
|
+
File.read filename = args.first
|
62
|
+
end
|
63
|
+
]
|
64
|
+
|
65
|
+
output = if opts['s']
|
66
|
+
JSON.fast_generate json
|
67
|
+
else # default is -l
|
68
|
+
JSON.pretty_generate json
|
69
|
+
end
|
70
|
+
|
71
|
+
if opts['i'] && filename
|
72
|
+
cp filename, "#{filename}.#{opts['i']}"
|
73
|
+
File.open(filename, 'w') { |f| f.puts output }
|
74
|
+
else
|
75
|
+
puts output
|
76
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"a":2,"b":3.141,"TIME":"2007-03-14T11:52:40","c":"c","d":[1,"b",3.14],"COUNT":666,"e":{"foo":"bar"},"foo":"B\u00e4r","g":"\u677e\u672c\u884c\u5f18","h":1000.0,"bar":"\u00a9 \u2260 \u20ac!","i":0.001,"j":"\ud840\udc01"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
4
|
+
<head>
|
5
|
+
<title>Javascript Example</title>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
7
|
+
<script src="prototype.js" type="text/javascript"></script>
|
8
|
+
</head>
|
9
|
+
|
10
|
+
<body>
|
11
|
+
<h1>Fetching object from server</h1>
|
12
|
+
<div id="list">
|
13
|
+
Wait...<br/>
|
14
|
+
<noscript><p>Switch on Javascript!</p></noscript>
|
15
|
+
</div>
|
16
|
+
<script type="text/javascript">
|
17
|
+
<!--
|
18
|
+
function pollJSON() {
|
19
|
+
new Ajax.Request('/json',
|
20
|
+
{
|
21
|
+
method: 'get',
|
22
|
+
onSuccess: function(transport) {
|
23
|
+
var response = transport.responseText || "no response text";
|
24
|
+
response = eval("(" + response + ")");
|
25
|
+
var text = "";
|
26
|
+
for (var k in response) {
|
27
|
+
text = text + "<b>" + k + "</b>: " + response[k] + "<br/>"
|
28
|
+
}
|
29
|
+
$("list").update(text);
|
30
|
+
},
|
31
|
+
onFailure: function() { alert('Something went wrong...') }
|
32
|
+
});
|
33
|
+
}
|
34
|
+
new PeriodicalExecuter(pollJSON, 1);
|
35
|
+
-->
|
36
|
+
</script>
|
37
|
+
</body>
|
38
|
+
</html>
|