genki-json 1.1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +97 -0
- data/GPL +340 -0
- data/README +78 -0
- data/RUBY +58 -0
- data/Rakefile +297 -0
- data/TODO +1 -0
- data/VERSION +1 -0
- data/benchmarks/generator_benchmark.rb +141 -0
- data/benchmarks/parser_benchmark.rb +129 -0
- data/bin/edit_json.rb +10 -0
- data/bin/prettify_json.rb +76 -0
- data/data/example.json +1 -0
- data/data/index.html +38 -0
- data/data/prototype.js +4184 -0
- data/doc-templates/main.txt +219 -0
- data/ext/json/ext/generator/extconf.rb +9 -0
- data/ext/json/ext/generator/generator.c +875 -0
- data/ext/json/ext/generator/unicode.c +182 -0
- data/ext/json/ext/generator/unicode.h +53 -0
- data/ext/json/ext/parser/extconf.rb +9 -0
- data/ext/json/ext/parser/parser.c +1758 -0
- data/ext/json/ext/parser/parser.rl +638 -0
- data/ext/json/ext/parser/unicode.c +154 -0
- data/ext/json/ext/parser/unicode.h +58 -0
- data/install.rb +26 -0
- data/json.gemspec +34 -0
- data/lib/json.rb +14 -0
- data/lib/json/Array.xpm +21 -0
- data/lib/json/FalseClass.xpm +21 -0
- data/lib/json/Hash.xpm +21 -0
- data/lib/json/Key.xpm +73 -0
- data/lib/json/NilClass.xpm +21 -0
- data/lib/json/Numeric.xpm +28 -0
- data/lib/json/String.xpm +96 -0
- data/lib/json/TrueClass.xpm +21 -0
- data/lib/json/add/core.rb +135 -0
- data/lib/json/add/rails.rb +58 -0
- data/lib/json/common.rb +354 -0
- data/lib/json/editor.rb +1362 -0
- data/lib/json/ext.rb +15 -0
- data/lib/json/json.xpm +1499 -0
- data/lib/json/pure.rb +77 -0
- data/lib/json/pure/generator.rb +404 -0
- data/lib/json/pure/parser.rb +259 -0
- data/lib/json/version.rb +9 -0
- data/tests/fixtures/fail1.json +1 -0
- data/tests/fixtures/fail10.json +1 -0
- data/tests/fixtures/fail11.json +1 -0
- data/tests/fixtures/fail12.json +1 -0
- data/tests/fixtures/fail13.json +1 -0
- data/tests/fixtures/fail14.json +1 -0
- data/tests/fixtures/fail18.json +1 -0
- data/tests/fixtures/fail19.json +1 -0
- data/tests/fixtures/fail2.json +1 -0
- data/tests/fixtures/fail20.json +1 -0
- data/tests/fixtures/fail21.json +1 -0
- data/tests/fixtures/fail22.json +1 -0
- data/tests/fixtures/fail23.json +1 -0
- data/tests/fixtures/fail24.json +1 -0
- data/tests/fixtures/fail25.json +1 -0
- data/tests/fixtures/fail27.json +2 -0
- data/tests/fixtures/fail28.json +2 -0
- data/tests/fixtures/fail3.json +1 -0
- data/tests/fixtures/fail4.json +1 -0
- data/tests/fixtures/fail5.json +1 -0
- data/tests/fixtures/fail6.json +1 -0
- data/tests/fixtures/fail7.json +1 -0
- data/tests/fixtures/fail8.json +1 -0
- data/tests/fixtures/fail9.json +1 -0
- data/tests/fixtures/pass1.json +56 -0
- data/tests/fixtures/pass15.json +1 -0
- data/tests/fixtures/pass16.json +1 -0
- data/tests/fixtures/pass17.json +1 -0
- data/tests/fixtures/pass2.json +1 -0
- data/tests/fixtures/pass26.json +1 -0
- data/tests/fixtures/pass3.json +6 -0
- data/tests/runner.rb +25 -0
- data/tests/test_json.rb +293 -0
- data/tests/test_json_addition.rb +161 -0
- data/tests/test_json_fixtures.rb +30 -0
- data/tests/test_json_generate.rb +100 -0
- data/tests/test_json_rails.rb +143 -0
- data/tests/test_json_unicode.rb +61 -0
- data/tools/fuzz.rb +140 -0
- data/tools/server.rb +62 -0
- metadata +161 -0
data/RUBY
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
|
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
|
3
|
+
(see COPYING.txt file), or the conditions below:
|
|
4
|
+
|
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
|
6
|
+
software without restriction, provided that you duplicate all of the
|
|
7
|
+
original copyright notices and associated disclaimers.
|
|
8
|
+
|
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
|
10
|
+
you do at least ONE of the following:
|
|
11
|
+
|
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
|
13
|
+
make them Freely Available, such as by posting said
|
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
|
15
|
+
the author to include your modifications in the software.
|
|
16
|
+
|
|
17
|
+
b) use the modified software only within your corporation or
|
|
18
|
+
organization.
|
|
19
|
+
|
|
20
|
+
c) rename any non-standard executables so the names do not conflict
|
|
21
|
+
with standard executables, which must also be provided.
|
|
22
|
+
|
|
23
|
+
d) make other distribution arrangements with the author.
|
|
24
|
+
|
|
25
|
+
3. You may distribute the software in object code or executable
|
|
26
|
+
form, provided that you do at least ONE of the following:
|
|
27
|
+
|
|
28
|
+
a) distribute the executables and library files of the software,
|
|
29
|
+
together with instructions (in the manual page or equivalent)
|
|
30
|
+
on where to get the original distribution.
|
|
31
|
+
|
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
|
33
|
+
the software.
|
|
34
|
+
|
|
35
|
+
c) give non-standard executables non-standard names, with
|
|
36
|
+
instructions on where to get the original software distribution.
|
|
37
|
+
|
|
38
|
+
d) make other distribution arrangements with the author.
|
|
39
|
+
|
|
40
|
+
4. You may modify and include the part of the software into any other
|
|
41
|
+
software (possibly commercial). But some files in the distribution
|
|
42
|
+
are not written by the author, so that they are not under this terms.
|
|
43
|
+
|
|
44
|
+
They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
|
|
45
|
+
files under the ./missing directory. See each file for the copying
|
|
46
|
+
condition.
|
|
47
|
+
|
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
|
49
|
+
output from the software do not automatically fall under the
|
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
|
52
|
+
software.
|
|
53
|
+
|
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
57
|
+
PURPOSE.
|
|
58
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
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"
|
|
127
|
+
task :benchmark_parser do
|
|
128
|
+
ruby 'benchmarks/parser_benchmark.rb'
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
desc "Benchmarking generator"
|
|
132
|
+
task :benchmark_generator do
|
|
133
|
+
ruby 'benchmarks/generator_benchmark.rb'
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
desc "Benchmarking library"
|
|
137
|
+
task :benchmark => [ :benchmark_parser, :benchmark_generator ]
|
|
138
|
+
|
|
139
|
+
desc "Clean benchmark data"
|
|
140
|
+
task :clean_benchmark_data do
|
|
141
|
+
rm_rf Dir['benchmarks/data/*.{dat,log}']
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
desc "Testing library with coverage" # XXX broken
|
|
145
|
+
task :coverage do
|
|
146
|
+
system 'RUBYOPT="" rcov -x tests -Ilib tests/runner.rb'
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
desc "Create RDOC documentation"
|
|
150
|
+
task :doc => [ :version, EXT_PARSER_SRC ] do
|
|
151
|
+
sh "rdoc -S -o doc -m main.txt doc-templates/main.txt lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if defined? Gem
|
|
155
|
+
spec_pure = Gem::Specification.new do |s|
|
|
156
|
+
s.name = 'json_pure'
|
|
157
|
+
s.version = PKG_VERSION
|
|
158
|
+
s.summary = "A JSON implementation in Ruby"
|
|
159
|
+
s.description = ""
|
|
160
|
+
|
|
161
|
+
s.files = PKG_FILES
|
|
162
|
+
|
|
163
|
+
s.require_path = 'lib'
|
|
164
|
+
|
|
165
|
+
s.bindir = "bin"
|
|
166
|
+
s.executables = ["edit_json.rb"]
|
|
167
|
+
s.default_executable = "edit_json.rb"
|
|
168
|
+
|
|
169
|
+
s.has_rdoc = true
|
|
170
|
+
s.rdoc_options <<
|
|
171
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
|
172
|
+
'--main' << 'JSON' << '--line-numbers'
|
|
173
|
+
s.test_files << 'tests/runner.rb'
|
|
174
|
+
|
|
175
|
+
s.author = "Florian Frank"
|
|
176
|
+
s.email = "flori@ping.de"
|
|
177
|
+
s.homepage = "http://json.rubyforge.org"
|
|
178
|
+
s.rubyforge_project = "json"
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
Rake::GemPackageTask.new(spec_pure) do |pkg|
|
|
182
|
+
pkg.need_tar = true
|
|
183
|
+
pkg.package_files += PKG_FILES
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
spec_ext = Gem::Specification.new do |s|
|
|
187
|
+
s.name = 'json'
|
|
188
|
+
s.version = PKG_VERSION
|
|
189
|
+
s.summary = "A JSON implementation as a Ruby extension"
|
|
190
|
+
s.description = ""
|
|
191
|
+
|
|
192
|
+
s.files = PKG_FILES
|
|
193
|
+
|
|
194
|
+
s.extensions <<
|
|
195
|
+
"#{EXT_PARSER_DIR}/extconf.rb" <<
|
|
196
|
+
"#{EXT_GENERATOR_DIR}/extconf.rb"
|
|
197
|
+
|
|
198
|
+
s.require_path = EXT_ROOT_DIR
|
|
199
|
+
s.require_paths << 'ext'
|
|
200
|
+
s.require_paths << 'lib'
|
|
201
|
+
|
|
202
|
+
s.bindir = "bin"
|
|
203
|
+
s.executables = ["edit_json.rb"]
|
|
204
|
+
s.default_executable = "edit_json.rb"
|
|
205
|
+
|
|
206
|
+
s.has_rdoc = true
|
|
207
|
+
s.rdoc_options <<
|
|
208
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
|
209
|
+
'--main' << 'JSON' << '--line-numbers'
|
|
210
|
+
s.test_files << 'tests/runner.rb'
|
|
211
|
+
|
|
212
|
+
s.author = "Florian Frank"
|
|
213
|
+
s.email = "flori@ping.de"
|
|
214
|
+
s.homepage = "http://json.rubyforge.org"
|
|
215
|
+
s.rubyforge_project = "json"
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
Rake::GemPackageTask.new(spec_ext) do |pkg|
|
|
219
|
+
pkg.need_tar = true
|
|
220
|
+
pkg.package_files += PKG_FILES
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
task :package_win => :compile do
|
|
224
|
+
mkdir_p 'pkg'
|
|
225
|
+
spec_win_ext = Gem::Specification.new do |s|
|
|
226
|
+
s.name = 'json'
|
|
227
|
+
s.platform = Gem::Platform::WIN32
|
|
228
|
+
s.version = PKG_VERSION
|
|
229
|
+
s.summary = "A JSON implementation as a Ruby extension"
|
|
230
|
+
s.description = ""
|
|
231
|
+
|
|
232
|
+
s.files = PKG_FILES.to_a <<
|
|
233
|
+
"#{EXT_ROOT_DIR}/parser.#{CONFIG['DLEXT']}" <<
|
|
234
|
+
"#{EXT_ROOT_DIR}/generator.#{CONFIG['DLEXT']}"
|
|
235
|
+
|
|
236
|
+
s.require_path = EXT_ROOT_DIR
|
|
237
|
+
s.require_paths << 'ext'
|
|
238
|
+
s.require_paths << 'lib'
|
|
239
|
+
|
|
240
|
+
s.bindir = "bin"
|
|
241
|
+
s.executables = ["edit_json.rb", "prettify_json.rb"]
|
|
242
|
+
s.default_executable = "edit_json.rb"
|
|
243
|
+
|
|
244
|
+
s.has_rdoc = true
|
|
245
|
+
s.rdoc_options <<
|
|
246
|
+
'--title' << 'JSON -- A JSON implemention' <<
|
|
247
|
+
'--main' << 'JSON' << '--line-numbers'
|
|
248
|
+
s.test_files << 'tests/runner.rb'
|
|
249
|
+
|
|
250
|
+
s.author = "Florian Frank"
|
|
251
|
+
s.email = "flori@ping.de"
|
|
252
|
+
s.homepage = "http://json.rubyforge.org"
|
|
253
|
+
s.rubyforge_project = "json"
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
gem_file = "json-#{spec_win_ext.version}-#{spec_win_ext.platform}.gem"
|
|
257
|
+
Gem::Builder.new(spec_win_ext).build
|
|
258
|
+
mv gem_file, 'pkg'
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
task :mrproper => [ :ragel_clean, :clean, :clean_benchmark_data ] do
|
|
263
|
+
for dir in [ EXT_PARSER_DIR, EXT_GENERATOR_DIR ]
|
|
264
|
+
cd(dir) { rm_f 'Makefile' }
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
desc m = "Writing version information for #{PKG_VERSION}"
|
|
269
|
+
task :version do
|
|
270
|
+
puts m
|
|
271
|
+
File.open(File.join('lib', 'json', 'version.rb'), 'w') do |v|
|
|
272
|
+
v.puts <<EOT
|
|
273
|
+
module JSON
|
|
274
|
+
# JSON version
|
|
275
|
+
VERSION = '#{PKG_VERSION}'
|
|
276
|
+
VERSION_ARRAY = VERSION.split(/\\./).map { |x| x.to_i } # :nodoc:
|
|
277
|
+
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
|
278
|
+
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
|
279
|
+
VERSION_BUILD = VERSION_ARRAY[2] # :nodoc:
|
|
280
|
+
VARIANT_BINARY = #{!!ON_WINDOWS}
|
|
281
|
+
end
|
|
282
|
+
EOT
|
|
283
|
+
end
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
if ON_WINDOWS
|
|
287
|
+
task :release => [ :version, :clean, :package_win ]
|
|
288
|
+
else
|
|
289
|
+
task :release => [ :version, :mrproper, :package ]
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
task :default => [ :version, :compile ]
|
|
293
|
+
|
|
294
|
+
desc "generate gemspec"
|
|
295
|
+
task :gemspec do
|
|
296
|
+
open("#{PKG_NAME}.gemspec", "w"){|file| file.write spec_ext.to_ruby}
|
|
297
|
+
end
|
data/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.1.4.1
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'bullshit'
|
|
4
|
+
$KCODE='utf8'
|
|
5
|
+
require 'bullshit'
|
|
6
|
+
case ARGV.first
|
|
7
|
+
when 'ext'
|
|
8
|
+
require 'json/ext'
|
|
9
|
+
when 'pure'
|
|
10
|
+
require 'json/pure'
|
|
11
|
+
when 'rails'
|
|
12
|
+
require 'active_support'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module JSON
|
|
16
|
+
def self.[](*) end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
module GeneratorBenchmarkCommon
|
|
20
|
+
include JSON
|
|
21
|
+
|
|
22
|
+
def setup
|
|
23
|
+
a = [ nil, false, true, "fÖßÄr", [ "n€st€d", true ], { "fooß" => "bär", "quux" => true } ]
|
|
24
|
+
puts a.to_json
|
|
25
|
+
@big = a * 100
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def generic_reset_method
|
|
29
|
+
@result and @result.size > 2 + 6 * @big.size or raise @result.to_s
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
module JSONGeneratorCommon
|
|
34
|
+
include GeneratorBenchmarkCommon
|
|
35
|
+
|
|
36
|
+
def benchmark_generator_fast
|
|
37
|
+
@result = JSON.fast_generate(@big)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
alias reset_benchmark_generator_fast generic_reset_method
|
|
41
|
+
|
|
42
|
+
def benchmark_generator_safe
|
|
43
|
+
@result = JSON.generate(@big)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
alias reset_benchmark_generator_safe generic_reset_method
|
|
47
|
+
|
|
48
|
+
def benchmark_generator_pretty
|
|
49
|
+
@result = JSON.pretty_generate(@big)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
alias reset_benchmark_generator_pretty generic_reset_method
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
class GeneratorBenchmarkExt < Bullshit::RepeatCase
|
|
56
|
+
include JSONGeneratorCommon
|
|
57
|
+
|
|
58
|
+
warmup yes
|
|
59
|
+
iterations 500
|
|
60
|
+
|
|
61
|
+
truncate_data do
|
|
62
|
+
alpha_level 0.05
|
|
63
|
+
window_size 50
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
67
|
+
output_filename benchmark_name + '.log'
|
|
68
|
+
data_file yes
|
|
69
|
+
histogram yes
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class GeneratorBenchmarkPure < Bullshit::RepeatCase
|
|
73
|
+
include JSONGeneratorCommon
|
|
74
|
+
|
|
75
|
+
warmup yes
|
|
76
|
+
iterations 500
|
|
77
|
+
|
|
78
|
+
truncate_data do
|
|
79
|
+
alpha_level 0.05
|
|
80
|
+
window_size 50
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
84
|
+
output_filename benchmark_name + '.log'
|
|
85
|
+
data_file yes
|
|
86
|
+
histogram yes
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
class GeneratorBenchmarkRails < Bullshit::RepeatCase
|
|
90
|
+
include GeneratorBenchmarkCommon
|
|
91
|
+
|
|
92
|
+
warmup yes
|
|
93
|
+
iterations 500
|
|
94
|
+
|
|
95
|
+
truncate_data do
|
|
96
|
+
alpha_level 0.05
|
|
97
|
+
window_size 50
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
101
|
+
output_filename benchmark_name + '.log'
|
|
102
|
+
data_file yes
|
|
103
|
+
histogram yes
|
|
104
|
+
|
|
105
|
+
def benchmark_generator
|
|
106
|
+
@result = @big.to_json
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
alias reset_benchmark_generator generic_reset_method
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if $0 == __FILE__
|
|
113
|
+
Bullshit::Case.autorun false
|
|
114
|
+
|
|
115
|
+
case ARGV.first
|
|
116
|
+
when 'ext'
|
|
117
|
+
GeneratorBenchmarkExt.run
|
|
118
|
+
when 'pure'
|
|
119
|
+
GeneratorBenchmarkPure.run
|
|
120
|
+
when 'rails'
|
|
121
|
+
GeneratorBenchmarkRails.run
|
|
122
|
+
else
|
|
123
|
+
system "rake clean"
|
|
124
|
+
system "ruby #$0 rails"
|
|
125
|
+
system "ruby #$0 pure"
|
|
126
|
+
system "rake compile"
|
|
127
|
+
system "ruby #$0 ext"
|
|
128
|
+
Bullshit.compare do
|
|
129
|
+
output_filename File.join(File.dirname(__FILE__), 'data', 'GeneratorBenchmarkComparison.log')
|
|
130
|
+
|
|
131
|
+
benchmark GeneratorBenchmarkExt, :generator_fast, :load => yes
|
|
132
|
+
benchmark GeneratorBenchmarkExt, :generator_safe, :load => yes
|
|
133
|
+
benchmark GeneratorBenchmarkExt, :generator_pretty, :load => yes
|
|
134
|
+
benchmark GeneratorBenchmarkPure, :generator_fast, :load => yes
|
|
135
|
+
benchmark GeneratorBenchmarkPure, :generator_safe, :load => yes
|
|
136
|
+
benchmark GeneratorBenchmarkPure, :generator_pretty, :load => yes
|
|
137
|
+
benchmark GeneratorBenchmarkRails, :generator, :load => yes
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|