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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7cab0f2557ace7ed091eb02c7090a595d0cfb586313b9f03b4727172e9fd670
4
- data.tar.gz: 5dcc6d2ee8e6d99612e6999549c944820b7485735947e80ee953498f2c5cf829
3
+ metadata.gz: 9d318dcf63df4adf2773ecaea8663db39502c2a423e2367a1a0dc9552f277563
4
+ data.tar.gz: ea0483713e317f4eb0b1b4e45099e9db3de30098b207b7adf64a2d29a7370616
5
5
  SHA512:
6
- metadata.gz: 71561f7bf678621e8061be51fd5a833c47ac219eb7f7ba010f8a210ba45c108d3f389ab743b87ab4bbc9d6f6aba95bfbd1694bb6f6c9319fa6e17880cd9fa54f
7
- data.tar.gz: 2c596c55ae278c66b5081a4d06aabfa43f83e8fd162675c2517299f120e231dd56f8d91a7fa0e7d1d7d0e7390022c825db71d5e71013b4d68b98b8daaf89ce86
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
- configure_from_hash! ::ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(url).to_hash
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"
@@ -1,6 +1,6 @@
1
1
  module OTR
2
2
  module ActiveRecord
3
3
  # Gem version
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.1'
5
5
  end
6
6
  end
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.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-05-06 00:00:00.000000000 Z
11
+ date: 2021-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord