divoxx-ruby_php_serialization 0.0.0 → 0.1.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/Rakefile CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  gem.summary = %Q{PHP's serialization implemenatation for ruby}
9
9
  gem.description = %Q{TODO: longer description of your gem}
10
10
  gem.email = "divoxx@gmail.com"
11
- gem.homepage = "http://github.com/divoxx/ruby_php_serialization"
11
+ gem.homepage = "http://github.com/divoxx/ruby-php-serialization"
12
12
  gem.authors = ["Rodrigo Kochenburger"]
13
13
  gem.add_development_dependency "rspec"
14
14
  gem.add_development_dependency "cucumber"
@@ -57,7 +57,7 @@ Rake::RDocTask.new do |rdoc|
57
57
  end
58
58
 
59
59
  rdoc.rdoc_dir = 'rdoc'
60
- rdoc.title = "ruby_php_serialization #{version}"
60
+ rdoc.title = "ruby-php-serialization #{version}"
61
61
  rdoc.rdoc_files.include('README*')
62
62
  rdoc.rdoc_files.include('lib/**/*.rb')
63
63
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.1
@@ -0,0 +1,329 @@
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', 59)
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
+ 35, 8, 28, 12, 20, 8, 21, 12, 3, 4,
32
+ 22, 36, 8, 10, 12, 23, 1, 3, 4, 24,
33
+ 25, 8, 10, 12, 17, 1, 3, 4, 27, 19,
34
+ 8, 10, 12, 29, 1, 30, 31, 16, 18, 41,
35
+ 42, 15, 26 ]
36
+
37
+ racc_action_check = [
38
+ 33, 35, 22, 35, 10, 33, 12, 33, 41, 41,
39
+ 15, 33, 41, 41, 41, 16, 41, 0, 0, 17,
40
+ 19, 0, 0, 0, 5, 0, 42, 42, 21, 8,
41
+ 42, 42, 42, 27, 42, 28, 29, 4, 6, 38,
42
+ 40, 1, 20 ]
43
+
44
+ racc_action_pointer = [
45
+ 14, 36, nil, nil, 32, 24, 36, nil, 24, nil,
46
+ -1, nil, 1, nil, nil, 4, 9, 19, nil, 14,
47
+ 36, 22, -3, nil, nil, nil, nil, 28, 23, 26,
48
+ nil, nil, nil, -2, nil, -6, nil, nil, 37, nil,
49
+ 38, 5, 23, nil, nil ]
50
+
51
+ racc_action_default = [
52
+ -21, -21, -7, -8, -21, -21, -21, -2, -21, -3,
53
+ -21, -4, -21, -5, -6, -21, -21, -21, -1, -21,
54
+ -21, -21, -21, -9, 45, -10, -11, -21, -21, -21,
55
+ -13, -12, -16, -21, -20, -21, -14, -15, -21, -19,
56
+ -21, -21, -21, -17, -18 ]
57
+
58
+ racc_goto_table = [
59
+ 6, 39, 38, 39, 40, 34, 33, 34, 32, 37,
60
+ 5, nil, nil, nil, nil, nil, nil, nil, nil, nil,
61
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
62
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
63
+ nil, 43, 44 ]
64
+
65
+ racc_goto_check = [
66
+ 2, 5, 12, 5, 12, 8, 9, 8, 10, 11,
67
+ 1, nil, nil, nil, nil, nil, nil, nil, nil, nil,
68
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
69
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
70
+ nil, 2, 2 ]
71
+
72
+ racc_goto_pointer = [
73
+ nil, 10, 0, nil, nil, -32, nil, nil, -28, -26,
74
+ -22, -24, -31 ]
75
+
76
+ racc_goto_default = [
77
+ nil, nil, nil, 7, 9, 11, 13, 14, 2, nil,
78
+ nil, nil, nil ]
79
+
80
+ racc_reduce_table = [
81
+ 0, 0, :racc_error,
82
+ 2, 15, :_reduce_1,
83
+ 1, 16, :_reduce_2,
84
+ 1, 16, :_reduce_3,
85
+ 1, 16, :_reduce_4,
86
+ 1, 16, :_reduce_5,
87
+ 1, 16, :_reduce_6,
88
+ 1, 16, :_reduce_7,
89
+ 1, 17, :_reduce_8,
90
+ 3, 18, :_reduce_9,
91
+ 3, 19, :_reduce_10,
92
+ 3, 20, :_reduce_11,
93
+ 5, 22, :_reduce_12,
94
+ 0, 24, :_reduce_13,
95
+ 8, 21, :_reduce_14,
96
+ 2, 23, :_reduce_15,
97
+ 0, 23, :_reduce_16,
98
+ 3, 25, :_reduce_17,
99
+ 4, 25, :_reduce_18,
100
+ 1, 26, :_reduce_19,
101
+ 1, 26, :_reduce_20 ]
102
+
103
+ racc_reduce_n = 21
104
+
105
+ racc_shift_n = 45
106
+
107
+ racc_token_table = {
108
+ false => 0,
109
+ :error => 1,
110
+ ";" => 2,
111
+ "N" => 3,
112
+ "b" => 4,
113
+ ":" => 5,
114
+ :NUMBER => 6,
115
+ "i" => 7,
116
+ "d" => 8,
117
+ "s" => 9,
118
+ :STRING => 10,
119
+ "a" => 11,
120
+ "{" => 12,
121
+ "}" => 13 }
122
+
123
+ racc_nt_base = 14
124
+
125
+ racc_use_result_var = true
126
+
127
+ Racc_arg = [
128
+ racc_action_table,
129
+ racc_action_check,
130
+ racc_action_default,
131
+ racc_action_pointer,
132
+ racc_goto_table,
133
+ racc_goto_check,
134
+ racc_goto_default,
135
+ racc_goto_pointer,
136
+ racc_nt_base,
137
+ racc_reduce_table,
138
+ racc_token_table,
139
+ racc_shift_n,
140
+ racc_reduce_n,
141
+ racc_use_result_var ]
142
+
143
+ Racc_token_to_s_table = [
144
+ "$end",
145
+ "error",
146
+ "\";\"",
147
+ "\"N\"",
148
+ "\"b\"",
149
+ "\":\"",
150
+ "NUMBER",
151
+ "\"i\"",
152
+ "\"d\"",
153
+ "\"s\"",
154
+ "STRING",
155
+ "\"a\"",
156
+ "\"{\"",
157
+ "\"}\"",
158
+ "$start",
159
+ "serialization",
160
+ "object",
161
+ "null",
162
+ "bool",
163
+ "integer",
164
+ "double",
165
+ "array",
166
+ "string",
167
+ "array_items",
168
+ "@1",
169
+ "array_item",
170
+ "array_key" ]
171
+
172
+ Racc_debug_parser = false
173
+
174
+ ##### State transition tables end #####
175
+
176
+ # reduce 0 omitted
177
+
178
+ module_eval(<<'.,.,', 'parser.y', 3)
179
+ def _reduce_1(val, _values, result)
180
+ @object = val[0]
181
+ result
182
+ end
183
+ .,.,
184
+
185
+ module_eval(<<'.,.,', 'parser.y', 6)
186
+ def _reduce_2(val, _values, result)
187
+ result = val[0]
188
+ result
189
+ end
190
+ .,.,
191
+
192
+ module_eval(<<'.,.,', 'parser.y', 7)
193
+ def _reduce_3(val, _values, result)
194
+ result = val[0]
195
+ result
196
+ end
197
+ .,.,
198
+
199
+ module_eval(<<'.,.,', 'parser.y', 8)
200
+ def _reduce_4(val, _values, result)
201
+ result = val[0]
202
+ result
203
+ end
204
+ .,.,
205
+
206
+ module_eval(<<'.,.,', 'parser.y', 9)
207
+ def _reduce_5(val, _values, result)
208
+ result = val[0]
209
+ result
210
+ end
211
+ .,.,
212
+
213
+ module_eval(<<'.,.,', 'parser.y', 10)
214
+ def _reduce_6(val, _values, result)
215
+ result = val[0]
216
+ result
217
+ end
218
+ .,.,
219
+
220
+ module_eval(<<'.,.,', 'parser.y', 11)
221
+ def _reduce_7(val, _values, result)
222
+ result = val[0]
223
+ result
224
+ end
225
+ .,.,
226
+
227
+ module_eval(<<'.,.,', 'parser.y', 14)
228
+ def _reduce_8(val, _values, result)
229
+ result = nil
230
+ result
231
+ end
232
+ .,.,
233
+
234
+ module_eval(<<'.,.,', 'parser.y', 17)
235
+ def _reduce_9(val, _values, result)
236
+ result = Integer(val[2]) > 0
237
+ result
238
+ end
239
+ .,.,
240
+
241
+ module_eval(<<'.,.,', 'parser.y', 20)
242
+ def _reduce_10(val, _values, result)
243
+ result = Integer(val[2])
244
+ result
245
+ end
246
+ .,.,
247
+
248
+ module_eval(<<'.,.,', 'parser.y', 23)
249
+ def _reduce_11(val, _values, result)
250
+ result = Float(val[2])
251
+ result
252
+ end
253
+ .,.,
254
+
255
+ module_eval(<<'.,.,', 'parser.y', 26)
256
+ def _reduce_12(val, _values, result)
257
+ result = val[4]
258
+ result
259
+ end
260
+ .,.,
261
+
262
+ module_eval(<<'.,.,', 'parser.y', 29)
263
+ def _reduce_13(val, _values, result)
264
+ @numeric_array = true
265
+ result
266
+ end
267
+ .,.,
268
+
269
+ module_eval(<<'.,.,', 'parser.y', 31)
270
+ def _reduce_14(val, _values, result)
271
+ if @numeric_array
272
+ result = []
273
+ val[6].each { |(i,v)| result[i] = v }
274
+ else
275
+ result = Hash[*val[6].flatten]
276
+ end
277
+
278
+ result
279
+ end
280
+ .,.,
281
+
282
+ module_eval(<<'.,.,', 'parser.y', 40)
283
+ def _reduce_15(val, _values, result)
284
+ result = val[0] << val[1]
285
+ result
286
+ end
287
+ .,.,
288
+
289
+ module_eval(<<'.,.,', 'parser.y', 41)
290
+ def _reduce_16(val, _values, result)
291
+ result = []
292
+ result
293
+ end
294
+ .,.,
295
+
296
+ module_eval(<<'.,.,', 'parser.y', 44)
297
+ def _reduce_17(val, _values, result)
298
+ result = [val[0], val[2]]
299
+ result
300
+ end
301
+ .,.,
302
+
303
+ module_eval(<<'.,.,', 'parser.y', 45)
304
+ def _reduce_18(val, _values, result)
305
+ result = [val[1], val[3]]
306
+ result
307
+ end
308
+ .,.,
309
+
310
+ module_eval(<<'.,.,', 'parser.y', 48)
311
+ def _reduce_19(val, _values, result)
312
+ result = val[0]
313
+ result
314
+ end
315
+ .,.,
316
+
317
+ module_eval(<<'.,.,', 'parser.y', 49)
318
+ def _reduce_20(val, _values, result)
319
+ @numeric_array = false; result = val[0]
320
+ result
321
+ end
322
+ .,.,
323
+
324
+ def _reduce_none(val, _values, result)
325
+ val[0]
326
+ end
327
+
328
+ end # class Parser
329
+ end # module RubyPhpSerialization
@@ -0,0 +1,70 @@
1
+ class RubyPhpSerialization::Parser
2
+ rule
3
+
4
+ serialization : object ';' { @object = val[0] }
5
+ ;
6
+
7
+ object : 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
+ ;
14
+
15
+ null : 'N' { result = nil }
16
+ ;
17
+
18
+ bool : 'b' ':' NUMBER { result = Integer(val[2]) > 0 }
19
+ ;
20
+
21
+ integer : 'i' ':' NUMBER { result = Integer(val[2]) }
22
+ ;
23
+
24
+ double : 'd' ':' NUMBER { result = Float(val[2]) }
25
+ ;
26
+
27
+ string : 's' ':' NUMBER ':' STRING { result = val[4] }
28
+ ;
29
+
30
+ array : 'a' ':' NUMBER ':' '{' { @numeric_array = true } array_items '}'
31
+ {
32
+ if @numeric_array
33
+ result = []
34
+ val[6].each { |(i,v)| result[i] = v }
35
+ else
36
+ result = Hash[*val[6].flatten]
37
+ end
38
+ }
39
+ ;
40
+
41
+ array_items : array_items array_item { result = val[0] << val[1] }
42
+ | { result = [] }
43
+ ;
44
+
45
+ array_item : array_key ';' object { result = [val[0], val[2]] }
46
+ | ';' array_key ';' object { result = [val[1], val[3]] }
47
+ ;
48
+
49
+ array_key : integer { result = val[0] }
50
+ | string { @numeric_array = false; result = val[0] }
51
+ ;
52
+
53
+ end
54
+
55
+ ---- header ----
56
+ require 'ruby_php_serialization/tokenizer'
57
+
58
+ ---- inner ----
59
+
60
+ def parse(string)
61
+ @tokenizer = Tokenizer.new(string)
62
+ do_parse
63
+ return @object
64
+ ensure
65
+ @tokenizer = nil
66
+ end
67
+
68
+ def next_token
69
+ @tokenizer.next_token
70
+ 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,4 @@
1
+ module RubyPhpSerialization
2
+ class Unserializer
3
+ end
4
+ 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.1.1"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: divoxx-ruby_php_serialization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Kochenburger
@@ -62,10 +62,15 @@ files:
62
62
  - features/step_definitions/ruby_php_serialization_steps.rb
63
63
  - features/support/env.rb
64
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
65
70
  - spec/ruby_php_serialization_spec.rb
66
71
  - spec/spec_helper.rb
67
72
  has_rdoc: false
68
- homepage: http://github.com/divoxx/ruby_php_serialization
73
+ homepage: http://github.com/divoxx/ruby-php-serialization
69
74
  licenses:
70
75
  post_install_message:
71
76
  rdoc_options: