rom-yesql 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2aedcc9a8aee73d1d75cf44cf9ffcea7c2750e64
4
- data.tar.gz: fb51885ac908e9131e4ceca401549ad214097391
3
+ metadata.gz: 71d682ad4bde9ef7d69778c1520c682907f2eeb3
4
+ data.tar.gz: 34ffde7f67a7da528281adb02abcc57ef50dbfdb
5
5
  SHA512:
6
- metadata.gz: ae27fce18a060dcb5f88b6c0bb8eab3acbf5dd37e8996dd3b38a8012d4a84f4bd1c4d5285076272f9ccb6c1cae187e4fa3351d0ad1594fe5849cf622aaba2343
7
- data.tar.gz: bec60620f2ae3ae65e806b00ff320c04fb291a8895691ee170fcce48ea65602618bb4c40290d649fedd7e714cac626c91ad4c6e20e6877cfe7f2ec077194c7e5
6
+ metadata.gz: 83ab884d970038302ef7275d47b26f9101eb8986b16aa5741e3a26e79b35b7cb79b44a89f1b306f78ffe299ffd321d36201ce87d185ce39c5e9187aa11dce54a
7
+ data.tar.gz: 62235b937beaf7a8cd723eee295fc9ca0b589d7fd65a6a93d1104e63513fac16db5b34d867ac79d1a629e8c599ee605acd1b05fbe7be96a752730426552205f4
@@ -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:
@@ -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
- * Updated to work with rom 0.8 (solnic)
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
 
@@ -1,6 +1,6 @@
1
1
  require 'sequel'
2
2
 
3
- require 'rom/support/options'
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
- include Options
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, type: Hash, default: EMPTY_HASH, reader: true
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(uri, options = {})
70
+ def initialize(*)
67
71
  super
68
72
  @connection = Sequel.connect(uri, options)
69
- initialize_queries
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 initialize_queries
103
- @queries = options[:queries].dup
104
-
105
- return unless path
106
-
107
- Dir["#{path}/*"].each do |dir|
108
- dataset = File.basename(dir).to_sym
109
- @queries[dataset] = {}
110
- Dir["#{dir}/**/*.sql"].each do |file|
111
- name = File.basename(file, '.*').to_sym
112
- sql = File.read(file)
113
- @queries[dataset][name] = sql.strip
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
@@ -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 ClassMacros
36
+ extend Dry::Core::ClassAttributes
35
37
 
36
38
  defines :query_proc
37
39
 
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Yesql
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
@@ -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", "~> 2.0"
22
- spec.add_runtime_dependency 'sequel', '~> 4.27'
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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'ROM / Yesql' do
3
+ RSpec.describe 'ROM / Yesql' do
4
4
  include_context 'users and tasks'
5
5
 
6
6
  let(:container) { ROM.container(configuration) }
@@ -1,4 +1,4 @@
1
- shared_context 'database setup' do
1
+ RSpec.shared_context 'database setup' do
2
2
  include_context 'gateway setup'
3
3
 
4
4
  let!(:conn) { Sequel.connect(uri) }
@@ -1,4 +1,4 @@
1
- shared_context 'gateway setup' do
1
+ RSpec.shared_context 'gateway setup' do
2
2
  let(:root) { Pathname(__FILE__).dirname.join('../..') }
3
3
  let(:path) { root.join('spec/fixtures') }
4
4
 
@@ -1,4 +1,4 @@
1
- shared_context 'users and tasks' do
1
+ RSpec.shared_context 'users and tasks' do
2
2
  include_context 'database setup'
3
3
 
4
4
  before do
@@ -1,16 +1,14 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bundler'
4
2
  Bundler.setup
5
3
 
6
- if RUBY_ENGINE == 'rbx'
7
- require "codeclimate-test-reporter"
8
- CodeClimate::TestReporter.start
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
- @constants = Object.constants
28
+ module Test
29
+ end
31
30
  end
32
31
 
33
32
  config.after do
34
- added_constants = Object.constants - @constants
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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe ROM::Yesql::Gateway do
3
+ RSpec.describe ROM::Yesql::Gateway do
4
4
  include_context 'gateway setup'
5
5
 
6
6
  it 'loads queries from file system when :path is provided' do
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.3.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: 2016-07-31 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
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