simple-sql 0.5.21 → 0.5.22

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: 96995841ebed4baaca67fa39701958d3ccff3a36325400075b043eb1d7236de5
4
- data.tar.gz: fc6ae8d35382e6c6d0aead1743ade7add236cc9e40e50d8f896f353a8e804b3d
3
+ metadata.gz: 0e247c58e46b3508c73b90dfe1000471c773d4f73e1c0ed7ce12204533910f69
4
+ data.tar.gz: 4c1fd0c77995b9693ea516939994420f0dc7c019c8c36064ccf60c34cef2edfd
5
5
  SHA512:
6
- metadata.gz: 5b22a609bcee2a0ad16d1026e586e4845757d63bef891cfa6f38f4ab6268bdf752a34cb5eb72b588e53ffd31c53080b922095e22a1b4556c0c1047fbd505265b
7
- data.tar.gz: bf5dc5c752346705a75ab3274c96a4998012344af45400e76f2f00f5498ed676caa95ff70406654c3ce0d05cbeaabba3d4fd9350c1ee3a4c8bb256ba703e8bff
6
+ metadata.gz: 6d77182e024d7c4b92ba61f7e37b06ee694d4940862d307f602874245bb51fd8c6bfdff4c7d584823a60f8b34186bce6633f0fcf65f363804c28c99cd7b5378c
7
+ data.tar.gz: d79889f4dcddc7845bf444493b5a1e0a8076cf2fb71ff3aae90fdaa89ba069ce77a59ee90a9bf70fae7baabfc3c8e89c80391f52f145c4ec4ff9a4f5da680958
@@ -27,14 +27,21 @@ module Simple::SQL::Config
27
27
 
28
28
  # determines the database_url from either the DATABASE_URL environment setting
29
29
  # or a config/database.yml file.
30
- def determine_url
31
- ENV["DATABASE_URL"] || database_url_from_database_yml
30
+ def determine_url(path: nil)
31
+ if path
32
+ database_url_from_database_yml(path)
33
+ elsif ENV["DATABASE_URL"]
34
+ ENV["DATABASE_URL"]
35
+ else
36
+ database_url_from_database_yml("config/database.yml")
37
+ end
32
38
  end
33
39
 
34
40
  private
35
41
 
36
- def database_url_from_database_yml
37
- abc = read_database_yml
42
+ def database_url_from_database_yml(path)
43
+ abc = load_activerecord_base_configuration(path: path, env: ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
44
+
38
45
  username, password, host, port, database = abc.values_at "username", "password", "host", "port", "database"
39
46
 
40
47
  URI::Generic.build(
@@ -46,13 +53,13 @@ module Simple::SQL::Config
46
53
  ).to_s
47
54
  end
48
55
 
49
- def read_database_yml
56
+ def load_activerecord_base_configuration(path:, env:)
50
57
  require "yaml"
51
- database_config = YAML.load_file "config/database.yml"
58
+ database_config = YAML.load_file(path)
52
59
  env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
53
60
 
54
61
  database_config[env] ||
55
62
  database_config["defaults"] ||
56
- raise("Invalid or missing database configuration in config/database.yml for #{env.inspect} environment")
63
+ raise("Invalid or missing database configuration in #{path} for #{env.inspect} environment")
57
64
  end
58
65
  end
@@ -1,5 +1,5 @@
1
1
  module Simple
2
2
  module SQL
3
- VERSION = "0.5.21"
3
+ VERSION = "0.5.22"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.21
4
+ version: 0.5.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-07-17 00:00:00.000000000 Z
12
+ date: 2019-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg_array_parser