dm-serializer 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/benchmarks/to_xml.rb +1 -1
- data/lib/dm-serializer/to_csv.rb +12 -7
- data/lib/dm-serializer/to_xml.rb +1 -1
- data/lib/dm-serializer/version.rb +1 -1
- data/lib/dm-serializer/xml_serializers/libxml.rb +4 -0
- data/lib/dm-serializer/xml_serializers/nokogiri.rb +4 -0
- data/lib/dm-serializer/xml_serializers/rexml.rb +4 -1
- data/spec/public/to_csv_spec.rb +2 -2
- data/spec/public/to_xml_spec.rb +6 -0
- data/spec/spec_helper.rb +2 -2
- data/tasks/spec.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/benchmarks/to_xml.rb
CHANGED
data/lib/dm-serializer/to_csv.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require 'dm-serializer/common'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
if RUBY_VERSION >= '1.9.0'
|
4
|
+
require 'csv'
|
5
|
+
else
|
6
|
+
begin
|
7
|
+
gem 'fastercsv', '~>1.4.0'
|
8
|
+
require 'fastercsv'
|
9
|
+
CSV = FasterCSV
|
10
|
+
rescue LoadError
|
11
|
+
nil
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
module DataMapper
|
@@ -13,10 +18,10 @@ module DataMapper
|
|
13
18
|
#
|
14
19
|
# @return <String> a CSV representation of the Resource
|
15
20
|
def to_csv(writer = '')
|
16
|
-
|
21
|
+
CSV.generate(writer) do |csv|
|
17
22
|
row = []
|
18
23
|
self.class.properties(repository.name).each do |property|
|
19
|
-
|
24
|
+
row << send(property.name).to_s
|
20
25
|
end
|
21
26
|
csv << row
|
22
27
|
end
|
data/lib/dm-serializer/to_xml.rb
CHANGED
data/spec/public/to_csv_spec.rb
CHANGED
@@ -28,8 +28,8 @@ describe DataMapper::Serialize, '#to_csv' do
|
|
28
28
|
|
29
29
|
it "should serialize a collection to CSV" do
|
30
30
|
result = @collection.to_csv.gsub(/[[:space:]]+\n/, "\n")
|
31
|
-
result.
|
32
|
-
result.
|
31
|
+
result.split("\n")[0].split(',')[0..3].should == ['1','2','Betsy','Jersey']
|
32
|
+
result.split("\n")[1].split(',')[0..3].should == ['10','20','Berta','Guernsey']
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "multiple repositories" do
|
data/spec/public/to_xml_spec.rb
CHANGED
@@ -59,6 +59,12 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
|
59
59
|
|
60
60
|
it_should_behave_like "A serialization method"
|
61
61
|
|
62
|
+
it "should not include the XML prologue, so that the result can be embedded in other XML documents" do
|
63
|
+
planet = Planet.new
|
64
|
+
xml = planet.to_xml(:element_name => "aplanet")
|
65
|
+
xml.starts_with?("<?xml").should == false
|
66
|
+
end
|
67
|
+
|
62
68
|
describe ':element_name option for Resource' do
|
63
69
|
it 'should be used as the root node name by #to_xml' do
|
64
70
|
planet = Planet.new
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'rubygems'
|
3
3
|
|
4
|
-
gem 'dm-core', '~>0.9.
|
4
|
+
gem 'dm-core', '~>0.9.10'
|
5
5
|
require 'dm-core'
|
6
6
|
|
7
7
|
spec_dir_path = Pathname(__FILE__).dirname.expand_path
|
@@ -37,6 +37,6 @@ end
|
|
37
37
|
require spec_dir_path + 'lib/serialization_method_shared_spec'
|
38
38
|
|
39
39
|
# require fixture resources
|
40
|
-
Dir[spec_dir_path + "fixtures/*.rb"].each do |fixture_file|
|
40
|
+
Dir[(spec_dir_path + "fixtures/*.rb").to_s].each do |fixture_file|
|
41
41
|
require fixture_file
|
42
42
|
end
|
data/tasks/spec.rb
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
desc 'Run specifications'
|
9
9
|
Spec::Rake::SpecTask.new(:spec) do |t|
|
10
10
|
t.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
|
11
|
-
t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s)
|
11
|
+
t.spec_files = Pathname.glob((ROOT + 'spec/**/*_spec.rb').to_s).map { |f| f.to_s }
|
12
12
|
|
13
13
|
begin
|
14
14
|
gem 'rcov', '~>0.8'
|
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.10
|
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: 2009-01-
|
12
|
+
date: 2009-01-19 00:00:00 -08: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.10
|
24
24
|
version:
|
25
25
|
description: DataMapper plugin for serializing DataMapper objects
|
26
26
|
email:
|