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.
@@ -1,3 +1,13 @@
1
+ === 0.9.10 / 2009-01-19
2
+
3
+ * 1 minor enhancement:
4
+
5
+ * Don't emit XML prologue when using libxml or nokogiri
6
+
7
+ * 1 bug fix:
8
+
9
+ * libxml and nokogiri no longer output an xml prologue
10
+
1
11
  === 0.9.9 / 2009-01-04
2
12
 
3
13
  * 1 major enhancement:
@@ -1,7 +1,7 @@
1
1
  require "rubygems"
2
2
  require 'pathname'
3
3
 
4
- gem 'dm-core', '~>0.9.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
@@ -1,10 +1,15 @@
1
1
  require 'dm-serializer/common'
2
2
 
3
- begin
4
- gem('fastercsv')
5
- require 'faster_csv'
6
- rescue LoadError
7
- nil
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
- FasterCSV.generate(writer) do |csv|
21
+ CSV.generate(writer) do |csv|
17
22
  row = []
18
23
  self.class.properties(repository.name).each do |property|
19
- row << send(property.name).to_s
24
+ row << send(property.name).to_s
20
25
  end
21
26
  csv << row
22
27
  end
@@ -36,7 +36,7 @@ module DataMapper
36
36
  xml.add_node(root, xml_name, value.to_s) unless value.nil?
37
37
  end
38
38
  end
39
- doc
39
+ xml.output(doc)
40
40
  end
41
41
  end
42
42
 
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Serializer
3
- VERSION = '0.9.9'
3
+ VERSION = '0.9.10'
4
4
  end
5
5
  end
@@ -23,6 +23,10 @@ module DataMapper
23
23
  end
24
24
  parent << node
25
25
  end
26
+
27
+ def self.output(doc)
28
+ doc.root.to_s
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -22,6 +22,10 @@ module DataMapper
22
22
  parent << node
23
23
  node
24
24
  end
25
+
26
+ def self.output(doc)
27
+ doc.root.to_s
28
+ end
25
29
  end
26
30
  end
27
31
  end
@@ -16,8 +16,11 @@ module DataMapper
16
16
  node << ::REXML::Text.new(value.to_s) unless value.nil?
17
17
  node
18
18
  end
19
- end
20
19
 
20
+ def self.output(doc)
21
+ doc.to_s
22
+ end
23
+ end
21
24
  end
22
25
  end
23
26
  end
@@ -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.to_a[0].split(',')[0..3].should == ['1','2','Betsy','Jersey']
32
- result.to_a[1].split(',')[0..3].should == ['10','20','Berta','Guernsey']
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
@@ -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
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
3
 
4
- gem 'dm-core', '~>0.9.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
@@ -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.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-04 00:00:00 -08:00
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.9
23
+ version: 0.9.10
24
24
  version:
25
25
  description: DataMapper plugin for serializing DataMapper objects
26
26
  email: