data_broker 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab94b51d25a3a4822f72e55571c65a91093a59db
4
- data.tar.gz: 8b934b53c08ca0ef7679fd34cb7863edf425032f
3
+ metadata.gz: 1872c24738cee2ffe0e8a2101e672798e3fd0d5a
4
+ data.tar.gz: cd0c646fa0a378528374e2c2185da8fe69587074
5
5
  SHA512:
6
- metadata.gz: 57adee8f7db28230cf4b9b1b3f8e7b49e6f2c5a4ea1a7cdb52799db9b12a8651c09fee1b33002008728ff2553265423ddf760e8906697e632c560828ab6f7b84
7
- data.tar.gz: 3b67351d428611e9902165b78317023dd1c8c6aab6ccce3cc0efbdfb430eb7cdd8eb8127aa3109878e1e986b0600a71d41b71ac61244606a4ffbfa3fc30c6426
6
+ metadata.gz: 8f20b1812566f0eee7e142317e6b9eafc0a9f277ee5a31129f1acefb9d51fb3f1d77cd19e598c54054d5b874fb1984f0e2e528eae224b0af21a7b7287c99ae58
7
+ data.tar.gz: f90d3d182c4b7ffb0aa0249cbaf4cf6546fe206a25041cfda58a37c11335dcc23049221f82c46fc8384af6aa36b70b0bd9724adb28d8680028bfbce9a9b34562
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # DataBroker
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/data_broker.png)](http://badge.fury.io/rb/data_broker)
3
4
  [![Semaphore](https://semaphoreapp.com/api/v1/projects/20b511c80e766c8d5d897140b7f7d87df8e4da9b/118941/shields_badge.png)](https://semaphoreapp.com/minter/data_broker)
4
5
  [![Code Climate](https://codeclimate.com/github/teamsnap/data_broker.png)](https://codeclimate.com/github/teamsnap/data_broker)
5
6
  [![Coverage Status](https://coveralls.io/repos/teamsnap/data_broker/badge.png?branch=master)](https://coveralls.io/r/teamsnap/data_broker?branch=master)
@@ -43,7 +44,7 @@ View specs for sample usage.
43
44
 
44
45
  ## Contributing
45
46
 
46
- 1. Fork it
47
+ 1. Fork it ( http://github.com/teamsnap/data_broker/fork )
47
48
  2. Create your feature branch (`git checkout -b my-new-feature`)
48
49
  3. Commit your changes (`git commit -am 'Add some feature'`)
49
50
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/data_broker.rb CHANGED
@@ -1,21 +1,3 @@
1
1
  require_relative "data_broker/mapper"
2
2
  require_relative "data_broker/value_object"
3
3
  require_relative "data_broker/version"
4
-
5
- module DataBroker
6
- def self.mapper
7
- Module.new do
8
- def self.included(descendant)
9
- descendant.send(:include, ::DataBroker::Mapper)
10
- end
11
- end
12
- end
13
-
14
- def self.value_object
15
- Module.new do
16
- def self.included(descendant)
17
- descendant.send(:include, ::DataBroker::ValueObject)
18
- end
19
- end
20
- end
21
- end
@@ -1,6 +1,14 @@
1
1
  require "active_record"
2
2
 
3
3
  module DataBroker
4
+ def self.mapper
5
+ Module.new do
6
+ def self.included(descendant)
7
+ descendant.send(:include, ::DataBroker::Mapper)
8
+ end
9
+ end
10
+ end
11
+
4
12
  module Mapper
5
13
  def self.included(descendant)
6
14
  super
@@ -3,6 +3,14 @@ require "active_support/inflector"
3
3
  require "active_support/core_ext/object/try"
4
4
 
5
5
  module DataBroker
6
+ def self.value_object
7
+ Module.new do
8
+ def self.included(descendant)
9
+ descendant.send(:include, ::DataBroker::ValueObject)
10
+ end
11
+ end
12
+ end
13
+
6
14
  module ValueObject
7
15
  def self.included(descendant)
8
16
  descendant.send(:include, Virtus.value_object)
@@ -1,3 +1,3 @@
1
1
  module DataBroker
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/mapper_spec.rb CHANGED
@@ -111,7 +111,7 @@ describe DataBroker::Mapper do
111
111
  expect(obj).to be_nil
112
112
  end
113
113
 
114
- it "eager loads relations" do
114
+ it "eager loads has_many relations" do
115
115
  parent_id = parent_mapper.record.create.id
116
116
  id = mapper.record.create(:parent_id => parent_id)
117
117
  obj = mapper.find(id)
@@ -119,6 +119,15 @@ describe DataBroker::Mapper do
119
119
  parent = obj.instance_variable_get(:@parent)
120
120
  expect(parent).to eq(parent_mapper.find(parent_id))
121
121
  end
122
+
123
+ it "eager loads belongs_to relations" do
124
+ parent_id = parent_mapper.record.create.id
125
+ id = mapper.record.create(:child_name => "Bobby", :parent_id => parent_id)
126
+ obj = parent_mapper.find(parent_id)
127
+
128
+ child = obj.instance_variable_get(:@children).first
129
+ expect(child).to eq(mapper.find(id))
130
+ end
122
131
  end
123
132
 
124
133
  describe "#where" do
@@ -164,6 +173,15 @@ describe DataBroker::Mapper do
164
173
  parent = obj.instance_variable_get(:@parent)
165
174
  expect(parent).to eq(parent_mapper.find(parent_id))
166
175
  end
176
+
177
+ it "eager loads belongs_to relations" do
178
+ parent_id = parent_mapper.record.create.id
179
+ id = mapper.record.create(:child_name => "Bobby", :parent_id => parent_id)
180
+ obj = parent_mapper.where(:id => parent_id).first
181
+
182
+ child = obj.instance_variable_get(:@children).first
183
+ expect(child).to eq(mapper.find(id))
184
+ end
167
185
  end
168
186
 
169
187
  describe "#save" do
metadata CHANGED
@@ -1,125 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_broker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Emmons
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-22 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: virtus
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activerecord
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 3.0.0.beta1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.0.0.beta1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sqlite3
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '1.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: database_cleaner
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '1.2'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.2'
125
125
  description: A simplified implementation of the data mapper pattern
@@ -129,7 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
- - .gitignore
132
+ - ".gitignore"
133
133
  - Gemfile
134
134
  - LICENSE.txt
135
135
  - README.md
@@ -152,17 +152,17 @@ require_paths:
152
152
  - lib
153
153
  required_ruby_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
- - - '>='
155
+ - - ">="
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
- - - '>='
160
+ - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.0.14
165
+ rubygems_version: 2.2.0
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: A simplified implementation of the data mapper pattern