otr-activerecord 2.0.2 → 2.1.1

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: cd820c260dab9b0cbef1548223fd8c7173c5cf2995e133e32db0ce2c90c3c427
4
- data.tar.gz: 2a170bd9fcaee46df1a0255180cc765eb4145d95fcb1ca7daf63a786cd43518d
3
+ metadata.gz: 618d9bd8f7eefebc0dec7d8edab50f3467d67960f0d45f6af2f6b9269c891326
4
+ data.tar.gz: defdc1b651311d6223c93372c12414c8aa959bfe2bff5c6e2f9ccfefb8742b2a
5
5
  SHA512:
6
- metadata.gz: c736dd5202985ab80f22318fbdab901c769e009ebc5dfb6b3de3c3be133f767e530222c231000bdef783c9fb3628cdbe69b5c1c3e9191bd1e3d1d5606debf198
7
- data.tar.gz: 5e5bfb8062b5ab2508b5057a5b8e222a5f0034a96a3e0a9f632c74ae2e53ba05350c8d30bf84b2e47051deea66a3094dd62721afb6e4d6b731135d1491cea44b
6
+ metadata.gz: ed724376e924c950216a0af6be220026eae7827771f956b823a3a5a87cde337382c417c10959a47e257a6a810f86f43104c1808abdfda26bd4237e0b19ec2ab2
7
+ data.tar.gz: 7b139648c7f47ff52dd6888c6bf9027d4c56d1ca8f5a6549eaa42ae48d6b9ed31ec10b2d9e5029f228b8c21824fca8910b38cac7c627bcfa2a21a9b6855c52a4
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  An easy way to use ActiveRecord "off the rails." Works with Grape, Sinatra, plain old Rack, or even in a boring little script!. The defaults are all very Railsy (`config/database.yml`, `db/seeds.rb`, `db/migrate`, etc.), but you can easily change them. (Formerly known as `grape-activerecord`.) Supports:
4
4
 
5
+ * ActiveRecord 7.0.0.alpha2 (new AR features, like encryption, not tested)
5
6
  * ActiveRecord 6
6
7
  * ActiveRecord 5
7
8
  * ActiveRecord 4
@@ -7,6 +7,7 @@ module OTR
7
7
  autoload :Compatibility4, 'otr-activerecord/compatibility_4'
8
8
  autoload :Compatibility5, 'otr-activerecord/compatibility_5'
9
9
  autoload :Compatibility6, 'otr-activerecord/compatibility_6'
10
+ autoload :Compatibility7, 'otr-activerecord/compatibility_7'
10
11
 
11
12
  class << self
12
13
  # Relative path to the "db" dir
@@ -57,7 +58,7 @@ module OTR
57
58
  # Connect to database with a yml file. Example: "config/database.yml"
58
59
  def self.configure_from_file!(path)
59
60
  raise "#{path} does not exist!" unless File.file? path
60
- result =(YAML.safe_load(ERB.new(File.read(path)).result, [], [], true) || {})
61
+ result = load_yaml(path)
61
62
  ::ActiveRecord::Base.configurations = begin
62
63
  result.each do |_env, config|
63
64
  if config.all? { |_, v| v.is_a?(Hash) }
@@ -83,5 +84,20 @@ module OTR
83
84
  def self.rack_env
84
85
  (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || ENV['APP_ENV'] || ENV['OTR_ENV'] || 'development').to_sym
85
86
  end
87
+
88
+ # Support old Psych versions
89
+ def self.load_yaml(path)
90
+ erb_result = ERB.new(File.read(path)).result
91
+
92
+ result = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
93
+ YAML.safe_load(erb_result, aliases: true)
94
+ else
95
+ YAML.safe_load(erb_result, [], [], true)
96
+ end
97
+
98
+ result || {}
99
+ end
100
+
101
+ private_class_method :load_yaml
86
102
  end
87
103
  end
@@ -8,7 +8,6 @@ module OTR
8
8
  def initialize
9
9
  @major_version = 4
10
10
  ::ActiveRecord::Base.default_timezone = :utc
11
- ::ActiveRecord::Base.logger = Logger.new(STDOUT)
12
11
  end
13
12
 
14
13
  # All db migration dir paths
@@ -8,7 +8,6 @@ module OTR
8
8
  def initialize
9
9
  @major_version = 5
10
10
  ::ActiveRecord::Base.default_timezone = :utc
