rom-yesql 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +11 -9
- data/CHANGELOG.md +5 -1
- data/lib/rom/yesql/gateway.rb +23 -19
- data/lib/rom/yesql/relation.rb +3 -1
- data/lib/rom/yesql/version.rb +1 -1
- data/rom-yesql.gemspec +3 -3
- data/spec/integration/adapter_spec.rb +1 -1
- data/spec/shared/database_setup.rb +1 -1
- data/spec/shared/repository_setup.rb +1 -1
- data/spec/shared/users_and_tasks.rb +1 -1
- data/spec/spec_helper.rb +10 -10
- data/spec/unit/rom/yesql/repository_spec.rb +1 -1
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71d682ad4bde9ef7d69778c1520c682907f2eeb3
|
4
|
+
data.tar.gz: 34ffde7f67a7da528281adb02abcc57ef50dbfdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ab884d970038302ef7275d47b26f9101eb8986b16aa5741e3a26e79b35b7cb79b44a89f1b306f78ffe299ffd321d36201ce87d185ce39c5e9187aa11dce54a
|
7
|
+
data.tar.gz: 62235b937beaf7a8cd723eee295fc9ca0b589d7fd65a6a93d1104e63513fac16db5b34d867ac79d1a629e8c599ee605acd1b05fbe7be96a752730426552205f4
|
data/.travis.yml
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
language: ruby
|
2
|
+
dist: trusty
|
2
3
|
sudo: false
|
3
4
|
cache: bundler
|
4
5
|
bundler_args: --without tools
|
5
6
|
script: "bundle exec rake ci"
|
6
|
-
rvm:
|
7
|
-
- 2.1
|
8
|
-
- 2.2
|
9
|
-
- 2.3.1
|
10
|
-
- rbx-2
|
11
|
-
- jruby-9.0.5.0
|
12
|
-
- jruby-head
|
13
|
-
- ruby-head
|
14
7
|
env:
|
15
8
|
global:
|
16
9
|
- CODECLIMATE_REPO_TOKEN=15dad2a6b4f5f73f367783df8192230b73070b33fe1f193393e9867d50653885
|
17
10
|
- JRUBY_OPTS='--dev -J-Xmx1024M'
|
11
|
+
after_success:
|
12
|
+
# Send coverage report from the job #1 == current MRI release
|
13
|
+
- '[ "${TRAVIS_JOB_NUMBER#*.}" = "1" ] && [ "$TRAVIS_BRANCH" = "master" ] && bundle exec codeclimate-test-reporter'
|
14
|
+
rvm:
|
15
|
+
- 2.4.0
|
16
|
+
- 2.3.3
|
17
|
+
- 2.2.6
|
18
|
+
- jruby-9.1.7.0
|
19
|
+
- ruby-head
|
20
|
+
- rbx-3
|
18
21
|
matrix:
|
19
22
|
allow_failures:
|
20
23
|
- rvm: ruby-head
|
21
|
-
- rvm: jruby-head
|
22
24
|
notifications:
|
23
25
|
webhooks:
|
24
26
|
urls:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## v0.4.0 to-be-released
|
2
|
+
|
3
|
+
Updated to work with rom 3.0.0
|
4
|
+
|
1
5
|
## v0.3.0 2016-07-31
|
2
6
|
|
3
7
|
Updated to work with rom 2.0.0
|
@@ -12,7 +16,7 @@ Updated to work with rom 0.9.0
|
|
12
16
|
|
13
17
|
### Changed
|
14
18
|
|
15
|
-
|
19
|
+
Updated to work with rom 0.8 (solnic)
|
16
20
|
|
17
21
|
[Compare v0.1.0...v0.1.1](https://github.com/rom-rb/rom-yaml/compare/v0.1.0...v0.1.1)
|
18
22
|
|
data/lib/rom/yesql/gateway.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'sequel'
|
2
2
|
|
3
|
-
require 'rom/
|
3
|
+
require 'rom/initializer'
|
4
4
|
|
5
5
|
require 'rom/yesql/dataset'
|
6
6
|
require 'rom/yesql/relation'
|
@@ -14,15 +14,19 @@ module ROM
|
|
14
14
|
#
|
15
15
|
# @api public
|
16
16
|
class Gateway < ROM::Gateway
|
17
|
-
|
17
|
+
extend Initializer
|
18
|
+
|
19
|
+
# @!attribute [r] uri
|
20
|
+
# @return [String] connection string
|
21
|
+
param :uri
|
18
22
|
|
19
23
|
# @!attribute [r] path
|
20
24
|
# @return [String] a path to files with SQL queries
|
21
|
-
option :path, reader: true
|
25
|
+
option :path, reader: true, optional: true
|
22
26
|
|
23
27
|
# @!attribute [r] queries
|
24
28
|
# @return [Hash] a hash with queries
|
25
|
-
option :queries,
|
29
|
+
option :queries, default: -> _ { EMPTY_HASH }, reader: true
|
26
30
|
|
27
31
|
# @!attribute [r] query_proc
|
28
32
|
# This defaults to simple interpolation of the query using option hash passed to a relation
|
@@ -63,11 +67,10 @@ module ROM
|
|
63
67
|
# @option :query_proc [Proc]
|
64
68
|
#
|
65
69
|
# @api public
|
66
|
-
def initialize(
|
70
|
+
def initialize(*)
|
67
71
|
super
|
68
72
|
@connection = Sequel.connect(uri, options)
|
69
|
-
|
70
|
-
queries.freeze
|
73
|
+
@queries = @queries.merge(load_queries(path)).freeze
|
71
74
|
Relation.query_proc(query_proc)
|
72
75
|
Relation.load_queries(queries)
|
73
76
|
end
|
@@ -99,18 +102,19 @@ module ROM
|
|
99
102
|
# Loads queries from filesystem if :path was provided
|
100
103
|
#
|
101
104
|
# @api private
|
102
|
-
def
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
105
|
+
def load_queries(path)
|
106
|
+
if path.nil?
|
107
|
+
{}
|
108
|
+
else
|
109
|
+
Dir["#{path}/*"].each_with_object({}) do |dir, fs_queries|
|
110
|
+
dataset = File.basename(dir).to_sym
|
111
|
+
|
112
|
+
fs_queries[dataset] = Dir["#{dir}/**/*.sql"].each_with_object({}) do |file, ds_queries|
|
113
|
+
query_name = File.basename(file, '.*').to_sym
|
114
|
+
sql = File.read(file).strip
|
115
|
+
|
116
|
+
ds_queries[query_name] = sql
|
117
|
+
end
|
114
118
|
end
|
115
119
|
end
|
116
120
|
end
|
data/lib/rom/yesql/relation.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'dry/core/class_attributes'
|
2
|
+
|
1
3
|
require 'rom/relation'
|
2
4
|
require 'rom/yesql/relation/class_interface'
|
3
5
|
|
@@ -31,7 +33,7 @@ module ROM
|
|
31
33
|
class Relation < ROM::Relation
|
32
34
|
adapter :yesql
|
33
35
|
|
34
|
-
extend
|
36
|
+
extend Dry::Core::ClassAttributes
|
35
37
|
|
36
38
|
defines :query_proc
|
37
39
|
|
data/lib/rom/yesql/version.rb
CHANGED
data/rom-yesql.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'rom/yesql/version'
|
@@ -18,8 +17,9 @@ Gem::Specification.new do |spec|
|
|
18
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.add_runtime_dependency "rom", "~>
|
22
|
-
spec.add_runtime_dependency
|
20
|
+
spec.add_runtime_dependency "rom", "~> 3.0"
|
21
|
+
spec.add_runtime_dependency "dry-core", "~> 0.2", ">= 0.2.4"
|
22
|
+
spec.add_runtime_dependency "sequel", "~> 4.27"
|
23
23
|
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'bundler'
|
4
2
|
Bundler.setup
|
5
3
|
|
6
|
-
if RUBY_ENGINE == '
|
7
|
-
require
|
8
|
-
|
4
|
+
if RUBY_ENGINE == 'ruby' && ENV['CI'] == 'true'
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter '/spec/'
|
8
|
+
end
|
9
9
|
end
|
10
10
|
|
11
11
|
require 'rom-yesql'
|
12
|
-
# FIXME: why do we need to require it manually??
|
13
|
-
require 'sequel/adapters/sqlite' unless RUBY_ENGINE == 'jruby'
|
14
12
|
require 'inflecto'
|
15
13
|
require 'logger'
|
16
14
|
|
@@ -27,11 +25,13 @@ Dir[root.join('shared/*.rb').to_s].each { |f| require f }
|
|
27
25
|
|
28
26
|
RSpec.configure do |config|
|
29
27
|
config.before do
|
30
|
-
|
28
|
+
module Test
|
29
|
+
end
|
31
30
|
end
|
32
31
|
|
33
32
|
config.after do
|
34
|
-
|
35
|
-
added_constants.each { |name| Object.send(:remove_const, name) }
|
33
|
+
Object.send(:remove_const, :Test)
|
36
34
|
end
|
35
|
+
|
36
|
+
config.disable_monkey_patching!
|
37
37
|
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.
|
4
|
+
version: 0.4.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:
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rom
|
@@ -16,14 +16,34 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.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
|
-
version: '
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-core
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 0.2.4
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.2.4
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: sequel
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|