rom-yesql 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/rom/yesql.rb +1 -1
- data/lib/rom/yesql/{repository.rb → gateway.rb} +6 -6
- data/lib/rom/yesql/relation.rb +4 -4
- data/lib/rom/yesql/version.rb +1 -1
- data/rom-yesql.gemspec +2 -2
- data/spec/shared/database_setup.rb +1 -1
- data/spec/shared/repository_setup.rb +1 -1
- data/spec/unit/rom/yesql/repository_spec.rb +12 -12
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daa257e05ad1e1c71faffc2ed1938d3a7a3eab74
|
4
|
+
data.tar.gz: 1a8665a1a99a4ce7c54afdeed0ccd0cc2b320a2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7348d1f700e7531b77d8e565a20f0fced2a6371b6ccb928cb9d734f8d9f5a63e28ab43d373f5a51e524186ca1d3a82b8a54614231565d3fb3f7370c5cea15ca4
|
7
|
+
data.tar.gz: 6d347bb100e00ea7c8b14c6272c6914a43ddeba156a9aceda4dfeadf628c7b5faff361b067873459a1b81011bd0ce8d3aa750c2bc64aaa50511ec44003b4397e
|
data/CHANGELOG.md
CHANGED
data/lib/rom/yesql.rb
CHANGED
@@ -5,31 +5,31 @@ require 'rom/yesql/relation'
|
|
5
5
|
|
6
6
|
module ROM
|
7
7
|
module Yesql
|
8
|
-
# Yesql
|
8
|
+
# Yesql gateway exposes access to configured SQL queries
|
9
9
|
#
|
10
10
|
# @example
|
11
11
|
# # Load all queries from a specific path
|
12
|
-
# ROM::Yesql::
|
12
|
+
# ROM::Yesql::Gateway.new(uri, path: '/path/to/my_queries')
|
13
13
|
#
|
14
14
|
# # Provide queries explicitly using a hash
|
15
|
-
# ROM::Yesql::
|
15
|
+
# ROM::Yesql::Gateway.new(uri, queries: {
|
16
16
|
# reports: {
|
17
17
|
# all_users: 'SELECT * FROM users'
|
18
18
|
# }
|
19
19
|
# })
|
20
20
|
#
|
21
21
|
# # Override default query proc handler
|
22
|
-
# ROM::Yesql::
|
22
|
+
# ROM::Yesql::Gateway.new(uri, query_proc: proc { |name, query, *args|
|
23
23
|
# # do something to return an sql string
|
24
24
|
# })
|
25
25
|
#
|
26
26
|
# @api public
|
27
|
-
class
|
27
|
+
class Gateway < ROM::Gateway
|
28
28
|
include Options
|
29
29
|
|
30
30
|
option :path, reader: true
|
31
31
|
option :queries, type: Hash, default: EMPTY_HASH
|
32
|
-
option :query_proc, reader: true, default: proc { |
|
32
|
+
option :query_proc, reader: true, default: proc { |gateway|
|
33
33
|
proc do |_name, query, opts|
|
34
34
|
query % opts
|
35
35
|
end
|
data/lib/rom/yesql/relation.rb
CHANGED
@@ -6,7 +6,7 @@ module ROM
|
|
6
6
|
# Yesql relation subclass
|
7
7
|
#
|
8
8
|
# Class that inherits from this relation will be extended with methods
|
9
|
-
# based on its
|
9
|
+
# based on its gateway queries hash
|
10
10
|
#
|
11
11
|
# It also supports overriding query_proc
|
12
12
|
#
|
@@ -60,7 +60,7 @@ module ROM
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
# All loaded queries provided by
|
63
|
+
# All loaded queries provided by gateway
|
64
64
|
#
|
65
65
|
# @return [Hash]
|
66
66
|
#
|
@@ -69,7 +69,7 @@ module ROM
|
|
69
69
|
@queries || {}
|
70
70
|
end
|
71
71
|
|
72
|
-
# Hook called by a
|
72
|
+
# Hook called by a gateway to load all configured queries
|
73
73
|
#
|
74
74
|
# @param [Hash] queries A hash with queries
|
75
75
|
#
|
@@ -86,7 +86,7 @@ module ROM
|
|
86
86
|
|
87
87
|
# Return query proc set on a relation class
|
88
88
|
#
|
89
|
-
# By default this returns whatever was set in the
|
89
|
+
# By default this returns whatever was set in the gateway or the default
|
90
90
|
# one which simply uses hash % query to evaluate a query string
|
91
91
|
#
|
92
92
|
# @return [Proc]
|
data/lib/rom/yesql/version.rb
CHANGED
data/rom-yesql.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ROM::Yesql::VERSION.dup
|
9
9
|
spec.authors = ["Piotr Solnica"]
|
10
10
|
spec.email = ["piotr.solnica@gmail.com"]
|
11
|
-
spec.summary = 'Yesql
|
11
|
+
spec.summary = 'Yesql adapter for ROM'
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "http://rom-rb.org"
|
14
14
|
spec.license = "MIT"
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'rom', '~> 0.
|
21
|
+
spec.add_runtime_dependency 'rom', '~> 0.8', '>= 0.8.0'
|
22
22
|
spec.add_runtime_dependency 'sequel', '~> 4.19.0'
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -1,38 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe ROM::Yesql::
|
4
|
-
include_context '
|
3
|
+
describe ROM::Yesql::Gateway do
|
4
|
+
include_context 'gateway setup'
|
5
5
|
|
6
6
|
it 'loads queries from file system when :path is provided' do
|
7
|
-
|
7
|
+
gateway = ROM::Yesql::Gateway.new(uri, path: path)
|
8
8
|
|
9
|
-
expect(
|
9
|
+
expect(gateway.queries.keys).to match_array([:users, :tasks])
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'combines queries from :queries option and loaded from provided :path' do
|
13
13
|
queries = { reports: { true: 'SELECT 1' } }
|
14
|
-
|
14
|
+
gateway = ROM::Yesql::Gateway.new(uri, path: path, queries: queries)
|
15
15
|
|
16
|
-
expect(
|
16
|
+
expect(gateway.queries.keys).to match_array([:users, :tasks, :reports])
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'loads queries from :queries option' do
|
20
20
|
queries = { reports: { true: 'SELECT 1' } }
|
21
|
-
|
21
|
+
gateway = ROM::Yesql::Gateway.new(uri, queries: queries)
|
22
22
|
|
23
|
-
expect(
|
23
|
+
expect(gateway.queries).to eql(queries)
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'loads empty queries hash when no options were provided' do
|
27
|
-
|
27
|
+
gateway = ROM::Yesql::Gateway.new(uri)
|
28
28
|
|
29
|
-
expect(
|
29
|
+
expect(gateway.queries).to eql({})
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'freezes queries' do
|
33
33
|
queries = { reports: { true: 'SELECT 1' } }
|
34
|
-
|
34
|
+
gateway = ROM::Yesql::Gateway.new(uri, queries: queries)
|
35
35
|
|
36
|
-
expect(
|
36
|
+
expect(gateway.queries).to be_frozen
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rom-yesql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
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-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -16,14 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.8'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.8.0
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
29
|
+
version: '0.8'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.0
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: sequel
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +72,7 @@ dependencies:
|
|
66
72
|
- - "~>"
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '10.0'
|
69
|
-
description: Yesql
|
75
|
+
description: Yesql adapter for ROM
|
70
76
|
email:
|
71
77
|
- piotr.solnica@gmail.com
|
72
78
|
executables: []
|
@@ -88,9 +94,9 @@ files:
|
|
88
94
|
- lib/rom-yesql.rb
|
89
95
|
- lib/rom/yesql.rb
|
90
96
|
- lib/rom/yesql/dataset.rb
|
97
|
+
- lib/rom/yesql/gateway.rb
|
91
98
|
- lib/rom/yesql/relation.rb
|
92
99
|
- lib/rom/yesql/relation/class_interface.rb
|
93
|
-
- lib/rom/yesql/repository.rb
|
94
100
|
- lib/rom/yesql/version.rb
|
95
101
|
- log/.gitkeep
|
96
102
|
- rakelib/rubocop.rake
|
@@ -126,7 +132,7 @@ rubyforge_project:
|
|
126
132
|
rubygems_version: 2.4.5
|
127
133
|
signing_key:
|
128
134
|
specification_version: 4
|
129
|
-
summary: Yesql
|
135
|
+
summary: Yesql adapter for ROM
|
130
136
|
test_files:
|
131
137
|
- spec/fixtures/tasks/by_id.sql
|
132
138
|
- spec/fixtures/users/by_name.sql
|