11
- ::ActiveRecord::Base.logger = Logger.new(STDOUT)
12
11
  end
13
12
 
14
13
  # All db migration dir paths
@@ -8,7 +8,6 @@ module OTR
8
8
  def initialize
9
9
  @major_version = 6
10
10
  ::ActiveRecord::Base.default_timezone = :utc
11
- ::ActiveRecord::Base.logger = Logger.new(STDOUT)
12
11
  end
13
12
 
14
13
  # All db migration dir paths
@@ -23,7 +22,7 @@ module OTR
23
22
 
24
23
  # Basename of migration classes
25
24
  def migration_base_class_name
26
- version = "6.#{::ActiveRecord::VERSION::MINOR}"
25
+ version = "#{@major_version}.#{::ActiveRecord::VERSION::MINOR}"
27
26
  "ActiveRecord::Migration[#{version}]"
28
27
  end
29
28
 
@@ -0,0 +1,11 @@
1
+ module OTR
2
+ module ActiveRecord
3
+ # Compatibility layer for ActiveRecord 7
4
+ class Compatibility7 < Compatibility6
5
+ def initialize
6
+ @major_version = 7
7
+ ::ActiveRecord.default_timezone = :utc
8
+ end
9
+ end
10
+ end
11
+ end
@@ -4,8 +4,10 @@ OTR::ActiveRecord.db_dir = 'db'
4
4
  OTR::ActiveRecord.migrations_paths = %w(db/migrate)
5
5
  OTR::ActiveRecord.fixtures_path = 'test/fixtures'
6
6
  OTR::ActiveRecord.seed_file = 'seeds.rb'
7
- OTR::ActiveRecord._normalizer = case ::ActiveRecord::VERSION::MAJOR
8
- when 4 then OTR::ActiveRecord::Compatibility4.new
9
- when 5 then OTR::ActiveRecord::Compatibility5.new
10
- when 6 then OTR::ActiveRecord::Compatibility6.new
11
- end
7
+ OTR::ActiveRecord._normalizer =
8
+ case ::ActiveRecord::VERSION::MAJOR
9
+ when 4 then OTR::ActiveRecord::Compatibility4.new
10
+ when 5 then OTR::ActiveRecord::Compatibility5.new
11
+ when 6 then OTR::ActiveRecord::Compatibility6.new
12
+ when 7 then OTR::ActiveRecord::Compatibility7.new
13
+ end
@@ -7,7 +7,7 @@ module OTR
7
7
  def initialize(app)
8
8
  @handler = case ::ActiveRecord::VERSION::MAJOR
9
9
  when 4 then ::ActiveRecord::QueryCache.new(app)
10
- when 5, 6 then ActionDispatchHandler.new(app)
10
+ when 5, 6, 7 then ActionDispatchHandler.new(app)
11
11
  end
12
12
  end
13
13
 
@@ -1,6 +1,6 @@
1
1
  module OTR
2
2
  module ActiveRecord
3
3
  # Gem version
4
- VERSION = '2.0.2'
4
+ VERSION = '2.1.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.2
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Hollinger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-14 00:00:00.000000000 Z
11
+ date: 2022-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '4.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.3'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '4.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.3'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: hashie-forbidden_attributes
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -58,6 +58,7 @@ files:
58
58
  - lib/otr-activerecord/compatibility_4.rb
59
59
  - lib/otr-activerecord/compatibility_5.rb
60
60
  - lib/otr-activerecord/compatibility_6.rb
61
+ - lib/otr-activerecord/compatibility_7.rb
61
62
  - lib/otr-activerecord/defaults.rb
62
63
  - lib/otr-activerecord/middleware/connection_management.rb
63
64
  - lib/otr-activerecord/middleware/query_cache.rb
@@ -67,7 +68,7 @@ homepage: https://github.com/jhollinger/otr-activerecord
67
68
  licenses:
68
69
  - MIT
69
70
  metadata: {}
70
- post_install_message:
71
+ post_install_message:
71
72
  rdoc_options: []
72
73
  require_paths:
73
74
  - lib
@@ -82,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  - !ruby/object:Gem::Version
83
84
  version: '0'
84
85
  requirements: []
85
- rubygems_version: 3.0.3
86
- signing_key:
86
+ rubygems_version: 3.1.6
87
+ signing_key:
87
88
  specification_version: 4
88
89
  summary: 'Off The Rails: Use ActiveRecord with Grape, Sinatra, Rack, or anything else!'
89
90
  test_files: []