php-serialization 0.5.3 → 1.0.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -5
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/{LICENSE → LICENSE.txt} +3 -1
- data/README.md +31 -0
- data/Rakefile +5 -67
- data/bin/racc +16 -0
- data/bin/racc2y +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/y2racc +16 -0
- data/lib/php_serialization/serializer.rb +7 -7
- data/lib/php_serialization/tokenizer.rb +5 -5
- data/lib/php_serialization/unserializer.output +503 -0
- data/lib/php_serialization/unserializer.rb +67 -64
- data/lib/php_serialization/unserializer.y +39 -27
- data/lib/php_serialization/version.rb +3 -0
- data/ruby-php-serialization.gemspec +26 -0
- data/spec/functional/session_serialization_spec.rb +23 -0
- data/spec/unit/serializer_spec.rb +49 -0
- data/spec/unit/unserializer_spec.rb +67 -0
- metadata +100 -81
- data/.document +0 -5
- data/README.rdoc +0 -72
- data/VERSION +0 -1
- data/features/ruby_php_serialization.feature +0 -9
- data/features/step_definitions/ruby_php_serialization_steps.rb +0 -0
- data/features/support/env.rb +0 -4
- data/php-serialization.gemspec +0 -72
- data/spec/serialization_spec.rb +0 -49
- data/spec/session_serialization_spec.rb +0 -21
- data/spec/spec.opts +0 -3
- data/spec/spec_helper.rb +0 -9
- data/spec/unserialization_spec.rb +0 -51
data/spec/serialization_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe "Serialization" do
|
4
|
-
it "should serialize a integer" do
|
5
|
-
PhpSerialization.dump(10).should == "i:10;"
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should serialize a string" do
|
9
|
-
PhpSerialization.dump("Name").should == 's:4:"Name";'
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should serialize a symbol string" do
|
13
|
-
PhpSerialization.dump(:name).should == 's:4:"name";'
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should serialize true" do
|
17
|
-
PhpSerialization.dump(true).should == 'b:1;'
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should serialize false" do
|
21
|
-
PhpSerialization.dump(false).should == 'b:0;'
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should serialize nil" do
|
25
|
-
PhpSerialization.dump(nil).should == 'N;'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should unzerialize an array" do
|
29
|
-
PhpSerialization.dump([true, "foo"]).should == 'a:2:{i:0;b:1;i:1;s:3:"foo";}'
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should serialize a hash" do
|
33
|
-
PhpSerialization.dump("name" => "Rodrigo", "age" => 23).should == 'a:2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}'
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should serialize object with class existant" do
|
37
|
-
class Person
|
38
|
-
attr_accessor :name, :age
|
39
|
-
end
|
40
|
-
|
41
|
-
person = Person.new
|
42
|
-
person.name = "Rodrigo"
|
43
|
-
person.age = 23
|
44
|
-
|
45
|
-
PhpSerialization.dump(person).should == 'O:6:"Person":2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}'
|
46
|
-
|
47
|
-
Object.send(:remove_const, :Person)
|
48
|
-
end
|
49
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe "Session serialization" do
|
4
|
-
it "should store session correctly" do
|
5
|
-
PhpSessionSerialization.load("userId|i:123;store|s:3:\"foo\";someArr|a:2:{i:0;b:1;i:1;s:3:\"foo\";}").should == {
|
6
|
-
"userId" => 123,
|
7
|
-
"store" => "foo",
|
8
|
-
"someArr" => [true, "foo"]
|
9
|
-
}
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should dump a hash as session" do
|
13
|
-
session_hash = {
|
14
|
-
"userId" => 123,
|
15
|
-
"store" => "foo",
|
16
|
-
"someArr" => [true, "foo"]
|
17
|
-
}
|
18
|
-
|
19
|
-
PhpSessionSerialization.load(PhpSessionSerialization.dump(session_hash)).should == session_hash
|
20
|
-
end
|
21
|
-
end
|
data/spec/spec.opts
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe "Unserialization" do
|
4
|
-
it "should unserialize a integer" do
|
5
|
-
PhpSerialization.load("i:10;").should == 10
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should unserialize a string" do
|
9
|
-
PhpSerialization.load('s:4:"Name";').should == "Name"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should unserialize true" do
|
13
|
-
PhpSerialization.load('b:1;').should == true
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should unserialize false" do
|
17
|
-
PhpSerialization.load('b:0;').should == false
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should unserialize nil" do
|
21
|
-
PhpSerialization.load('N;').should == nil
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should unzerialize an array" do
|
25
|
-
PhpSerialization.load('a:2:{i:0;b:1;i:1;s:3:"foo";}').should == [true, "foo"]
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should unserialize a hash" do
|
29
|
-
PhpSerialization.load('a:2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}').should == {"name" => "Rodrigo", "age" => 23}
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should unserialize object with class existant" do
|
33
|
-
class Person
|
34
|
-
attr_accessor :name, :age, :gender
|
35
|
-
end
|
36
|
-
|
37
|
-
person = PhpSerialization.load('O:6:"Person":2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}')
|
38
|
-
person.should be_instance_of(Person)
|
39
|
-
person.name.should == "Rodrigo"
|
40
|
-
person.age.should == 23
|
41
|
-
|
42
|
-
Object.send(:remove_const, :Person)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should unserialize object without class as a struct" do
|
46
|
-
person = PhpSerialization.load('O:6:"Person":2:{s:4:"name";s:7:"Rodrigo";s:3:"age";i:23;}')
|
47
|
-
person.should be_instance_of(Struct::Person)
|
48
|
-
person.name.should == "Rodrigo"
|
49
|
-
person.age.should == 23
|
50
|
-
end
|
51
|
-
end
|