sequelizer 0.1.2 → 0.1.3

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
  SHA256:
3
- metadata.gz: 96e14a988922e4e961273049b4ec5137332a6276702fbc7ff4c7ece29dbf10da
4
- data.tar.gz: e8eb82b04cbacfebdc8abd98ac4a85614d366097a455f0b6b9bf7ed7df8d41bc
3
+ metadata.gz: 4cfd3663b92545f1bffb3c811297f81f26a2a1c237bc621c31d22d905be4bc0b
4
+ data.tar.gz: 1865666d4f264967f909820d9c7572dfff2b74bc3c80219c589c8197f18e5e59
5
5
  SHA512:
6
- metadata.gz: 98e32334ee46938dc39b5ae853ec54e56f6577fdefb86637f50ea24a77f33730f6059ba7ee75138b150ae46191a9f6957f86c44183b26564c934b56bdc3b286e
7
- data.tar.gz: d56db775cf833b2935afa22d9308d91820d980150a6e0d7c8ef058d3d2727cabc7b3e949444fe195ddf1109e62b46671e0396629b81d58ae4bb7e561d2d93a73
6
+ metadata.gz: c02b029eb0bf30bfb6498d75fbde32aa7a1576074c74dd55993a91a3f4d6458c53e0e1ed45c16d3177767ddde7b44ce706cbafce0269681f025acbe80f46ea35
7
+ data.tar.gz: f123e5d48c8178d9b5609f6f44d9744fb00f31085b11364aa839b902784f9de60beedabc7b90a7c6e4ae6b84a62d9d9a1b338190a0597fec40107518632b94f8
@@ -39,7 +39,8 @@ module Sequelizer
39
39
  # the string is returned without modification
40
40
  def fix_options(passed_options)
41
41
  return passed_options unless passed_options.nil? || passed_options.is_a?(Hash)
42
- sequelizer_options = db_config.merge(OptionsHash.new(passed_options || {}).to_hash)
42
+ opts = OptionsHash.new(passed_options || {}).to_hash
43
+ sequelizer_options = db_config(opts).merge(opts)
43
44
 
44
45
  if sequelizer_options[:adapter] =~ /^postgres/
45
46
  sequelizer_options[:adapter] = 'postgres'
@@ -65,11 +66,12 @@ module Sequelizer
65
66
  # - ~/.config/sequelizer.yml if it exists
66
67
  # - config/database.yml if it exists
67
68
  # - environment variables (also reads from .env)
68
- def db_config
69
+ def db_config(opts)
69
70
  @db_config ||= begin
70
- opts = OptionsHash.new(YamlConfig.user_config.options)
71
- opts.merge!(YamlConfig.local_config.options)
72
- opts.merge!(EnvConfig.new.options)
71
+ opts = OptionsHash.new(opts)
72
+ opts.merge!(YamlConfig.user_config.options) unless opts[:ignore_yaml]
73
+ opts.merge!(YamlConfig.local_config.options) unless opts[:ignore_yaml]
74
+ opts.merge!(EnvConfig.new.options) unless opts[:ignore_env]
73
75
  opts
74
76
  end
75
77
  end
@@ -1,4 +1,4 @@
1
1
  module Sequelizer
2
2
  # Version for the gem
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
data/sequelizer.gemspec CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rake', '~> 12.0'
26
26
  spec.add_dependency 'sequel', '~> 5.0'
27
27
  spec.add_dependency 'dotenv', '~> 2.1'
28
- spec.add_dependency 'thor', '~> 0.19'
28
+ spec.add_dependency 'thor', '~> 1.0'
29
29
  spec.add_dependency 'hashie', '~> 3.2'
30
30
  end
@@ -12,23 +12,26 @@ class TestConnectionMaker < Minitest::Test
12
12
  end
13
13
  end
14
14
 
15
+ def with_ignored_yaml_config(opts = {})
16
+ end
17
+
18
+
15
19
  def with_yaml_config(options = {})
16
- yaml_config = Minitest::Mock.new
17
- yaml_config.expect :options, options
18
- yaml_config.expect :options, options
19
- Sequelizer::YamlConfig.stub :new, yaml_config do
20
- yield
20
+ yaml_config = Sequelizer::YamlConfig.new
21
+ yaml_config.stub(:options, options) do
22
+ Sequelizer::YamlConfig.stub :new, yaml_config do
23
+ yield
24
+ end
21
25
  end
22
- yaml_config.verify
23
26
  end
24
27
 
25
28
  def with_env_config(options = {})
26
- env_config = Minitest::Mock.new
27
- env_config.expect :options, options
28
- Sequelizer::EnvConfig.stub :new, env_config do
29
- yield
29
+ env_config = Sequelizer::EnvConfig.new
30
+ env_config.stub(:options, options) do
31
+ Sequelizer::EnvConfig.stub :new, env_config do
32
+ yield env_config
33
+ end
30
34
  end
31
- env_config.verify
32
35
  end
33
36
 
34
37
  def test_reads_options_from_yaml_config
@@ -37,6 +40,12 @@ class TestConnectionMaker < Minitest::Test
37
40
  end
38
41
  end
39
42
 
43
+ def test_ignores_options_from_yaml_config_when_asked
44
+ with_yaml_config(@options) do
45
+ assert_nil Sequelizer::ConnectionMaker.new(ignore_yaml: true).options.to_hash[:adapter]
46
+ end
47
+ end
48
+
40
49
  def test_applies_settings_if_given
41
50
  with_yaml_config(@options.merge(postgres_db_opt_flim: :flam)) do
42
51
  with_env_config do
@@ -65,6 +74,14 @@ class TestConnectionMaker < Minitest::Test
65
74
  end
66
75
  end
67
76
 
77
+ def test_ignores_options_from_env_config_if_no_yaml_config
78
+ with_yaml_config do
79
+ with_env_config(@options) do
80
+ assert_nil Sequelizer::ConnectionMaker.new(ignore_env: true).options.to_hash[:adapter]
81
+ end
82
+ end
83
+ end
84
+
68
85
  def test_applies_configuration_to_connection
69
86
  opts = @options.merge(postgres_db_opt_search_path: "searchy", impala_db_opt_search_path: "searchy2")
70
87
  with_yaml_config(opts) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequelizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Duryea
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-15 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.19'
117
+ version: '1.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.19'
124
+ version: '1.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: hashie
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  - !ruby/object:Gem::Version
197
197
  version: '0'
198
198
  requirements: []
199
- rubygems_version: 3.0.3
199
+ rubygems_version: 3.1.4
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Sequel database connections via config/database.yml or .env