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 +4 -4
- data/lib/simple/sql/config.rb +14 -7
- data/lib/simple/sql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e247c58e46b3508c73b90dfe1000471c773d4f73e1c0ed7ce12204533910f69
|
4
|
+
data.tar.gz: 4c1fd0c77995b9693ea516939994420f0dc7c019c8c36064ccf60c34cef2edfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d77182e024d7c4b92ba61f7e37b06ee694d4940862d307f602874245bb51fd8c6bfdff4c7d584823a60f8b34186bce6633f0fcf65f363804c28c99cd7b5378c
|
7
|
+
data.tar.gz: d79889f4dcddc7845bf444493b5a1e0a8076cf2fb71ff3aae90fdaa89ba069ce77a59ee90a9bf70fae7baabfc3c8e89c80391f52f145c4ec4ff9a4f5da680958
|
data/lib/simple/sql/config.rb
CHANGED
@@ -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
|
-
|
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 =
|
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
|
56
|
+
def load_activerecord_base_configuration(path:, env:)
|
50
57
|
require "yaml"
|
51
|
-
database_config = YAML.load_file
|
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
|
63
|
+
raise("Invalid or missing database configuration in #{path} for #{env.inspect} environment")
|
57
64
|
end
|
58
65
|
end
|
data/lib/simple/sql/version.rb
CHANGED
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.
|
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-
|
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
|