engineyard-serverside 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. data/lib/engineyard-serverside.rb +3 -3
  2. data/lib/engineyard-serverside/configuration.rb +6 -6
  3. data/lib/engineyard-serverside/deploy.rb +11 -7
  4. data/lib/engineyard-serverside/version.rb +1 -1
  5. data/lib/vendor/multi_json/CHANGELOG.md +121 -0
  6. data/lib/vendor/multi_json/CONTRIBUTING.md +46 -0
  7. data/lib/vendor/multi_json/Gemfile +31 -0
  8. data/lib/vendor/multi_json/LICENSE.md +20 -0
  9. data/lib/vendor/multi_json/README.md +105 -0
  10. data/lib/vendor/multi_json/Rakefile +12 -0
  11. data/lib/vendor/multi_json/lib/multi_json.rb +137 -0
  12. data/lib/vendor/multi_json/lib/multi_json/adapters/gson.rb +20 -0
  13. data/lib/vendor/multi_json/lib/multi_json/adapters/json_common.rb +35 -0
  14. data/lib/vendor/multi_json/lib/multi_json/adapters/json_gem.rb +12 -0
  15. data/lib/vendor/multi_json/lib/multi_json/adapters/json_pure.rb +12 -0
  16. data/lib/vendor/multi_json/lib/multi_json/adapters/nsjsonserialization.rb +35 -0
  17. data/lib/vendor/multi_json/lib/multi_json/adapters/oj.rb +29 -0
  18. data/lib/vendor/multi_json/lib/multi_json/adapters/ok_json.rb +58 -0
  19. data/lib/vendor/multi_json/lib/multi_json/adapters/yajl.rb +20 -0
  20. data/lib/vendor/multi_json/lib/multi_json/vendor/okjson.rb +602 -0
  21. data/lib/vendor/multi_json/lib/multi_json/version.rb +3 -0
  22. data/lib/vendor/multi_json/multi_json.gemspec +22 -0
  23. data/lib/vendor/multi_json/spec/adapter_shared_example.rb +162 -0
  24. data/lib/vendor/multi_json/spec/helper.rb +45 -0
  25. data/lib/vendor/multi_json/spec/json_common_shared_example.rb +36 -0
  26. data/lib/vendor/multi_json/spec/multi_json_spec.rb +151 -0
  27. data/spec/configuration_spec.rb +79 -1
  28. data/spec/deploy_hook_spec.rb +2 -2
  29. data/spec/spec_helper.rb +1 -1
  30. metadata +26 -120
  31. data/lib/vendor/json_pure/CHANGES +0 -166
  32. data/lib/vendor/json_pure/COPYING +0 -58
  33. data/lib/vendor/json_pure/GPL +0 -340
  34. data/lib/vendor/json_pure/README +0 -358
  35. data/lib/vendor/json_pure/Rakefile +0 -292
  36. data/lib/vendor/json_pure/TODO +0 -1
  37. data/lib/vendor/json_pure/VERSION +0 -1
  38. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
  39. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
  40. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
  41. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
  42. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
  43. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
  44. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
  45. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
  46. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
  47. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
  48. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
  49. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
  50. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
  51. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
  52. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
  53. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
  54. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
  55. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
  56. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
  57. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
  58. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
  59. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
  60. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
  61. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
  62. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
  63. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
  64. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
  65. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
  66. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
  67. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
  68. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
  69. data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +0 -222
  70. data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +0 -224
  71. data/lib/vendor/json_pure/benchmarks/ohai.json +0 -1216
  72. data/lib/vendor/json_pure/benchmarks/ohai.ruby +0 -1
  73. data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +0 -251
  74. data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +0 -259
  75. data/lib/vendor/json_pure/bin/edit_json.rb +0 -9
  76. data/lib/vendor/json_pure/bin/prettify_json.rb +0 -75
  77. data/lib/vendor/json_pure/data/example.json +0 -1
  78. data/lib/vendor/json_pure/data/index.html +0 -38
  79. data/lib/vendor/json_pure/data/prototype.js +0 -4184
  80. data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -16
  81. data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1323
  82. data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +0 -170
  83. data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -15
  84. data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +0 -1935
  85. data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +0 -71
  86. data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -792
  87. data/lib/vendor/json_pure/install.rb +0 -26
  88. data/lib/vendor/json_pure/lib/json.rb +0 -10
  89. data/lib/vendor/json_pure/lib/json/Array.xpm +0 -21
  90. data/lib/vendor/json_pure/lib/json/FalseClass.xpm +0 -21
  91. data/lib/vendor/json_pure/lib/json/Hash.xpm +0 -21
  92. data/lib/vendor/json_pure/lib/json/Key.xpm +0 -73
  93. data/lib/vendor/json_pure/lib/json/NilClass.xpm +0 -21
  94. data/lib/vendor/json_pure/lib/json/Numeric.xpm +0 -28
  95. data/lib/vendor/json_pure/lib/json/String.xpm +0 -96
  96. data/lib/vendor/json_pure/lib/json/TrueClass.xpm +0 -21
  97. data/lib/vendor/json_pure/lib/json/add/core.rb +0 -148
  98. data/lib/vendor/json_pure/lib/json/add/rails.rb +0 -58
  99. data/lib/vendor/json_pure/lib/json/common.rb +0 -397
  100. data/lib/vendor/json_pure/lib/json/editor.rb +0 -1371
  101. data/lib/vendor/json_pure/lib/json/ext.rb +0 -15
  102. data/lib/vendor/json_pure/lib/json/json.xpm +0 -1499
  103. data/lib/vendor/json_pure/lib/json/pure.rb +0 -77
  104. data/lib/vendor/json_pure/lib/json/pure/generator.rb +0 -452
  105. data/lib/vendor/json_pure/lib/json/pure/parser.rb +0 -307
  106. data/lib/vendor/json_pure/lib/json/version.rb +0 -8
  107. data/lib/vendor/json_pure/tests/fixtures/fail1.json +0 -1
  108. data/lib/vendor/json_pure/tests/fixtures/fail10.json +0 -1
  109. data/lib/vendor/json_pure/tests/fixtures/fail11.json +0 -1
  110. data/lib/vendor/json_pure/tests/fixtures/fail12.json +0 -1
  111. data/lib/vendor/json_pure/tests/fixtures/fail13.json +0 -1
  112. data/lib/vendor/json_pure/tests/fixtures/fail14.json +0 -1
  113. data/lib/vendor/json_pure/tests/fixtures/fail18.json +0 -1
  114. data/lib/vendor/json_pure/tests/fixtures/fail19.json +0 -1
  115. data/lib/vendor/json_pure/tests/fixtures/fail2.json +0 -1
  116. data/lib/vendor/json_pure/tests/fixtures/fail20.json +0 -1
  117. data/lib/vendor/json_pure/tests/fixtures/fail21.json +0 -1
  118. data/lib/vendor/json_pure/tests/fixtures/fail22.json +0 -1
  119. data/lib/vendor/json_pure/tests/fixtures/fail23.json +0 -1
  120. data/lib/vendor/json_pure/tests/fixtures/fail24.json +0 -1
  121. data/lib/vendor/json_pure/tests/fixtures/fail25.json +0 -1
  122. data/lib/vendor/json_pure/tests/fixtures/fail27.json +0 -2
  123. data/lib/vendor/json_pure/tests/fixtures/fail28.json +0 -2
  124. data/lib/vendor/json_pure/tests/fixtures/fail3.json +0 -1
  125. data/lib/vendor/json_pure/tests/fixtures/fail4.json +0 -1
  126. data/lib/vendor/json_pure/tests/fixtures/fail5.json +0 -1
  127. data/lib/vendor/json_pure/tests/fixtures/fail6.json +0 -1
  128. data/lib/vendor/json_pure/tests/fixtures/fail7.json +0 -1
  129. data/lib/vendor/json_pure/tests/fixtures/fail8.json +0 -1
  130. data/lib/vendor/json_pure/tests/fixtures/fail9.json +0 -1
  131. data/lib/vendor/json_pure/tests/fixtures/pass1.json +0 -56
  132. data/lib/vendor/json_pure/tests/fixtures/pass15.json +0 -1
  133. data/lib/vendor/json_pure/tests/fixtures/pass16.json +0 -1
  134. data/lib/vendor/json_pure/tests/fixtures/pass17.json +0 -1
  135. data/lib/vendor/json_pure/tests/fixtures/pass2.json +0 -1
  136. data/lib/vendor/json_pure/tests/fixtures/pass26.json +0 -1
  137. data/lib/vendor/json_pure/tests/fixtures/pass3.json +0 -6
  138. data/lib/vendor/json_pure/tests/test_json.rb +0 -361
  139. data/lib/vendor/json_pure/tests/test_json_addition.rb +0 -162
  140. data/lib/vendor/json_pure/tests/test_json_encoding.rb +0 -68
  141. data/lib/vendor/json_pure/tests/test_json_fixtures.rb +0 -34
  142. data/lib/vendor/json_pure/tests/test_json_generate.rb +0 -122
  143. data/lib/vendor/json_pure/tests/test_json_rails.rb +0 -144
  144. data/lib/vendor/json_pure/tests/test_json_unicode.rb +0 -76
  145. data/lib/vendor/json_pure/tools/fuzz.rb +0 -139
  146. data/lib/vendor/json_pure/tools/server.rb +0 -61
