rom-repository 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.md +28 -0
- data/lib/rom/plugins/relation/key_inference.rb +3 -3
- data/lib/rom/plugins/relation/sql/auto_combine.rb +4 -4
- data/lib/rom/plugins/relation/sql/auto_wrap.rb +4 -4
- data/lib/rom/plugins/relation/sql/base_view.rb +4 -4
- data/lib/rom/plugins/relation/view.rb +8 -4
- data/lib/rom/repository/version.rb +1 -1
- data/rom-repository.gemspec +1 -1
- data/spec/integration/multi_adapter_spec.rb +61 -0
- data/spec/shared/database.rb +2 -1
- data/spec/unit/sql/relation_spec.rb +10 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a0d338b66452b9d5434b08129f04c7ce0a260a
|
4
|
+
data.tar.gz: 98e1038b529b861828284565d6e7fa59f3da5fbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bde95e0e0fda272e1737e6eda953896f8fb5f3ce9a52620bcf41b469ef0f796dd05e11d2f05d6ed1fc1fd81004bb87fe7f2685e1151bc9414735f3d19c9b527
|
7
|
+
data.tar.gz: b1b0a57585cc0cd60dfd3be82fc51e75ccdfacca7d6cdfa580d2216d2fe1358d018e68838a25ed6fa13eb909fbf3544a578ad6e0981d6ebf731440b45cbf0c5d
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
# v0.1.0 2015-08-19
|
2
|
+
|
3
|
+
This release ensures that relations from different adapters can be composed
|
4
|
+
together :tada:
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Plugins are registered correctly for multi-env setups (AMHOL)
|
9
|
+
- multi-block `view` syntax works correctly when header is not provided as options (solnic)
|
10
|
+
|
11
|
+
[Compare v0.0.2...v0.1.0](https://github.com/rom-rb/rom-repository/compare/v0.0.2...v0.1.0)
|
12
|
+
|
13
|
+
# v0.0.2 2015-08-10
|
14
|
+
|
15
|
+
### Added
|
16
|
+
|
17
|
+
- `view` relation plugin (solnic)
|
18
|
+
- `key_inference` relation plugin (solnic)
|
19
|
+
- `base_view` sql relation plugin (solnic)
|
20
|
+
- `auto_combine` sql relation plugin (solnic)
|
21
|
+
- `auto_wrap` sql relation plugin (solnic)
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Switched to extracted `rom-mapper` gem (solnic)
|
26
|
+
|
27
|
+
[Compare v0.0.1...v0.0.2](https://github.com/rom-rb/rom-repository/compare/v0.0.1...v0.0.2)
|
28
|
+
|
1
29
|
# v0.0.1 2015-08-05
|
2
30
|
|
3
31
|
First public release \o/
|
@@ -36,10 +36,10 @@ module ROM
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
41
|
+
ROM.plugins do
|
42
|
+
adapter :sql do
|
43
|
+
register :auto_combine, ROM::Plugins::Relation::SQL::AutoCombine, type: :relation
|
44
44
|
end
|
45
45
|
end
|
@@ -39,10 +39,10 @@ module ROM
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
44
|
+
ROM.plugins do
|
45
|
+
adapter :sql do
|
46
|
+
register :auto_wrap, ROM::Plugins::Relation::SQL::AutoWrap, type: :relation
|
47
47
|
end
|
48
48
|
end
|
@@ -20,10 +20,10 @@ module ROM
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
25
|
+
ROM.plugins do
|
26
|
+
adapter :sql do
|
27
|
+
register :base_view, ROM::Plugins::Relation::SQL::BaseView, type: :relation
|
28
28
|
end
|
29
29
|
end
|
@@ -53,8 +53,12 @@ module ROM
|
|
53
53
|
#
|
54
54
|
# @api public
|
55
55
|
def view(*args, &block)
|
56
|
+
if args.size == 1 && block.arity > 0
|
57
|
+
raise ArgumentError, "header must be set as second argument"
|
58
|
+
end
|
59
|
+
|
56
60
|
name, names, relation_block =
|
57
|
-
if
|
61
|
+
if args.size == 1
|
58
62
|
DSL.new(*args, &block).call
|
59
63
|
else
|
60
64
|
[*args, block]
|
@@ -68,8 +72,8 @@ module ROM
|
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|
75
|
+
end
|
71
76
|
|
72
|
-
|
73
|
-
|
74
|
-
end
|
77
|
+
ROM.plugins do
|
78
|
+
register :view, ROM::Plugins::Relation::View, type: :relation
|
75
79
|
end
|
data/rom-repository.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.license = 'MIT'
|
17
17
|
|
18
18
|
gem.add_runtime_dependency 'anima', '~> 0.2', '>= 0.2'
|
19
|
-
gem.add_runtime_dependency 'rom', '~> 0.9.0
|
19
|
+
gem.add_runtime_dependency 'rom', '~> 0.9', '>= 0.9.0'
|
20
20
|
gem.add_runtime_dependency 'rom-support', '~> 0.1', '>= 0.1.0'
|
21
21
|
gem.add_runtime_dependency 'rom-mapper', '~> 0.2', '>= 0.2.0'
|
22
22
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe 'Repository with multi-adapters setup' do
|
4
|
+
include_context 'database'
|
5
|
+
|
6
|
+
let(:setup) {
|
7
|
+
ROM.setup(default: [:sql, uri], memory: [:memory])
|
8
|
+
}
|
9
|
+
|
10
|
+
let(:users) { rom.relation(:sql_users) }
|
11
|
+
let(:tasks) { rom.relation(:memory_tasks) }
|
12
|
+
|
13
|
+
let(:repo) { Test::Repository.new(rom) }
|
14
|
+
|
15
|
+
before do
|
16
|
+
module Test
|
17
|
+
class Users < ROM::Relation[:sql]
|
18
|
+
dataset :users
|
19
|
+
register_as :sql_users
|
20
|
+
gateway :default
|
21
|
+
end
|
22
|
+
|
23
|
+
class Tasks < ROM::Relation[:memory]
|
24
|
+
dataset :tasks
|
25
|
+
register_as :memory_tasks
|
26
|
+
gateway :memory
|
27
|
+
|
28
|
+
use :view
|
29
|
+
use :key_inference
|
30
|
+
|
31
|
+
view(:base, [:user_id, :title]) do
|
32
|
+
project(:user_id, :title)
|
33
|
+
end
|
34
|
+
|
35
|
+
def for_users(users)
|
36
|
+
restrict(user_id: users.map { |u| u[:id] })
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Repository < ROM::Repository::Base
|
41
|
+
relations :sql_users, :memory_tasks
|
42
|
+
|
43
|
+
def users_with_tasks(id)
|
44
|
+
sql_users.where(id: id).combine_children(many: { tasks: memory_tasks })
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
user_id = setup.gateways[:default].dataset(:users).insert(name: 'Jane')
|
50
|
+
setup.gateways[:memory].dataset(:tasks).insert(user_id: user_id, title: 'Jane Task')
|
51
|
+
end
|
52
|
+
|
53
|
+
specify 'ᕕ⁞ ᵒ̌ 〜 ᵒ̌ ⁞ᕗ' do
|
54
|
+
user = repo.users_with_tasks(users.last[:id]).first
|
55
|
+
|
56
|
+
expect(user.name).to eql('Jane')
|
57
|
+
|
58
|
+
expect(user.tasks[0].user_id).to eql(user.id)
|
59
|
+
expect(user.tasks[0].title).to eql('Jane Task')
|
60
|
+
end
|
61
|
+
end
|
data/spec/shared/database.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
RSpec.shared_context 'database' do
|
2
|
-
let(:setup) { ROM.setup(:sql,
|
2
|
+
let(:setup) { ROM.setup(:sql, uri) }
|
3
3
|
let(:conn) { setup.gateways[:default].connection }
|
4
4
|
let(:rom) { setup.finalize }
|
5
|
+
let(:uri) { 'postgres://localhost/rom_repository' }
|
5
6
|
|
6
7
|
before do
|
7
8
|
[:tags, :tasks, :users].each { |table| conn.drop_table?(table) }
|
@@ -40,5 +40,15 @@ RSpec.describe 'SQL Relation extensions' do
|
|
40
40
|
|
41
41
|
include_context 'valid view'
|
42
42
|
end
|
43
|
+
|
44
|
+
context 'with multi-block when first block has args' do
|
45
|
+
it 'raises error' do
|
46
|
+
expect {
|
47
|
+
setup.relation(:users) do
|
48
|
+
view(:by_id) { |args| }
|
49
|
+
end
|
50
|
+
}.to raise_error(ArgumentError)
|
51
|
+
end
|
52
|
+
end
|
43
53
|
end
|
44
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Solnica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: anima
|
@@ -36,14 +36,20 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.9
|
39
|
+
version: '0.9'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.9.0
|
40
43
|
type: :runtime
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
47
|
- - "~>"
|
45
48
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.9
|
49
|
+
version: '0.9'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.9.0
|
47
53
|
- !ruby/object:Gem::Dependency
|
48
54
|
name: rom-support
|
49
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -145,6 +151,7 @@ files:
|
|
145
151
|
- lib/rom/repository/version.rb
|
146
152
|
- lib/rom/struct.rb
|
147
153
|
- rom-repository.gemspec
|
154
|
+
- spec/integration/multi_adapter_spec.rb
|
148
155
|
- spec/integration/repository_spec.rb
|
149
156
|
- spec/shared/database.rb
|
150
157
|
- spec/shared/relations.rb
|