sinatra-activerecord 2.0.21 → 2.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sinatra/activerecord.rb +9 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b662752481c4940600cb421378b4dd447e549ea11a876c86a36d250f473e706
4
- data.tar.gz: ac0a9176f4e2b0abd115664db78ba1bfeb7ed043dd190c3ed5251a794555a360
3
+ metadata.gz: dd8c9b0af0329e3c58559409592d58ff44a7110407969effa9902c34c316eb07
4
+ data.tar.gz: fb39eecde9d4947aac413beda568cb3b60ad408d8505fddf45907cbed18193f2
5
5
  SHA512:
6
- metadata.gz: 6b6bb226f78cc9fd45e928625b3c062077101fb0e8a9f58ad47fd8f374ab316e96cee7366872346c02bfb411306e997a8a2848b433b8103abba9643f2f8f2f48
7
- data.tar.gz: 7c2b8cd35e0dc75e9ac1045c8a1074cdaa75eedadc6ce607fd8e99a30ba6f3b3e0abae2f0bfeab8276a38c840da529dc9f1cb5d689108c191cd29a36332958ce
6
+ metadata.gz: 8655fe10cab66ccb6d3c4ab505d81e7ae2d091057dcda13b2f8e0504f738274274a4ae4d53c5d6c91bf64f0c5b2be2603467bc62272d2cf7125e124c825b7c37
7
+ data.tar.gz: b04451e063eb7729b3e33937697c13f0d1dd329bfcd7970a8e2d0eda4f7c64fda3d72dc4aa896e16569db2d95a4f0ee158b7068147dac8d8ec53c545296c50d3
@@ -7,6 +7,8 @@ require 'pathname'
7
7
  require 'yaml'
8
8
  require 'erb'
9
9
 
10
+ require 'active_record/database_configurations/connection_url_resolver' if Gem.loaded_specs["activerecord"].version >= Gem::Version.create('6.1')
11
+
10
12
  module Sinatra
11
13
  module ActiveRecordHelper
12
14
  def database
@@ -22,8 +24,13 @@ module Sinatra
22
24
  file_path = File.join(root, path) if Pathname(path).relative? and root
23
25
  file_spec = YAML.load(ERB.new(File.read(path)).result) || {}
24
26
 
25
- url_spec = ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(url).to_hash
26
-
27
+ # ActiveRecord 6.1+ has moved the connection url resolver to another module
28
+ if Gem.loaded_specs["activerecord"].version >= Gem::Version.create('6.1')
29
+ url_spec = ActiveRecord::DatabaseConfigurations::ConnectionUrlResolver.new(url).to_hash
30
+ else
31
+ url_spec = ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(url).to_hash
32
+ end
33
+
27
34
  # url_spec will override the same key, if exist
28
35
  final_spec = file_spec.keys.map{ |env| [env, file_spec[env].merge(url_spec)] }.to_h
29
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.21
4
+ version: 2.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-10-24 00:00:00.000000000 Z
13
+ date: 2021-01-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sinatra