json_pure 1.4.6 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +6 -0
- data/COPYING-json-jruby +57 -0
- data/README-json-jruby.markdown +33 -0
- data/Rakefile +224 -119
- data/VERSION +1 -1
- data/benchmarks/generator2_benchmark.rb +1 -1
- data/benchmarks/generator_benchmark.rb +1 -1
- data/ext/json/ext/generator/generator.c +20 -20
- data/ext/json/ext/generator/generator.h +7 -7
- data/ext/json/ext/parser/extconf.rb +1 -0
- data/ext/json/ext/parser/parser.c +122 -88
- data/ext/json/ext/parser/parser.h +7 -0
- data/ext/json/ext/parser/parser.rl +54 -20
- data/java/lib/bytelist-1.0.6.jar +0 -0
- data/java/lib/jcodings.jar +0 -0
- data/java/src/json/ext/ByteListTranscoder.java +167 -0
- data/java/src/json/ext/Generator.java +441 -0
- data/java/src/json/ext/GeneratorMethods.java +231 -0
- data/java/src/json/ext/GeneratorService.java +42 -0
- data/java/src/json/ext/GeneratorState.java +473 -0
- data/java/src/json/ext/OptionsReader.java +119 -0
- data/java/src/json/ext/Parser.java +2295 -0
- data/java/src/json/ext/Parser.rl +825 -0
- data/java/src/json/ext/ParserService.java +34 -0
- data/java/src/json/ext/RuntimeInfo.java +119 -0
- data/java/src/json/ext/StringDecoder.java +166 -0
- data/java/src/json/ext/StringEncoder.java +106 -0
- data/java/src/json/ext/Utils.java +89 -0
- data/json-java.gemspec +20 -0
- data/lib/json/add/core.rb +1 -2
- data/lib/json/add/rails.rb +4 -54
- data/lib/json/common.rb +36 -8
- data/lib/json/editor.rb +1 -3
- data/lib/json/ext.rb +2 -2
- data/lib/json/pure.rb +2 -64
- data/lib/json/pure/generator.rb +10 -8
- data/lib/json/pure/parser.rb +23 -12
- data/lib/json/version.rb +1 -1
- data/tests/setup_variant.rb +11 -0
- data/tests/test_json.rb +1 -5
- data/tests/test_json_addition.rb +14 -9
- data/tests/test_json_encoding.rb +9 -12
- data/tests/test_json_fixtures.rb +9 -8
- data/tests/test_json_generate.rb +3 -5
- data/tests/test_json_string_matching.rb +40 -0
- data/tests/test_json_unicode.rb +1 -5
- metadata +51 -13
- data/tests/test_json_rails.rb +0 -144
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
2010-08-15 (1.5.0)
|
2
|
+
* Included Java source codes for the Jruby extension made by Daniel Luz
|
3
|
+
<dev@mernen.com>.
|
4
|
+
* Output full exception message of deep_const_get to aid debugging.
|
5
|
+
* Fixed an issue with ruby 1.9 Module#const_defined? method, that was
|
6
|
+
reported by Riley Goodside.
|
1
7
|
2010-08-09 (1.4.6)
|
2
8
|
* Fixed oversight reported in http://github.com/flori/json/issues/closed#issue/23,
|
3
9
|
always create a new object from the state prototype.
|
data/COPYING-json-jruby
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
JSON-JRuby is copyrighted free software by Daniel Luz <mernen at gmail dot com>,
|
2
|
+
and is a derivative work of Florian Frank's json library <flori at ping dot de>.
|
3
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
4
|
+
version 2 (see the file GPL), or the conditions below:
|
5
|
+
|
6
|
+
1. You may make and give away verbatim copies of the source form of the
|
7
|
+
software without restriction, provided that you duplicate all of the
|
8
|
+
original copyright notices and associated disclaimers.
|
9
|
+
|
10
|
+
2. You may modify your copy of the software in any way, provided that
|
11
|
+
you do at least ONE of the following:
|
12
|
+
|
13
|
+
a) place your modifications in the Public Domain or otherwise
|
14
|
+
make them Freely Available, such as by posting said
|
15
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
16
|
+
the author to include your modifications in the software.
|
17
|
+
|
18
|
+
b) use the modified software only within your corporation or
|
19
|
+
organization.
|
20
|
+
|
21
|
+
c) give non-standard binaries non-standard names, with
|
22
|
+
instructions on where to get the original software distribution.
|
23
|
+
|
24
|
+
d) make other distribution arrangements with the author.
|
25
|
+
|
26
|
+
3. You may distribute the software in object code or binary form,
|
27
|
+
provided that you do at least ONE of the following:
|
28
|
+
|
29
|
+
a) distribute the binaries and library files of the software,
|
30
|
+
together with instructions (in the manual page or equivalent)
|
31
|
+
on where to get the original distribution.
|
32
|
+
|
33
|
+
b) accompany the distribution with the machine-readable source of
|
34
|
+
the software.
|
35
|
+
|
36
|
+
c) give non-standard binaries non-standard names, with
|
37
|
+
instructions on where to get the original software distribution.
|
38
|
+
|
39
|
+
d) make other distribution arrangements with the author.
|
40
|
+
|
41
|
+
4. You may modify and include the part of the software into any other
|
42
|
+
software (possibly commercial). But some files in the distribution
|
43
|
+
are not written by the author, so that they are not under these terms.
|
44
|
+
|
45
|
+
For the list of those files and their copying conditions, see the
|
46
|
+
file LEGAL.
|
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.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
JSON-JRuby
|
2
|
+
==========
|
3
|
+
|
4
|
+
JSON-JRuby is a port of Florian Frank's native
|
5
|
+
[`json` library](http://json.rubyforge.org/) to JRuby.
|
6
|
+
It aims to be a perfect drop-in replacement for `json_pure`.
|
7
|
+
|
8
|
+
|
9
|
+
Development version
|
10
|
+
===================
|
11
|
+
|
12
|
+
The latest version is available from the
|
13
|
+
[Git repository](http://github.com/mernen/json-jruby/tree):
|
14
|
+
|
15
|
+
git clone git://github.com/mernen/json-jruby.git
|
16
|
+
|
17
|
+
|
18
|
+
Compiling
|
19
|
+
=========
|
20
|
+
|
21
|
+
You'll need JRuby version 1.2 or greater to build JSON-JRuby.
|
22
|
+
Its path must be set on the `jruby.dir` property of
|
23
|
+
`nbproject/project.properties` (defaults to `../jruby`).
|
24
|
+
|
25
|
+
Additionally, you'll need [Ant](http://ant.apache.org/), and
|
26
|
+
[Ragel](http://www.cs.queensu.ca/~thurston/ragel/) 6.4 or greater.
|
27
|
+
|
28
|
+
Then, from the folder where the sources are located, type:
|
29
|
+
|
30
|
+
ant clean jar
|
31
|
+
|
32
|
+
to clean any leftovers from previous builds and generate the `.jar` files.
|
33
|
+
To generate a RubyGem, specify the `gem` action rather than `jar`.
|
data/Rakefile
CHANGED
@@ -6,34 +6,45 @@ end
|
|
6
6
|
begin
|
7
7
|
require 'rake/extensiontask'
|
8
8
|
rescue LoadError
|
9
|
-
|
9
|
+
warn "WARNING: rake-compiler is not installed. You will not be able to build the json gem until you install it."
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'rbconfig'
|
13
13
|
include Config
|
14
14
|
|
15
15
|
require 'rake/clean'
|
16
|
-
CLOBBER.include Dir['benchmarks/data/*.{dat,log}']
|
16
|
+
CLOBBER.include Dir['benchmarks/data/*.{dat,log}']
|
17
17
|
CLEAN.include FileList['diagrams/*.*'], 'doc', 'coverage', 'tmp',
|
18
|
-
FileList["ext/**/{Makefile,mkmf.log}"],
|
19
|
-
FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def}"]
|
18
|
+
FileList["ext/**/{Makefile,mkmf.log}"], 'build', 'dist', FileList['**/*.rbc'],
|
19
|
+
FileList["{ext,lib}/**/*.{so,bundle,#{CONFIG['DLEXT']},o,obj,pdb,lib,manifest,exp,def,jar,class}"],
|
20
|
+
FileList['java/src/**/*.class']
|
20
21
|
|
21
22
|
MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
|
22
23
|
PKG_NAME = 'json'
|
23
24
|
PKG_TITLE = 'JSON Implementation for Ruby'
|
24
25
|
PKG_VERSION = File.read('VERSION').chomp
|
25
|
-
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs
|
26
|
+
PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\.|\.iml\Z/).exclude(/\.(so|bundle|o|class|#{CONFIG['DLEXT']})$/)
|
27
|
+
|
26
28
|
EXT_ROOT_DIR = 'ext/json/ext'
|
27
29
|
EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
|
28
30
|
EXT_PARSER_DL = "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}"
|
31
|
+
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
|
29
32
|
EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
|
30
33
|
PKG_FILES << EXT_PARSER_SRC
|
31
34
|
EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
|
32
35
|
EXT_GENERATOR_DL = "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}"
|
33
36
|
EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
|
37
|
+
|
38
|
+
JAVA_DIR = "java/src/json/ext"
|
39
|
+
JAVA_RAGEL_PATH = "#{JAVA_DIR}/Parser.rl"
|
40
|
+
JAVA_PARSER_SRC = "#{JAVA_DIR}/Parser.java"
|
41
|
+
JAVA_SOURCES = FileList["#{JAVA_DIR}/*.java"]
|
42
|
+
JAVA_CLASSES = []
|
43
|
+
JRUBY_PARSER_JAR = File.expand_path("lib/json/ext/parser.jar")
|
44
|
+
JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
|
45
|
+
|
34
46
|
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
|
35
47
|
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
|
36
|
-
RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
|
37
48
|
|
38
49
|
def myruby(*args, &block)
|
39
50
|
@myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
|
@@ -71,112 +82,6 @@ else
|
|
71
82
|
task :install => :install_ext
|
72
83
|
end
|
73
84
|
|
74
|
-
desc "Compiling extension"
|
75
|
-
task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
|
76
|
-
|
77
|
-
file EXT_PARSER_DL => EXT_PARSER_SRC do
|
78
|
-
cd EXT_PARSER_DIR do
|
79
|
-
myruby 'extconf.rb'
|
80
|
-
sh MAKE
|
81
|
-
end
|
82
|
-
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
83
|
-
end
|
84
|
-
|
85
|
-
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
|
86
|
-
cd EXT_GENERATOR_DIR do
|
87
|
-
myruby 'extconf.rb'
|
88
|
-
sh MAKE
|
89
|
-
end
|
90
|
-
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
91
|
-
end
|
92
|
-
|
93
|
-
desc "Generate parser with ragel"
|
94
|
-
task :ragel => EXT_PARSER_SRC
|
95
|
-
|
96
|
-
task :ragel_clean do
|
97
|
-
rm_rf EXT_PARSER_SRC
|
98
|
-
end
|
99
|
-
|
100
|
-
file EXT_PARSER_SRC => RAGEL_PATH do
|
101
|
-
cd EXT_PARSER_DIR do
|
102
|
-
if RAGEL_CODEGEN == 'ragel'
|
103
|
-
sh "ragel parser.rl -G2 -o parser.c"
|
104
|
-
else
|
105
|
-
sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
desc "Generate diagrams of ragel parser (ps)"
|
111
|
-
task :ragel_dot_ps do
|
112
|
-
root = 'diagrams'
|
113
|
-
specs = []
|
114
|
-
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
115
|
-
for s in specs
|
116
|
-
if RAGEL_DOTGEN == 'ragel'
|
117
|
-
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tps -o#{root}/#{s}.ps"
|
118
|
-
else
|
119
|
-
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
desc "Generate diagrams of ragel parser (png)"
|
125
|
-
task :ragel_dot_png do
|
126
|
-
root = 'diagrams'
|
127
|
-
specs = []
|
128
|
-
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
129
|
-
for s in specs
|
130
|
-
if RAGEL_DOTGEN == 'ragel'
|
131
|
-
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tpng -o#{root}/#{s}.png"
|
132
|
-
else
|
133
|
-
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
desc "Generate diagrams of ragel parser"
|
139
|
-
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
|
140
|
-
|
141
|
-
desc "Testing library (pure ruby)"
|
142
|
-
task :test_pure => :clean do
|
143
|
-
ENV['JSON'] = 'pure'
|
144
|
-
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
|
145
|
-
myruby "-S testrb #{Dir['./tests/*.rb'] * ' '}"
|
146
|
-
end
|
147
|
-
|
148
|
-
desc "Testing library (extension)"
|
149
|
-
task :test_ext => :compile_ext do
|
150
|
-
ENV['JSON'] = 'ext'
|
151
|
-
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
|
152
|
-
myruby "-S testrb #{Dir['./tests/*.rb'] * ' '}"
|
153
|
-
end
|
154
|
-
|
155
|
-
desc "Testing library (pure ruby and extension)"
|
156
|
-
task :test => [ :test_pure, :test_ext ]
|
157
|
-
|
158
|
-
desc "Benchmarking parser"
|
159
|
-
task :benchmark_parser do
|
160
|
-
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
|
161
|
-
myruby 'benchmarks/parser_benchmark.rb'
|
162
|
-
myruby 'benchmarks/parser2_benchmark.rb'
|
163
|
-
end
|
164
|
-
|
165
|
-
desc "Benchmarking generator"
|
166
|
-
task :benchmark_generator do
|
167
|
-
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
|
168
|
-
myruby 'benchmarks/generator_benchmark.rb'
|
169
|
-
myruby 'benchmarks/generator2_benchmark.rb'
|
170
|
-
end
|
171
|
-
|
172
|
-
desc "Benchmarking library"
|
173
|
-
task :benchmark => [ :benchmark_parser, :benchmark_generator ]
|
174
|
-
|
175
|
-
desc "Create RDOC documentation"
|
176
|
-
task :doc => [ :version, EXT_PARSER_SRC ] do
|
177
|
-
sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
|
178
|
-
end
|
179
|
-
|
180
85
|
if defined?(Gem) and defined?(Rake::GemPackageTask)
|
181
86
|
spec_pure = Gem::Specification.new do |s|
|
182
87
|
s.name = 'json_pure'
|
@@ -196,7 +101,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask)
|
|
196
101
|
s.extra_rdoc_files << 'README'
|
197
102
|
s.rdoc_options <<
|
198
103
|
'--title' << 'JSON implemention for ruby' << '--main' << 'README'
|
199
|
-
s.test_files.concat Dir['tests
|
104
|
+
s.test_files.concat Dir['./tests/test_*.rb']
|
200
105
|
|
201
106
|
s.author = "Florian Frank"
|
202
107
|
s.email = "flori@ping.de"
|
@@ -233,7 +138,7 @@ if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::Extension
|
|
233
138
|
s.extra_rdoc_files << 'README'
|
234
139
|
s.rdoc_options <<
|
235
140
|
'--title' << 'JSON implemention for Ruby' << '--main' << 'README'
|
236
|
-
s.test_files.concat Dir['tests
|
141
|
+
s.test_files.concat Dir['./tests/test_*.rb']
|
237
142
|
|
238
143
|
s.author = "Florian Frank"
|
239
144
|
s.email = "flori@ping.de"
|
@@ -282,11 +187,211 @@ EOT
|
|
282
187
|
end
|
283
188
|
end
|
284
189
|
|
285
|
-
desc "
|
286
|
-
task :
|
287
|
-
|
288
|
-
|
190
|
+
desc "Testing library (pure ruby)"
|
191
|
+
task :test_pure => :clean do
|
192
|
+
ENV['JSON'] = 'pure'
|
193
|
+
ENV['RUBYOPT'] = "-Ilib #{ENV['RUBYOPT']}"
|
194
|
+
myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
|
195
|
+
end
|
196
|
+
|
197
|
+
desc "Testing library (pure ruby and extension)"
|
198
|
+
task :test => [ :test_pure, :test_ext ]
|
199
|
+
|
200
|
+
|
201
|
+
if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
|
202
|
+
file JAVA_PARSER_SRC => JAVA_RAGEL_PATH do
|
203
|
+
cd JAVA_DIR do
|
204
|
+
if RAGEL_CODEGEN == 'ragel'
|
205
|
+
sh "ragel Parser.rl -J -o Parser.java"
|
206
|
+
else
|
207
|
+
sh "ragel -x Parser.rl | #{RAGEL_CODEGEN} -J"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
desc "Generate parser for java with ragel"
|
213
|
+
task :ragel => JAVA_PARSER_SRC
|
214
|
+
|
215
|
+
desc "Delete the ragel generated Java source"
|
216
|
+
task :ragel_clean do
|
217
|
+
rm_rf JAVA_PARSER_SRC
|
218
|
+
end
|
219
|
+
|
220
|
+
JRUBY_JAR = File.join(Config::CONFIG["libdir"], "jruby.jar")
|
221
|
+
if File.exist?(JRUBY_JAR)
|
222
|
+
JAVA_SOURCES.each do |src|
|
223
|
+
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
|
224
|
+
obj = src.sub(/\.java\Z/, '.class')
|
225
|
+
file obj => src do
|
226
|
+
sh 'javac', '-classpath', classpath, '-source', '1.5', src
|
227
|
+
end
|
228
|
+
JAVA_CLASSES << obj
|
229
|
+
end
|
230
|
+
else
|
231
|
+
warn "WARNING: Cannot find jruby in path => Cannot build jruby extension!"
|
232
|
+
end
|
233
|
+
|
234
|
+
desc "Compiling jruby extension"
|
235
|
+
task :compile_ext => JAVA_CLASSES
|
236
|
+
|
237
|
+
desc "Package the jruby gem"
|
238
|
+
task :jruby_gem => :create_jar do
|
239
|
+
sh 'gem build json-java.gemspec'
|
240
|
+
mkdir_p 'pkg'
|
241
|
+
mv "json-#{PKG_VERSION}-java.gem", 'pkg'
|
242
|
+
end
|
243
|
+
|
244
|
+
desc "Testing library (jruby)"
|
245
|
+
task :test_ext => :create_jar do
|
246
|
+
ENV['JSON'] = 'ext'
|
247
|
+
myruby '-S', 'testrb', '-Ilib', *Dir['./tests/test_*.rb']
|
248
|
+
end
|
249
|
+
|
250
|
+
file JRUBY_PARSER_JAR => :compile_ext do
|
251
|
+
cd 'java/src' do
|
252
|
+
parser_classes = FileList[
|
253
|
+
"json/ext/ByteListTranscoder*.class",
|
254
|
+
"json/ext/OptionsReader*.class",
|
255
|
+
"json/ext/Parser*.class",
|
256
|
+
"json/ext/RuntimeInfo*.class",
|
257
|
+
"json/ext/StringDecoder*.class",
|
258
|
+
"json/ext/Utils*.class"
|
259
|
+
]
|
260
|
+
sh 'jar', 'cf', File.basename(JRUBY_PARSER_JAR), *parser_classes
|
261
|
+
mv File.basename(JRUBY_PARSER_JAR), File.dirname(JRUBY_PARSER_JAR)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
desc "Create parser jar"
|
266
|
+
task :create_parser_jar => JRUBY_PARSER_JAR
|
267
|
+
|
268
|
+
file JRUBY_GENERATOR_JAR => :compile_ext do
|
269
|
+
cd 'java/src' do
|
270
|
+
generator_classes = FileList[
|
271
|
+
"json/ext/ByteListTranscoder*.class",
|
272
|
+
"json/ext/OptionsReader*.class",
|
273
|
+
"json/ext/Generator*.class",
|
274
|
+
"json/ext/RuntimeInfo*.class",
|
275
|
+
"json/ext/StringEncoder*.class",
|
276
|
+
"json/ext/Utils*.class"
|
277
|
+
]
|
278
|
+
sh 'jar', 'cf', File.basename(JRUBY_GENERATOR_JAR), *generator_classes
|
279
|
+
mv File.basename(JRUBY_GENERATOR_JAR), File.dirname(JRUBY_GENERATOR_JAR)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
desc "Create generator jar"
|
284
|
+
task :create_generator_jar => JRUBY_GENERATOR_JAR
|
285
|
+
|
286
|
+
desc "Create parser and generator jars"
|
287
|
+
task :create_jar => [ :create_parser_jar, :create_generator_jar ]
|
288
|
+
|
289
|
+
desc "Build all gems and archives for a new release of the jruby extension."
|
290
|
+
task :release => [ :clean, :version, :jruby_gem ]
|
291
|
+
else
|
292
|
+
desc "Compiling extension"
|
293
|
+
task :compile_ext => [ EXT_PARSER_DL, EXT_GENERATOR_DL ]
|
294
|
+
|
295
|
+
file EXT_PARSER_DL => EXT_PARSER_SRC do
|
296
|
+
cd EXT_PARSER_DIR do
|
297
|
+
myruby 'extconf.rb'
|
298
|
+
sh MAKE
|
299
|
+
end
|
300
|
+
cp "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
301
|
+
end
|
302
|
+
|
303
|
+
file EXT_GENERATOR_DL => EXT_GENERATOR_SRC do
|
304
|
+
cd EXT_GENERATOR_DIR do
|
305
|
+
myruby 'extconf.rb'
|
306
|
+
sh MAKE
|
307
|
+
end
|
308
|
+
cp "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}", EXT_ROOT_DIR
|
309
|
+
end
|
310
|
+
|
311
|
+
desc "Testing library (extension)"
|
312
|
+
task :test_ext => :compile_ext do
|
313
|
+
ENV['JSON'] = 'ext'
|
314
|
+
ENV['RUBYOPT'] = "-Iext:lib #{ENV['RUBYOPT']}"
|
315
|
+
myruby '-S', 'testrb', *Dir['./tests/test_*.rb']
|
316
|
+
end
|
317
|
+
|
318
|
+
desc "Benchmarking parser"
|
319
|
+
task :benchmark_parser do
|
320
|
+
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
|
321
|
+
myruby 'benchmarks/parser_benchmark.rb'
|
322
|
+
myruby 'benchmarks/parser2_benchmark.rb'
|
323
|
+
end
|
324
|
+
|
325
|
+
desc "Benchmarking generator"
|
326
|
+
task :benchmark_generator do
|
327
|
+
ENV['RUBYOPT'] = "-Ilib:ext #{ENV['RUBYOPT']}"
|
328
|
+
myruby 'benchmarks/generator_benchmark.rb'
|
329
|
+
myruby 'benchmarks/generator2_benchmark.rb'
|
330
|
+
end
|
331
|
+
|
332
|
+
desc "Benchmarking library"
|
333
|
+
task :benchmark => [ :benchmark_parser, :benchmark_generator ]
|
334
|
+
|
335
|
+
desc "Create RDOC documentation"
|
336
|
+
task :doc => [ :version, EXT_PARSER_SRC ] do
|
337
|
+
sh "sdoc -o doc -t '#{PKG_TITLE}' -m README README lib/json.rb #{FileList['lib/json/**/*.rb']} #{EXT_PARSER_SRC} #{EXT_GENERATOR_SRC}"
|
338
|
+
end
|
339
|
+
|
340
|
+
desc "Generate parser with ragel"
|
341
|
+
task :ragel => EXT_PARSER_SRC
|
342
|
+
|
343
|
+
desc "Delete the ragel generated C source"
|
344
|
+
task :ragel_clean do
|
345
|
+
rm_rf EXT_PARSER_SRC
|
346
|
+
end
|
347
|
+
|
348
|
+
file EXT_PARSER_SRC => RAGEL_PATH do
|
349
|
+
cd EXT_PARSER_DIR do
|
350
|
+
if RAGEL_CODEGEN == 'ragel'
|
351
|
+
sh "ragel parser.rl -G2 -o parser.c"
|
352
|
+
else
|
353
|
+
sh "ragel -x parser.rl | #{RAGEL_CODEGEN} -G2"
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
desc "Generate diagrams of ragel parser (ps)"
|
359
|
+
task :ragel_dot_ps do
|
360
|
+
root = 'diagrams'
|
361
|
+
specs = []
|
362
|
+
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
363
|
+
for s in specs
|
364
|
+
if RAGEL_DOTGEN == 'ragel'
|
365
|
+
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tps -o#{root}/#{s}.ps"
|
366
|
+
else
|
367
|
+
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tps -o#{root}/#{s}.ps"
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
desc "Generate diagrams of ragel parser (png)"
|
373
|
+
task :ragel_dot_png do
|
374
|
+
root = 'diagrams'
|
375
|
+
specs = []
|
376
|
+
File.new(RAGEL_PATH).grep(/^\s*machine\s*(\S+);\s*$/) { specs << $1 }
|
377
|
+
for s in specs
|
378
|
+
if RAGEL_DOTGEN == 'ragel'
|
379
|
+
sh "ragel #{RAGEL_PATH} -S#{s} -p -V | dot -Tpng -o#{root}/#{s}.png"
|
380
|
+
else
|
381
|
+
sh "ragel -x #{RAGEL_PATH} -S#{s} | #{RAGEL_DOTGEN} -p|dot -Tpng -o#{root}/#{s}.png"
|
382
|
+
end
|
383
|
+
end
|
384
|
+
end
|
385
|
+
|
386
|
+
desc "Generate diagrams of ragel parser"
|
387
|
+
task :ragel_dot => [ :ragel_dot_png, :ragel_dot_ps ]
|
388
|
+
|
389
|
+
desc "Build all gems and archives for a new release of json and json_pure."
|
390
|
+
task :release => [ :clean, :version, :cross, :native, :gem, ] do
|
391
|
+
sh "#$0 clean native gem"
|
392
|
+
sh "#$0 clean package"
|
393
|
+
end
|
289
394
|
end
|
290
395
|
|
291
396
|
desc "Compile in the the source directory"
|
292
|
-
task :default => [ :version
|
397
|
+
task :default => [ :version ]
|