@@ -1,358 +0,0 @@
1
- == Description
2
-
3
- This is a implementation of the JSON specification according to RFC 4627
4
- http://www.ietf.org/rfc/rfc4627.txt . Starting from version 1.0.0 on there
5
- will be two variants available:
6
-
7
- * A pure ruby variant, that relies on the iconv and the stringscan
8
- extensions, which are both part of the ruby standard library.
9
- * The quite a bit faster C extension variant, which is in parts implemented
10
- in C and comes with its own unicode conversion functions and a parser
11
- generated by the ragel state machine compiler
12
- http://www.cs.queensu.ca/~thurston/ragel .
13
-
14
- Both variants of the JSON generator escape all non-ASCII and control characters
15
- with \uXXXX escape sequences, and support UTF-16 surrogate pairs in order to be
16
- able to generate the whole range of unicode code points. This means that
17
- generated JSON document is encoded as UTF-8 (because ASCII is a subset of
18
- UTF-8) and at the same time avoids decoding problems for receiving endpoints,
19
- that don't expect UTF-8 encoded texts. On the negative side this may lead to a
20
- bit longer strings than necessarry.
21
-
22
- All strings, that are to be encoded as JSON strings, should be UTF-8 byte
23
- sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8
24
- encoded, please use the to_json_raw_object method of String (which produces
25
- an object, that contains a byte array) and decode the result on the receiving
26
- endpoint.
27
-
28
- The JSON parsers can parse UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, and UTF-32LE
29
- JSON documents under Ruby 1.8. Under Ruby 1.9 they take advantage of Ruby's
30
- M17n features and can parse all documents which have the correct
31
- String#encoding set. If a document string has ASCII-8BIT as an encoding the
32
- parser attempts to figure out which of the UTF encodings from above it is and
33
- trys to parse it.
34
-
35
- == Installation
36
-
37
- It's recommended to use the extension variant of JSON, because it's faster than
38
- the pure ruby variant. If you cannot build it on your system, you can settle
39
- for the latter.
40
-
41
- Just type into the command line as root:
42
-
43
- # rake install
44
-
45
- The above command will build the extensions and install them on your system.
46
-
47
- # rake install_pure
48
-
49
- or
50
-
51
- # ruby install.rb
52
-
53
- will just install the pure ruby implementation of JSON.
54
-
55
- If you use Rubygems you can type
56
-
57
- # gem install json
58
-
59
- instead, to install the newest JSON version.
60
-
61
- There is also a pure ruby json only variant of the gem, that can be installed
62
- with:
63
-
64
- # gem install json_pure
65
-
66
- == Compiling the extensions yourself
67
-
68
- If you want to build the extensions yourself you need rake:
69
-
70
- You can get it from rubyforge:
71
- http://rubyforge.org/projects/rake
72
-
73
- or just type
74
-
75
- # gem install rake
76
-
77
- for the installation via rubygems.
78
-
79
- If you want to create the parser.c file from its parser.rl file or draw nice
80
- graphviz images of the state machines, you need ragel from: http://www.cs.queensu.ca/~thurston/ragel
81
-
82
-
83
- == Usage
84
-
85
- To use JSON you can
86
- require 'json'
87
- to load the installed variant (either the extension 'json' or the pure
88
- variant 'json_pure'). If you have installed the extension variant, you can
89
- pick either the extension variant or the pure variant by typing
90
- require 'json/ext'
91
- or
92
- require 'json/pure'
93
-
94
- Now you can parse a JSON document into a ruby data structure by calling
95
-
96
- JSON.parse(document)
97
-
98
- If you want to generate a JSON document from a ruby data structure call
99
- JSON.generate(data)
100
-
101
- You can also use the pretty_generate method (which formats the output more
102
- verbosely and nicely) or fast_generate (which doesn't do any of the security
103
- checks generate performs, e. g. nesting deepness checks).
104
-
105
- To create a valid JSON document you have to make sure, that the output is
106
- embedded in either a JSON array [] or a JSON object {}. The easiest way to do
107
- this, is by putting your values in a Ruby Array or Hash instance.
108
-
109
- There are also the JSON and JSON[] methods which use parse on a String or
110
- generate a JSON document from an array or hash:
111
-
112
- document = JSON 'test' => 23 # => "{\"test\":23}"
113
- document = JSON['test'] => 23 # => "{\"test\":23}"
114
-
115
- and
116
-
117
- data = JSON '{"test":23}' # => {"test"=>23}
118
- data = JSON['{"test":23}'] # => {"test"=>23}
119
-
120
- You can choose to load a set of common additions to ruby core's objects if
121
- you
122
- require 'json/add/core'
123
-
124
- After requiring this you can, e. g., serialise/deserialise Ruby ranges:
125
-
126
- JSON JSON(1..10) # => 1..10
127
-
128
- To find out how to add JSON support to other or your own classes, read the
129
- section "More Examples" below.
130
-
131
- To get the best compatibility to rails' JSON implementation, you can
132
- require 'json/add/rails'
133
-
134
- Both of the additions attempt to require 'json' (like above) first, if it has
135
- not been required yet.
136
-
137
- == More Examples
138
-
139
- To create a JSON document from a ruby data structure, you can call
140
- JSON.generate like that:
141
-
142
- json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
143
- # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
144
-
145
- To get back a ruby data structure from a JSON document, you have to call
146
- JSON.parse on it:
147
-
148
- JSON.parse json
149
- # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
150
-
151
- Note, that the range from the original data structure is a simple
152
- string now. The reason for this is, that JSON doesn't support ranges
153
- or arbitrary classes. In this case the json library falls back to call
154
- Object#to_json, which is the same as #to_s.to_json.
155
-
156
- It's possible to add JSON support serialization to arbitrary classes by
157
- simply implementing a more specialized version of the #to_json method, that
158
- should return a JSON object (a hash converted to JSON with #to_json) like
159
- this (don't forget the *a for all the arguments):
160
-
161
- class Range
162
- def to_json(*a)
163
- {
164
- 'json_class' => self.class.name, # = 'Range'
165
- 'data' => [ first, last, exclude_end? ]
166
- }.to_json(*a)
167
- end
168
- end
169
-
170
- The hash key 'json_class' is the class, that will be asked to deserialise the
171
- JSON representation later. In this case it's 'Range', but any namespace of
172
- the form 'A::B' or '::A::B' will do. All other keys are arbitrary and can be
173
- used to store the necessary data to configure the object to be deserialised.
174
-
175
- If a the key 'json_class' is found in a JSON object, the JSON parser checks
176
- if the given class responds to the json_create class method. If so, it is
177
- called with the JSON object converted to a Ruby hash. So a range can
178
- be deserialised by implementing Range.json_create like this:
179
-
180
- class Range
181
- def self.json_create(o)
182
- new(*o['data'])
183
- end
184
- end
185
-
186
- Now it possible to serialise/deserialise ranges as well:
187
-
188
- json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
189
- # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
190
- JSON.parse json
191
- # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
192
-
193
- JSON.generate always creates the shortest possible string representation of a
194
- ruby data structure in one line. This is good for data storage or network
195
- protocols, but not so good for humans to read. Fortunately there's also
196
- JSON.pretty_generate (or JSON.pretty_generate) that creates a more readable
197
- output:
198
-
199
- puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
200
- [
201
- 1,
202
- 2,
203
- {
204
- "a": 3.141
205
- },
206
- false,
207
- true,
208
- null,
209
- {
210
- "json_class": "Range",
211
- "data": [
212
- 4,
213
- 10,
214
- false
215
- ]
216
- }
217
- ]
218
-
219
- There are also the methods Kernel#j for generate, and Kernel#jj for
220
- pretty_generate output to the console, that work analogous to Core Ruby's p and
221
- the pp library's pp methods.
222
-
223
- The script tools/server.rb contains a small example if you want to test, how
224
- receiving a JSON object from a webrick server in your browser with the
225
- javasript prototype library http://www.prototypejs.org works.
226
-
227
- == Speed Comparisons
228
-
229
- I have created some benchmark results (see the benchmarks/data-p4-3Ghz
230
- subdir of the package) for the JSON-parser to estimate the speed up in the C
231
- extension:
232
-
233
- Comparing times (call_time_mean):
234
- 1 ParserBenchmarkExt#parser 900 repeats:
235
- 553.922304770 ( real) -> 21.500x
236
- 0.001805307
237
- 2 ParserBenchmarkYAML#parser 1000 repeats:
238
- 224.513358139 ( real) -> 8.714x
239
- 0.004454078
240
- 3 ParserBenchmarkPure#parser 1000 repeats:
241
- 26.755020642 ( real) -> 1.038x
242
- 0.037376163
243
- 4 ParserBenchmarkRails#parser 1000 repeats:
244
- 25.763381731 ( real) -> 1.000x
245
- 0.038814780
246
- calls/sec ( time) -> speed covers
247
- secs/call
248
-
249
- In the table above 1 is JSON::Ext::Parser, 2 is YAML.load with YAML
250
- compatbile JSON document, 3 is is JSON::Pure::Parser, and 4 is
251
- ActiveSupport::JSON.decode. The ActiveSupport JSON-decoder converts the
252
- input first to YAML and then uses the YAML-parser, the conversion seems to
253
- slow it down so much that it is only as fast as the JSON::Pure::Parser!
254
-
255
- If you look at the benchmark data you can see that this is mostly caused by
256
- the frequent high outliers - the median of the Rails-parser runs is still
257
- overall smaller than the median of the JSON::Pure::Parser runs:
258
-
259
- Comparing times (call_time_median):
260
- 1 ParserBenchmarkExt#parser 900 repeats:
261
- 800.592479481 ( real) -> 26.936x
262
- 0.001249075
263
- 2 ParserBenchmarkYAML#parser 1000 repeats:
264
- 271.002390644 ( real) -> 9.118x
265
- 0.003690004
266
- 3 ParserBenchmarkRails#parser 1000 repeats:
267
- 30.227910865 ( real) -> 1.017x
268
- 0.033082008
269
- 4 ParserBenchmarkPure#parser 1000 repeats:
270
- 29.722384421 ( real) -> 1.000x
271
- 0.033644676
272
- calls/sec ( time) -> speed covers
273
- secs/call
274
-
275
- I have benchmarked the JSON-Generator as well. This generated a few more
276
- values, because there are different modes that also influence the achieved
277
- speed:
278
-
279
- Comparing times (call_time_mean):
280
- 1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
281
- 547.354332608 ( real) -> 15.090x
282
- 0.001826970
283
- 2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
284
- 443.968212317 ( real) -> 12.240x
285
- 0.002252414
286
- 3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
287
- 375.104545883 ( real) -> 10.341x
288
- 0.002665923
289
- 4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
290
- 49.978706968 ( real) -> 1.378x
291
- 0.020008521
292
- 5 GeneratorBenchmarkRails#generator 1000 repeats:
293
- 38.531868759 ( real) -> 1.062x
294
- 0.025952543
295
- 6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
296
- 36.927649925 ( real) -> 1.018x 7 (>=3859)
297
- 0.027079979
298
- 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats:
299
- 36.272134441 ( real) -> 1.000x 6 (>=3859)
300
- 0.027569373
301
- calls/sec ( time) -> speed covers
302
- secs/call
303
-
304
- In the table above 1-3 are JSON::Ext::Generator methods. 4, 6, and 7 are
305
- JSON::Pure::Generator methods and 5 is the Rails JSON generator. It is now a
306
- bit faster than the generator_safe and generator_pretty methods of the pure
307
- variant but slower than the others.
308
-
309
- To achieve the fastest JSON document output, you can use the fast_generate
310
- method. Beware, that this will disable the checking for circular Ruby data
311
- structures, which may cause JSON to go into an infinite loop.
312
-
313
- Here are the median comparisons for completeness' sake:
314
-
315
- Comparing times (call_time_median):
316
- 1 GeneratorBenchmarkExt#generator_fast 1000 repeats:
317
- 708.258020939 ( real) -> 16.547x
318
- 0.001411915
319
- 2 GeneratorBenchmarkExt#generator_safe 1000 repeats:
320
- 569.105020353 ( real) -> 13.296x
321
- 0.001757145
322
- 3 GeneratorBenchmarkExt#generator_pretty 900 repeats:
323
- 482.825371244 ( real) -> 11.280x
324
- 0.002071142
325
- 4 GeneratorBenchmarkPure#generator_fast 1000 repeats:
326
- 62.717626652 ( real) -> 1.465x
327
- 0.015944481
328
- 5 GeneratorBenchmarkRails#generator 1000 repeats:
329
- 43.965681162 ( real) -> 1.027x
330
- 0.022745013
331
- 6 GeneratorBenchmarkPure#generator_safe 1000 repeats:
332
- 43.929073409 ( real) -> 1.026x 7 (>=3859)
333
- 0.022763968
334
- 7 GeneratorBenchmarkPure#generator_pretty 1000 repeats:
335
- 42.802514491 ( real) -> 1.000x 6 (>=3859)
336
- 0.023363113
337
- calls/sec ( time) -> speed covers
338
- secs/call
339
-
340
- == Author
341
-
342
- Florian Frank <mailto:flori@ping.de>
343
-
344
- == License
345
-
346
- Ruby License, see the COPYING file included in the source distribution. The
347
- Ruby License includes the GNU General Public License (GPL), Version 2, so see
348
- the file GPL as well.
349
-
350
- == Download
351
-
352
- The latest version of this library can be downloaded at
353
-
354
- * http://rubyforge.org/frs?group_id=953
355
-
356
- Online Documentation should be located at
357
-
358
- * http://json.rubyforge.org
@@ -1,292 +0,0 @@
1
- begin
2
- require 'rake/gempackagetask'
3
- rescue LoadError
4
- end
5
-
6
- begin
7
- require 'rake/extensiontask'
8
- rescue LoadError
9
- puts "WARNING: rake-compiler is not installed. You will not be able to build the json gem until you install it."
10
- end
11
-
12
- require 'rbconfig'
13
- include Config
14
-
15
- require 'rake/clean'
16
- CLOBBER.include Dir['benchmarks/data/*.{dat,log}'], FileList['**/*.rbc']
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}"]
20
-
21
- MAKE = ENV['MAKE'] || %w[gmake make].find { |c| system(c, '-v') }
22
- PKG_NAME = 'json'
23
- PKG_TITLE = 'JSON Implementation for Ruby'
24
- PKG_VERSION = File.read('VERSION').chomp
25
- PKG_FILES = FileList["**/*"].exclude(/CVS|pkg|tmp|coverage|Makefile|\.nfs\./).exclude(/\.(so|bundle|o|#{CONFIG['DLEXT']})$/)
26
- EXT_ROOT_DIR = 'ext/json/ext'
27
- EXT_PARSER_DIR = "#{EXT_ROOT_DIR}/parser"
28
- EXT_PARSER_DL = "#{EXT_PARSER_DIR}/parser.#{CONFIG['DLEXT']}"
29
- EXT_PARSER_SRC = "#{EXT_PARSER_DIR}/parser.c"
30
- PKG_FILES << EXT_PARSER_SRC
31
- EXT_GENERATOR_DIR = "#{EXT_ROOT_DIR}/generator"
32
- EXT_GENERATOR_DL = "#{EXT_GENERATOR_DIR}/generator.#{CONFIG['DLEXT']}"
33
- EXT_GENERATOR_SRC = "#{EXT_GENERATOR_DIR}/generator.c"
34
- RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find { |c| system(c, '-v') }
35
- RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find { |c| system(c, '-v') }
36
- RAGEL_PATH = "#{EXT_PARSER_DIR}/parser.rl"
37
-
38
- def myruby(*args, &block)
39
- @myruby ||= File.join(CONFIG['bindir'], CONFIG['ruby_install_name'])
40
- options = (Hash === args.last) ? args.pop : {}
41
- if args.length > 1 then
42
- sh(*([@myruby] + args + [options]), &block)
43
- else
44
- sh("#{@myruby} #{args.first}", options, &block)
45
- end
46
- end
47
-
48
- desc "Installing library (pure)"
49
- task :install_pure => :version do
50
- myruby 'install.rb'
51
- end
52
-
53
- task :install_ext_really do
54
- sitearchdir = CONFIG["sitearchdir"]
55
- cd 'ext' do
56
- for file in Dir["json/ext/*.#{CONFIG['DLEXT']}"]
57
- d = File.join(sitearchdir, file)
58
- mkdir_p File.dirname(d)
59
- install(file, d)
60
- end
61
- end
62
- end
63
-
64
- desc "Installing library (extension)"
65
- task :install_ext => [ :compile_ext, :install_pure, :install_ext_really ]
66
-
67
- desc "Installing library (extension)"
68
- if RUBY_PLATFORM =~ /java/
69
- task :install => :install_pure
70
- else
71
- task :install => :install_ext
72
- end
73
-
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 "rdoc -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
- if defined?(Gem) and defined?(Rake::GemPackageTask)
181
- spec_pure = Gem::Specification.new do |s|
182
- s.name = 'json_pure'
183
- s.version = PKG_VERSION
184
- s.summary = PKG_TITLE
185
- s.description = "This is a JSON implementation in pure Ruby."
186
-
187
- s.files = PKG_FILES
188
-
189
- s.require_path = 'lib'
190
-
191
- s.bindir = "bin"
192
- s.executables = [ "edit_json.rb", "prettify_json.rb" ]
193
- s.default_executable = "edit_json.rb"
194
-
195
- s.has_rdoc = true
196
- s.extra_rdoc_files << 'README'
197
- s.rdoc_options <<
198
- '--title' << 'JSON implemention for ruby' << '--main' << 'README'
199
- s.test_files.concat Dir['tests/*.rb']
200
-
201
- s.author = "Florian Frank"
202
- s.email = "flori@ping.de"
203
- s.homepage = "http://flori.github.com/#{PKG_NAME}"
204
- s.rubyforge_project = "json"
205
- end
206
-
207
- Rake::GemPackageTask.new(spec_pure) do |pkg|
208
- pkg.need_tar = true
209
- pkg.package_files = PKG_FILES
210
- end
211
- end
212
-
213
- if defined?(Gem) and defined?(Rake::GemPackageTask) and defined?(Rake::ExtensionTask)
214
- spec_ext = Gem::Specification.new do |s|
215
- s.name = 'json'
216
- s.version = PKG_VERSION
217
- s.summary = PKG_TITLE
218
- s.description = "This is a JSON implementation as a Ruby extension in C."
219
-
220
- s.files = PKG_FILES
221
-
222
- s.extensions = FileList['ext/**/extconf.rb']
223
-
224
- s.require_path = EXT_ROOT_DIR
225
- s.require_paths << 'ext'
226
- s.require_paths << 'lib'
227
-
228
- s.bindir = "bin"
229
- s.executables = [ "edit_json.rb", "prettify_json.rb" ]
230
- s.default_executable = "edit_json.rb"
231
-
232
- s.has_rdoc = true
233
- s.extra_rdoc_files << 'README'
234
- s.rdoc_options <<
235
- '--title' << 'JSON implemention for Ruby' << '--main' << 'README'
236
- s.test_files.concat Dir['tests/*.rb']
237
-
238
- s.author = "Florian Frank"
239
- s.email = "flori@ping.de"
240
- s.homepage = "http://flori.github.com/#{PKG_NAME}"
241
- s.rubyforge_project = "json"
242
- end
243
-
244
- Rake::GemPackageTask.new(spec_ext) do |pkg|
245
- pkg.need_tar = true
246
- pkg.package_files = PKG_FILES
247
- end
248
-
249
- Rake::ExtensionTask.new do |ext|
250
- ext.name = 'parser'
251
- ext.gem_spec = spec_ext
252
- ext.cross_compile = true
253
- ext.cross_platform = %w[i386-mswin32 i386-mingw32]
254
- ext.ext_dir = 'ext/json/ext/parser'
255
- ext.lib_dir = 'lib/json/ext'
256
- end
257
-
258
- Rake::ExtensionTask.new do |ext|
259
- ext.name = 'generator'
260
- ext.gem_spec = spec_ext
261
- ext.cross_compile = true
262
- ext.cross_platform = %w[i386-mswin32 i386-mingw32]
263
- ext.ext_dir = 'ext/json/ext/generator'
264
- ext.lib_dir = 'lib/json/ext'
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
- end
281
- EOT
282
- end
283
- end
284
-
285
- desc "Build all gems and archives for a new release."
286
- task :release => [ :clean, :version, :cross, :native, :gem ] do
287
- sh "#$0 clean native gem"
288
- sh "#$0 clean package"
289
- end
290
-
291
- desc "Compile in the the source directory"
292
- task :default => [ :version, :compile_ext ]