dm-serializer 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dm-serializer.rb +4 -4
- data/lib/dm-serializer/version.rb +2 -2
- data/spec/fixtures/cow.rb +1 -1
- data/spec/fixtures/quatum_cat.rb +5 -5
- data/spec/spec_helper.rb +2 -2
- data/spec/unit/to_csv_spec.rb +2 -2
- data/spec/unit/to_json_spec.rb +3 -3
- data/spec/unit/to_xml_spec.rb +4 -4
- data/spec/unit/to_yaml_spec.rb +2 -2
- metadata +3 -3
data/lib/dm-serializer.rb
CHANGED
@@ -35,7 +35,7 @@ module DataMapper
|
|
35
35
|
fields += propset.map do |property|
|
36
36
|
"#{property.name.to_json}: #{send(property.getter).to_json}"
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
if self.respond_to?(:serialize_properties)
|
40
40
|
self.serialize_properties.each do |k,v|
|
41
41
|
fields << "#{k.to_json}: #{v.to_json}"
|
@@ -77,7 +77,7 @@ module DataMapper
|
|
77
77
|
#
|
78
78
|
# @return <REXML::Document> an XML representation of this Resource
|
79
79
|
def to_xml(opts = {})
|
80
|
-
|
80
|
+
|
81
81
|
to_xml_document(opts).to_s
|
82
82
|
end
|
83
83
|
|
@@ -154,12 +154,12 @@ module DataMapper
|
|
154
154
|
end
|
155
155
|
result
|
156
156
|
end
|
157
|
-
|
157
|
+
|
158
158
|
protected
|
159
159
|
def xml_element_name
|
160
160
|
Extlib::Inflection.tableize(self.model.to_s)
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
def to_xml_document(opts={})
|
164
164
|
doc = REXML::Document.new
|
165
165
|
root = doc.add_element(xml_element_name)
|
data/spec/fixtures/cow.rb
CHANGED
data/spec/fixtures/quatum_cat.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'pathname'
|
3
3
|
|
4
|
-
gem 'dm-core', '=0.9.
|
4
|
+
gem 'dm-core', '=0.9.4'
|
5
5
|
require 'dm-core'
|
6
6
|
|
7
7
|
spec_dir_path = Pathname(__FILE__).dirname.expand_path
|
@@ -13,7 +13,7 @@ def load_driver(name, default_uri)
|
|
13
13
|
lib = "do_#{name}"
|
14
14
|
|
15
15
|
begin
|
16
|
-
gem lib, '=0.9.
|
16
|
+
gem lib, '=0.9.4'
|
17
17
|
require lib
|
18
18
|
DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
|
19
19
|
DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
|
data/spec/unit/to_csv_spec.rb
CHANGED
@@ -31,13 +31,13 @@ describe DataMapper::Serialize, '#to_csv' do
|
|
31
31
|
"1,2,Betsy,Jersey\n" +
|
32
32
|
"10,20,Berta,Guernsey\n"
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
describe "multiple repositories" do
|
36
36
|
before(:all) do
|
37
37
|
QuantumCat.auto_migrate!
|
38
38
|
repository(:alternate){QuantumCat.auto_migrate!}
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
it "should use the repsoitory for the model" do
|
42
42
|
gerry = QuantumCat.create(:name => "gerry")
|
43
43
|
george = repository(:alternate){QuantumCat.create(:name => "george", :is_dead => false)}
|
data/spec/unit/to_json_spec.rb
CHANGED
@@ -106,13 +106,13 @@ describe DataMapper::Serialize, '#to_json' do
|
|
106
106
|
deserialized_hash["name"].should be(nil)
|
107
107
|
deserialized_hash["aphelion"].should == 249_209_300.4
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
110
|
describe "multiple repositories" do
|
111
111
|
before(:all) do
|
112
112
|
QuantumCat.auto_migrate!
|
113
113
|
repository(:alternate){QuantumCat.auto_migrate!}
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
it "should use the repsoitory for the model" do
|
117
117
|
gerry = QuantumCat.create(:name => "gerry")
|
118
118
|
george = repository(:alternate){QuantumCat.create(:name => "george", :is_dead => false)}
|
@@ -120,7 +120,7 @@ describe DataMapper::Serialize, '#to_json' do
|
|
120
120
|
george.to_json.should match(/is_dead/)
|
121
121
|
end
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
it "supports :include option for one level depth"
|
125
125
|
|
126
126
|
it "supports :include option for more than one level depth"
|
data/spec/unit/to_xml_spec.rb
CHANGED
@@ -8,9 +8,9 @@ describe DataMapper::Serialize, '#to_xml' do
|
|
8
8
|
|
9
9
|
before(:all) do
|
10
10
|
query = DataMapper::Query.new(DataMapper::repository(:default), Cow)
|
11
|
-
|
11
|
+
|
12
12
|
@time = DateTime.now
|
13
|
-
|
13
|
+
|
14
14
|
|
15
15
|
@collection = DataMapper::Collection.new(query) do |c|
|
16
16
|
c.load([1, 2, 'Betsy', 'Jersey'])
|
@@ -55,13 +55,13 @@ describe DataMapper::Serialize, '#to_xml' do
|
|
55
55
|
</cows>
|
56
56
|
EOS
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
describe "multiple repositories" do
|
60
60
|
before(:all) do
|
61
61
|
QuantumCat.auto_migrate!
|
62
62
|
repository(:alternate){QuantumCat.auto_migrate!}
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
it "should use the repsoitory for the model" do
|
66
66
|
gerry = QuantumCat.create(:name => "gerry")
|
67
67
|
george = repository(:alternate){QuantumCat.create(:name => "george", :is_dead => false)}
|
data/spec/unit/to_yaml_spec.rb
CHANGED
@@ -58,13 +58,13 @@ describe DataMapper::Serialize, '#to_yaml' do
|
|
58
58
|
it "handles empty collections just fine" do
|
59
59
|
YAML.load(@empty_collection.to_yaml).should be_empty
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
describe "multiple repositories" do
|
63
63
|
before(:all) do
|
64
64
|
QuantumCat.auto_migrate!
|
65
65
|
repository(:alternate){QuantumCat.auto_migrate!}
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should use the repsoitory for the model" do
|
69
69
|
gerry = QuantumCat.create(:name => "gerry")
|
70
70
|
george = repository(:alternate){QuantumCat.create(:name => "george", :is_dead => false)}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guy van den Berg
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.4
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|