divoxx-ruby-php-serialization 0.2.0
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/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +10 -0
- data/Rakefile +71 -0
- data/VERSION +1 -0
- data/features/ruby_php_serialization.feature +9 -0
- data/features/step_definitions/ruby_php_serialization_steps.rb +0 -0
- data/features/support/env.rb +4 -0
- data/lib/ruby_php_serialization.rb +2 -0
- data/lib/ruby_php_serialization/parser.rb +346 -0
- data/lib/ruby_php_serialization/parser.y +77 -0
- data/lib/ruby_php_serialization/tokenizer.rb +20 -0
- data/lib/ruby_php_serialization/unserializer.rb +4 -0
- data/ruby-php-serialization.gemspec +66 -0
- data/spec/ruby_php_serialization_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +101 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Rodrigo Kochenburger
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ruby-php-serialization"
|
8
|
+
gem.summary = %Q{PHP's serialization implemenatation for ruby}
|
9
|
+
gem.description = %Q{TODO: longer description of your gem}
|
10
|
+
gem.email = "divoxx@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/divoxx/ruby-php-serialization"
|
12
|
+
gem.authors = ["Rodrigo Kochenburger"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
gem.add_development_dependency "cucumber"
|
15
|
+
gem.add_development_dependency "racc"
|
16
|
+
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
Jeweler::GemcutterTasks.new
|
20
|
+
rescue LoadError
|
21
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'spec/rake/spectask'
|
25
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
26
|
+
spec.libs << 'lib' << 'spec'
|
27
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
|
+
end
|
29
|
+
|
30
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
31
|
+
spec.libs << 'lib' << 'spec'
|
32
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
33
|
+
spec.rcov = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :spec => :check_dependencies
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'cucumber/rake/task'
|
40
|
+
Cucumber::Rake::Task.new(:features)
|
41
|
+
|
42
|
+
task :features => :check_dependencies
|
43
|
+
rescue LoadError
|
44
|
+
task :features do
|
45
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
task :default => :spec
|
50
|
+
|
51
|
+
require 'rake/rdoctask'
|
52
|
+
Rake::RDocTask.new do |rdoc|
|
53
|
+
if File.exist?('VERSION')
|
54
|
+
version = File.read('VERSION')
|
55
|
+
else
|
56
|
+
version = ""
|
57
|
+
end
|
58
|
+
|
59
|
+
rdoc.rdoc_dir = 'rdoc'
|
60
|
+
rdoc.title = "ruby-php-serialization #{version}"
|
61
|
+
rdoc.rdoc_files.include('README*')
|
62
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
file 'lib/ruby_php_serialization/parser.rb' => 'lib/ruby_php_serialization/parser.y' do |t|
|
67
|
+
`racc -o #{t.name} #{t.prerequisites[0]}`
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Compile all the necessary files, such as .y grammar files"
|
71
|
+
task :compile => ['lib/ruby_php_serialization/parser.rb']
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
File without changes
|
@@ -0,0 +1,346 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.6
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
require 'ruby_php_serialization/tokenizer'
|
10
|
+
|
11
|
+
module RubyPhpSerialization
|
12
|
+
class Parser < Racc::Parser
|
13
|
+
|
14
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 66)
|
15
|
+
|
16
|
+
def parse(string)
|
17
|
+
@tokenizer = Tokenizer.new(string)
|
18
|
+
do_parse
|
19
|
+
return @object
|
20
|
+
ensure
|
21
|
+
@tokenizer = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def next_token
|
25
|
+
@tokenizer.next_token
|
26
|
+
end
|
27
|
+
...end parser.y/module_eval...
|
28
|
+
##### State transition tables begin ###
|
29
|
+
|
30
|
+
racc_action_table = [
|
31
|
+
44, 6, 7, 22, 23, 10, 12, 14, 24, 1,
|
32
|
+
25, 43, 5, 44, 6, 7, 26, 27, 10, 12,
|
33
|
+
14, 28, 1, 29, 53, 5, 6, 7, 30, 31,
|
34
|
+
10, 12, 14, 21, 1, 6, 7, 5, 33, 10,
|
35
|
+
12, 14, 34, 1, 6, 7, 5, 35, 10, 12,
|
36
|
+
14, 36, 1, 6, 7, 5, 37, 10, 12, 14,
|
37
|
+
38, 1, 40, 42, 5, 20, 47, 19, 49, 51,
|
38
|
+
18, 17, 32 ]
|
39
|
+
|
40
|
+
racc_action_check = [
|
41
|
+
41, 41, 41, 10, 12, 41, 41, 41, 14, 41,
|
42
|
+
17, 41, 41, 50, 50, 50, 18, 19, 50, 50,
|
43
|
+
50, 20, 50, 22, 50, 50, 49, 49, 23, 24,
|
44
|
+
49, 49, 49, 9, 49, 44, 44, 49, 26, 44,
|
45
|
+
44, 44, 31, 44, 0, 0, 44, 32, 0, 0,
|
46
|
+
0, 33, 0, 51, 51, 0, 34, 51, 51, 51,
|
47
|
+
35, 51, 38, 40, 51, 8, 42, 7, 46, 48,
|
48
|
+
5, 1, 25 ]
|
49
|
+
|
50
|
+
racc_action_pointer = [
|
51
|
+
41, 66, nil, nil, nil, 65, nil, 62, 65, 31,
|
52
|
+
-2, nil, -1, nil, 3, nil, nil, 4, 10, 11,
|
53
|
+
21, nil, 17, 22, 23, 67, 33, nil, nil, nil,
|
54
|
+
nil, 37, 37, 39, 46, 55, nil, nil, 56, nil,
|
55
|
+
58, -2, 54, nil, 32, nil, 66, nil, 67, 23,
|
56
|
+
11, 50, nil, nil, nil ]
|
57
|
+
|
58
|
+
racc_action_default = [
|
59
|
+
-21, -21, -6, -7, -8, -21, -9, -21, -21, -21,
|
60
|
+
-21, -2, -21, -3, -21, -4, -5, -21, -21, -21,
|
61
|
+
-21, -1, -21, -21, -21, -21, -21, -10, 55, -11,
|
62
|
+
-12, -21, -21, -21, -21, -21, -19, -13, -21, -16,
|
63
|
+
-21, -21, -21, -20, -21, -15, -21, -16, -21, -21,
|
64
|
+
-21, -21, -17, -14, -18 ]
|
65
|
+
|
66
|
+
racc_goto_table = [
|
67
|
+
9, 41, 8, 39, nil, nil, nil, nil, nil, 50,
|
68
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
69
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
70
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
71
|
+
nil, nil, nil, nil, 48, nil, nil, nil, nil, 52,
|
72
|
+
nil, 54 ]
|
73
|
+
|
74
|
+
racc_goto_check = [
|
75
|
+
2, 10, 1, 12, nil, nil, nil, nil, nil, 10,
|
76
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
77
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
78
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
79
|
+
nil, nil, nil, nil, 2, nil, nil, nil, nil, 2,
|
80
|
+
nil, 2 ]
|
81
|
+
|
82
|
+
racc_goto_pointer = [
|
83
|
+
nil, 2, 0, nil, nil, nil, nil, nil, nil, nil,
|
84
|
+
-38, nil, -33 ]
|
85
|
+
|
86
|
+
racc_goto_default = [
|
87
|
+
nil, nil, 46, 11, 13, 15, 16, 2, 3, 4,
|
88
|
+
nil, 45, nil ]
|
89
|
+
|
90
|
+
racc_reduce_table = [
|
91
|
+
0, 0, :racc_error,
|
92
|
+
2, 16, :_reduce_1,
|
93
|
+
1, 17, :_reduce_2,
|
94
|
+
1, 17, :_reduce_3,
|
95
|
+
1, 17, :_reduce_4,
|
96
|
+
1, 17, :_reduce_5,
|
97
|
+
1, 17, :_reduce_6,
|
98
|
+
1, 17, :_reduce_7,
|
99
|
+
1, 17, :_reduce_8,
|
100
|
+
1, 18, :_reduce_9,
|
101
|
+
3, 19, :_reduce_10,
|
102
|
+
3, 20, :_reduce_11,
|
103
|
+
3, 21, :_reduce_12,
|
104
|
+
5, 23, :_reduce_13,
|
105
|
+
11, 24, :_reduce_14,
|
106
|
+
2, 25, :_reduce_15,
|
107
|
+
0, 25, :_reduce_16,
|
108
|
+
3, 26, :_reduce_17,
|
109
|
+
4, 26, :_reduce_18,
|
110
|
+
0, 27, :_reduce_19,
|
111
|
+
8, 22, :_reduce_20 ]
|
112
|
+
|
113
|
+
racc_reduce_n = 21
|
114
|
+
|
115
|
+
racc_shift_n = 55
|
116
|
+
|
117
|
+
racc_token_table = {
|
118
|
+
false => 0,
|
119
|
+
:error => 1,
|
120
|
+
";" => 2,
|
121
|
+
"N" => 3,
|
122
|
+
"b" => 4,
|
123
|
+
":" => 5,
|
124
|
+
:NUMBER => 6,
|
125
|
+
"i" => 7,
|
126
|
+
"d" => 8,
|
127
|
+
"s" => 9,
|
128
|
+
:STRING => 10,
|
129
|
+
"O" => 11,
|
130
|
+
"{" => 12,
|
131
|
+
"}" => 13,
|
132
|
+
"a" => 14 }
|
133
|
+
|
134
|
+
racc_nt_base = 15
|
135
|
+
|
136
|
+
racc_use_result_var = true
|
137
|
+
|
138
|
+
Racc_arg = [
|
139
|
+
racc_action_table,
|
140
|
+
racc_action_check,
|
141
|
+
racc_action_default,
|
142
|
+
racc_action_pointer,
|
143
|
+
racc_goto_table,
|
144
|
+
racc_goto_check,
|
145
|
+
racc_goto_default,
|
146
|
+
racc_goto_pointer,
|
147
|
+
racc_nt_base,
|
148
|
+
racc_reduce_table,
|
149
|
+
racc_token_table,
|
150
|
+
racc_shift_n,
|
151
|
+
racc_reduce_n,
|
152
|
+
racc_use_result_var ]
|
153
|
+
|
154
|
+
Racc_token_to_s_table = [
|
155
|
+
"$end",
|
156
|
+
"error",
|
157
|
+
"\";\"",
|
158
|
+
"\"N\"",
|
159
|
+
"\"b\"",
|
160
|
+
"\":\"",
|
161
|
+
"NUMBER",
|
162
|
+
"\"i\"",
|
163
|
+
"\"d\"",
|
164
|
+
"\"s\"",
|
165
|
+
"STRING",
|
166
|
+
"\"O\"",
|
167
|
+
"\"{\"",
|
168
|
+
"\"}\"",
|
169
|
+
"\"a\"",
|
170
|
+
"$start",
|
171
|
+
"serialization",
|
172
|
+
"data",
|
173
|
+
"null",
|
174
|
+
"bool",
|
175
|
+
"integer",
|
176
|
+
"double",
|
177
|
+
"array",
|
178
|
+
"string",
|
179
|
+
"object",
|
180
|
+
"attribute_list",
|
181
|
+
"attribute",
|
182
|
+
"@1" ]
|
183
|
+
|
184
|
+
Racc_debug_parser = false
|
185
|
+
|
186
|
+
##### State transition tables end #####
|
187
|
+
|
188
|
+
# reduce 0 omitted
|
189
|
+
|
190
|
+
module_eval(<<'.,.,', 'parser.y', 3)
|
191
|
+
def _reduce_1(val, _values, result)
|
192
|
+
@object = val[0]
|
193
|
+
result
|
194
|
+
end
|
195
|
+
.,.,
|
196
|
+
|
197
|
+
module_eval(<<'.,.,', 'parser.y', 6)
|
198
|
+
def _reduce_2(val, _values, result)
|
199
|
+
result = val[0]
|
200
|
+
result
|
201
|
+
end
|
202
|
+
.,.,
|
203
|
+
|
204
|
+
module_eval(<<'.,.,', 'parser.y', 7)
|
205
|
+
def _reduce_3(val, _values, result)
|
206
|
+
result = val[0]
|
207
|
+
result
|
208
|
+
end
|
209
|
+
.,.,
|
210
|
+
|
211
|
+
module_eval(<<'.,.,', 'parser.y', 8)
|
212
|
+
def _reduce_4(val, _values, result)
|
213
|
+
result = val[0]
|
214
|
+
result
|
215
|
+
end
|
216
|
+
.,.,
|
217
|
+
|
218
|
+
module_eval(<<'.,.,', 'parser.y', 9)
|
219
|
+
def _reduce_5(val, _values, result)
|
220
|
+
result = val[0]
|
221
|
+
result
|
222
|
+
end
|
223
|
+
.,.,
|
224
|
+
|
225
|
+
module_eval(<<'.,.,', 'parser.y', 10)
|
226
|
+
def _reduce_6(val, _values, result)
|
227
|
+
result = val[0]
|
228
|
+
result
|
229
|
+
end
|
230
|
+
.,.,
|
231
|
+
|
232
|
+
module_eval(<<'.,.,', 'parser.y', 11)
|
233
|
+
def _reduce_7(val, _values, result)
|
234
|
+
result = val[0]
|
235
|
+
result
|
236
|
+
end
|
237
|
+
.,.,
|
238
|
+
|
239
|
+
module_eval(<<'.,.,', 'parser.y', 12)
|
240
|
+
def _reduce_8(val, _values, result)
|
241
|
+
result = val[0]
|
242
|
+
result
|
243
|
+
end
|
244
|
+
.,.,
|
245
|
+
|
246
|
+
module_eval(<<'.,.,', 'parser.y', 15)
|
247
|
+
def _reduce_9(val, _values, result)
|
248
|
+
result = nil
|
249
|
+
result
|
250
|
+
end
|
251
|
+
.,.,
|
252
|
+
|
253
|
+
module_eval(<<'.,.,', 'parser.y', 18)
|
254
|
+
def _reduce_10(val, _values, result)
|
255
|
+
result = Integer(val[2]) > 0
|
256
|
+
result
|
257
|
+
end
|
258
|
+
.,.,
|
259
|
+
|
260
|
+
module_eval(<<'.,.,', 'parser.y', 21)
|
261
|
+
def _reduce_11(val, _values, result)
|
262
|
+
result = Integer(val[2])
|
263
|
+
result
|
264
|
+
end
|
265
|
+
.,.,
|
266
|
+
|
267
|
+
module_eval(<<'.,.,', 'parser.y', 24)
|
268
|
+
def _reduce_12(val, _values, result)
|
269
|
+
result = Float(val[2])
|
270
|
+
result
|
271
|
+
end
|
272
|
+
.,.,
|
273
|
+
|
274
|
+
module_eval(<<'.,.,', 'parser.y', 27)
|
275
|
+
def _reduce_13(val, _values, result)
|
276
|
+
result = val[4]
|
277
|
+
result
|
278
|
+
end
|
279
|
+
.,.,
|
280
|
+
|
281
|
+
module_eval(<<'.,.,', 'parser.y', 32)
|
282
|
+
def _reduce_14(val, _values, result)
|
283
|
+
result = Object.const_get(val[4]).new
|
284
|
+
|
285
|
+
val[9].each do |(attr_name, value)|
|
286
|
+
result.instance_variable_set("@#{attr_name}", value)
|
287
|
+
end
|
288
|
+
|
289
|
+
result
|
290
|
+
end
|
291
|
+
.,.,
|
292
|
+
|
293
|
+
module_eval(<<'.,.,', 'parser.y', 40)
|
294
|
+
def _reduce_15(val, _values, result)
|
295
|
+
result = val[0] << val[1]
|
296
|
+
result
|
297
|
+
end
|
298
|
+
.,.,
|
299
|
+
|
300
|
+
module_eval(<<'.,.,', 'parser.y', 41)
|
301
|
+
def _reduce_16(val, _values, result)
|
302
|
+
result = []
|
303
|
+
result
|
304
|
+
end
|
305
|
+
.,.,
|
306
|
+
|
307
|
+
module_eval(<<'.,.,', 'parser.y', 44)
|
308
|
+
def _reduce_17(val, _values, result)
|
309
|
+
@numeric_array = false unless val[0].is_a?(Integer); result = [val[0], val[2]]
|
310
|
+
result
|
311
|
+
end
|
312
|
+
.,.,
|
313
|
+
|
314
|
+
module_eval(<<'.,.,', 'parser.y', 45)
|
315
|
+
def _reduce_18(val, _values, result)
|
316
|
+
@numeric_array = false unless val[1].is_a?(Integer); result = [val[1], val[3]]
|
317
|
+
result
|
318
|
+
end
|
319
|
+
.,.,
|
320
|
+
|
321
|
+
module_eval(<<'.,.,', 'parser.y', 48)
|
322
|
+
def _reduce_19(val, _values, result)
|
323
|
+
@numeric_array = true
|
324
|
+
result
|
325
|
+
end
|
326
|
+
.,.,
|
327
|
+
|
328
|
+
module_eval(<<'.,.,', 'parser.y', 50)
|
329
|
+
def _reduce_20(val, _values, result)
|
330
|
+
if @numeric_array
|
331
|
+
result = []
|
332
|
+
val[6].each { |(i,v)| result[i] = v }
|
333
|
+
else
|
334
|
+
result = Hash[*val[6].flatten]
|
335
|
+
end
|
336
|
+
|
337
|
+
result
|
338
|
+
end
|
339
|
+
.,.,
|
340
|
+
|
341
|
+
def _reduce_none(val, _values, result)
|
342
|
+
val[0]
|
343
|
+
end
|
344
|
+
|
345
|
+
end # class Parser
|
346
|
+
end # module RubyPhpSerialization
|
@@ -0,0 +1,77 @@
|
|
1
|
+
class RubyPhpSerialization::Parser
|
2
|
+
rule
|
3
|
+
|
4
|
+
serialization : data ';' { @object = val[0] }
|
5
|
+
;
|
6
|
+
|
7
|
+
data : null { result = val[0] }
|
8
|
+
| bool { result = val[0] }
|
9
|
+
| integer { result = val[0] }
|
10
|
+
| double { result = val[0] }
|
11
|
+
| array { result = val[0] }
|
12
|
+
| string { result = val[0] }
|
13
|
+
| object { result = val[0] }
|
14
|
+
;
|
15
|
+
|
16
|
+
null : 'N' { result = nil }
|
17
|
+
;
|
18
|
+
|
19
|
+
bool : 'b' ':' NUMBER { result = Integer(val[2]) > 0 }
|
20
|
+
;
|
21
|
+
|
22
|
+
integer : 'i' ':' NUMBER { result = Integer(val[2]) }
|
23
|
+
;
|
24
|
+
|
25
|
+
double : 'd' ':' NUMBER { result = Float(val[2]) }
|
26
|
+
;
|
27
|
+
|
28
|
+
string : 's' ':' NUMBER ':' STRING { result = val[4] }
|
29
|
+
;
|
30
|
+
|
31
|
+
object : 'O' ':' NUMBER ':' STRING ':' NUMBER ':' '{' attribute_list '}'
|
32
|
+
{
|
33
|
+
result = Object.const_get(val[4]).new
|
34
|
+
|
35
|
+
val[9].each do |(attr_name, value)|
|
36
|
+
result.instance_variable_set("@#{attr_name}", value)
|
37
|
+
end
|
38
|
+
}
|
39
|
+
;
|
40
|
+
|
41
|
+
attribute_list : attribute_list attribute { result = val[0] << val[1] }
|
42
|
+
| { result = [] }
|
43
|
+
;
|
44
|
+
|
45
|
+
attribute : data ';' data { @numeric_array = false unless val[0].is_a?(Integer); result = [val[0], val[2]] }
|
46
|
+
| ';' data ';' data { @numeric_array = false unless val[1].is_a?(Integer); result = [val[1], val[3]] }
|
47
|
+
;
|
48
|
+
|
49
|
+
array : 'a' ':' NUMBER ':' '{' { @numeric_array = true } attribute_list '}'
|
50
|
+
{
|
51
|
+
if @numeric_array
|
52
|
+
result = []
|
53
|
+
val[6].each { |(i,v)| result[i] = v }
|
54
|
+
else
|
55
|
+
result = Hash[*val[6].flatten]
|
56
|
+
end
|
57
|
+
}
|
58
|
+
;
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
---- header ----
|
63
|
+
require 'ruby_php_serialization/tokenizer'
|
64
|
+
|
65
|
+
---- inner ----
|
66
|
+
|
67
|
+
def parse(string)
|
68
|
+
@tokenizer = Tokenizer.new(string)
|
69
|
+
do_parse
|
70
|
+
return @object
|
71
|
+
ensure
|
72
|
+
@tokenizer = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
def next_token
|
76
|
+
@tokenizer.next_token
|
77
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RubyPhpSerialization
|
2
|
+
class Tokenizer
|
3
|
+
def initialize(string)
|
4
|
+
@string = string
|
5
|
+
end
|
6
|
+
|
7
|
+
def next_token
|
8
|
+
token = nil
|
9
|
+
|
10
|
+
token = case @string
|
11
|
+
when /\A[0-9]+(\.[0-9]+)?/m then [:NUMBER, $&]
|
12
|
+
when /\A"([^"]*)"/m then [:STRING, $1]
|
13
|
+
when /\A[^\s]/m then [$&, $&]
|
14
|
+
end
|
15
|
+
@string = $'
|
16
|
+
|
17
|
+
token unless token.nil?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{ruby-php-serialization}
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Rodrigo Kochenburger"]
|
12
|
+
s.date = %q{2009-09-25}
|
13
|
+
s.description = %q{TODO: longer description of your gem}
|
14
|
+
s.email = %q{divoxx@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"features/ruby_php_serialization.feature",
|
27
|
+
"features/step_definitions/ruby_php_serialization_steps.rb",
|
28
|
+
"features/support/env.rb",
|
29
|
+
"lib/ruby_php_serialization.rb",
|
30
|
+
"lib/ruby_php_serialization/parser.rb",
|
31
|
+
"lib/ruby_php_serialization/parser.y",
|
32
|
+
"lib/ruby_php_serialization/tokenizer.rb",
|
33
|
+
"lib/ruby_php_serialization/unserializer.rb",
|
34
|
+
"ruby-php-serialization.gemspec",
|
35
|
+
"spec/ruby_php_serialization_spec.rb",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/divoxx/ruby-php-serialization}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.4}
|
42
|
+
s.summary = %q{PHP's serialization implemenatation for ruby}
|
43
|
+
s.test_files = [
|
44
|
+
"spec/ruby_php_serialization_spec.rb",
|
45
|
+
"spec/spec_helper.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
54
|
+
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
55
|
+
s.add_development_dependency(%q<racc>, [">= 0"])
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
58
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
59
|
+
s.add_dependency(%q<racc>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
s.add_dependency(%q<cucumber>, [">= 0"])
|
64
|
+
s.add_dependency(%q<racc>, [">= 0"])
|
65
|
+
end
|
66
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: divoxx-ruby-php-serialization
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rodrigo Kochenburger
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-25 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: racc
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: "TODO: longer description of your gem"
|
46
|
+
email: divoxx@gmail.com
|
47
|
+
executables: []
|
48
|
+
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.rdoc
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.rdoc
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- features/ruby_php_serialization.feature
|
62
|
+
- features/step_definitions/ruby_php_serialization_steps.rb
|
63
|
+
- features/support/env.rb
|
64
|
+
- lib/ruby_php_serialization.rb
|
65
|
+
- lib/ruby_php_serialization/parser.rb
|
66
|
+
- lib/ruby_php_serialization/parser.y
|
67
|
+
- lib/ruby_php_serialization/tokenizer.rb
|
68
|
+
- lib/ruby_php_serialization/unserializer.rb
|
69
|
+
- ruby-php-serialization.gemspec
|
70
|
+
- spec/ruby_php_serialization_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
has_rdoc: false
|
73
|
+
homepage: http://github.com/divoxx/ruby-php-serialization
|
74
|
+
licenses:
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --charset=UTF-8
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 1.3.5
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: PHP's serialization implemenatation for ruby
|
99
|
+
test_files:
|
100
|
+
- spec/ruby_php_serialization_spec.rb
|
101
|
+
- spec/spec_helper.rb
|