otr-activerecord 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/otr-activerecord/activerecord.rb +22 -1
- data/lib/otr-activerecord/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: 9d318dcf63df4adf2773ecaea8663db39502c2a423e2367a1a0dc9552f277563
|
4
|
+
data.tar.gz: ea0483713e317f4eb0b1b4e45099e9db3de30098b207b7adf64a2d29a7370616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afe4f886901046296b816c50ecad5637280afbbf077a53a77c1f74a5da2073c8ba91c353fe8cf5df5239c03a5a955ca5ca13b9dd147c729d1dafe7b94f5b652
|
7
|
+
data.tar.gz: 412060fba9c524ccb59acd56f13cbe8d26fcc4f0662377dadc25663b22b3954b11f10a5a8d0593e12e9fbe11e0b6b884cb0c8ce7776d9ea529147d7fbd878277
|
@@ -30,7 +30,28 @@ module OTR
|
|
30
30
|
|
31
31
|
# Connect to database with a DB URL. Example: "postgres://user:pass@localhost/db"
|
32
32
|
def self.configure_from_url!(url)
|
33
|
-
|
33
|
+
require 'uri'
|
34
|
+
uri = URI(url)
|
35
|
+
spec = {"adapter" => uri.scheme}
|
36
|
+
|
37
|
+
case spec["adapter"]
|
38
|
+
when /^sqlite/i
|
39
|
+
spec["database"] = url =~ /::memory:/ ? ":memory:" : "#{uri.host}#{uri.path}"
|
40
|
+
else
|
41
|
+
spec["host"] = uri.host if uri.host
|
42
|
+
spec["port"] = uri.port if uri.port
|
43
|
+
spec["database"] = uri.path.sub(/^\//, "")
|
44
|
+
spec["username"] = uri.user if uri.user
|
45
|
+
spec["password"] = uri.password if uri.password
|
46
|
+
end
|
47
|
+
|
48
|
+
if uri.query
|
49
|
+
opts_ary = URI.decode_www_form(uri.query)
|
50
|
+
opts = Hash[opts_ary]
|
51
|
+
spec.merge!(opts)
|
52
|
+
end
|
53
|
+
|
54
|
+
configure_from_hash! spec
|
34
55
|
end
|
35
56
|
|
36
57
|
# Connect to database with a yml file. Example: "config/database.yml"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: otr-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jordan Hollinger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|