dm-serializer 0.9.6 → 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  module Serializer
3
- VERSION = "0.9.6"
3
+ VERSION = "0.9.7"
4
4
  end
5
5
  end
data/lib/dm-serializer.rb CHANGED
@@ -55,6 +55,15 @@ module DataMapper
55
55
  end
56
56
  end
57
57
 
58
+ # Note: if you want to include a whole other model via relation, use :methods
59
+ # comments.to_json(:relationships=>{:user=>{:include=>[:first_name],:methods=>[:age]}})
60
+ # add relationships
61
+ (options[:relationships] || {}).each do |rel,opts|
62
+ if self.respond_to?(rel)
63
+ fields << "#{rel.to_json}: #{send(rel).to_json(opts)}"
64
+ end
65
+ end
66
+
58
67
  result << fields.join(', ')
59
68
  result << ' }'
60
69
  result
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.6'
4
+ gem 'dm-core', '~>0.9.7'
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.5'
16
+ gem lib, '~>0.9.7'
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]
@@ -39,7 +39,7 @@ describe DataMapper::Serialize, '#to_xml' do
39
39
 
40
40
  it "should serialize a collection to XML" do
41
41
  @collection.to_xml.should == <<-EOS.compress_lines(false)
42
- <cows type='array'>
42
+ <#{Extlib::Inflection.tableize("Cow")} type='array'>
43
43
  <cow>
44
44
  <id type='integer'>1</id>
45
45
  <composite type='integer'>2</composite>
@@ -52,7 +52,7 @@ describe DataMapper::Serialize, '#to_xml' do
52
52
  <name>Berta</name>
53
53
  <breed>Guernsey</breed>
54
54
  </cow>
55
- </cows>
55
+ </#{Extlib::Inflection.tableize("Cow")}>
56
56
  EOS
57
57
  end
58
58
 
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.6
4
+ version: 0.9.7
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-10-12 00:00:00 -06:00
12
+ date: 2008-11-18 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.6
23
+ version: 0.9.7
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
@@ -30,7 +30,7 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.7.0
33
+ version: 1.8.2
34
34
  version:
35
35
  description: DataMapper plugin for serializing DataMapper objects
36
36
  email:
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements: []
88
88
 
89
89
  rubyforge_project: datamapper
90
- rubygems_version: 1.2.0
90
+ rubygems_version: 1.3.1
91
91
  signing_key:
92
92
  specification_version: 2
93
93
  summary: DataMapper plugin for serializing DataMapper objects