active_record_doctor 1.13.0 → 1.14.0

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: cc970595479a84692995f75b3e512f1b1a01dc6fc61eee9a738abbd402ac9e44
4
- data.tar.gz: 3bd5807bc126459379478c24d14a5595a2ee207415cb71c86c82ebdfae5f19f3
3
+ metadata.gz: 89e283c2844a768587302646735a080d8db2b3514775083cc6bc74a25e7aff18
4
+ data.tar.gz: 975a75da213c565dba3ee7918ffe64d5b75d812059b8080d6a5134a2fb27028f
5
5
  SHA512:
6
- metadata.gz: 4b0ac66a6f9037ce810ff73660735b816bc58d614dd7612b7c7849292741519cbecd6bdb7105c7392e01fc1621ce550e1b8ba0726573beca33ee6e10ec6e35da
7
- data.tar.gz: c3d2d7b0448ccff98001c72fa6330b54f45364a43e3eff35ff7407d0e2aeaaf8c3070a3ce308992577fa41adf7cdde3a8ba2aa93db4c8955fd69e5ec7f29d03b
6
+ metadata.gz: ca4a89d161ef3a57ee325ea6551417b9e542967d2f932f383eca6e7394ba99f02cf08ac9cd699e98f1f59018669405220fe1175f80d31f60576fc606d2d3f5f6
7
+ data.tar.gz: 70644778b22b9fe2892d12704cdfb3d81337702e8770ca94f8410694e3a8b12ad931bc511bc5188f77726849fca7c87c1ce8fec059d647ea4225adf6ab1363ef
data/README.md CHANGED
@@ -55,7 +55,7 @@ ActiveRecordDoctor::Rake::Task.new do |task|
55
55
  task.deps = []
56
56
 
57
57
  # A path to your active_record_doctor configuration file.
58
- task.config_path = ::Rails.root.join(".active_record_doctor")
58
+ task.config_path = ::Rails.root.join(".active_record_doctor.rb")
59
59
 
60
60
  # A Proc called right before running detectors that should ensure your Active
61
61
  # Record models are preloaded and a database connection is ready.
@@ -111,7 +111,7 @@ If you want to use the default configuration then you don't have to do anything.
111
111
  Just run `active_record_doctor` in your project directory.
112
112
 
113
113
  If you want to customize the tool you should create a file named
114
- `.active_record_doctor` in your project root directory with content like:
114
+ `.active_record_doctor.rb` in your project root directory with content like:
115
115
 
116
116
  ```ruby
117
117
  ActiveRecordDoctor.configure do
@@ -68,9 +68,41 @@ module ActiveRecordDoctor
68
68
  end
69
69
 
70
70
  def config
71
- @config ||= begin
72
- path = config_path && File.exist?(config_path) ? config_path : nil
73
- ActiveRecordDoctor.load_config_with_defaults(path)
71
+ @config ||=
72
+ ActiveRecordDoctor.load_config_with_defaults(effective_config_path)
73
+ end
74
+
75
+ def effective_config_path
76
+ if config_path.nil?
77
+ # No explicit config_path was set, so we're trying to use defaults.
78
+ legacy_default_path = Rails.root.join(".active_record_doctor")
79
+ new_default_path = Rails.root.join(".active_record_doctor.rb")
80
+
81
+ # First, if the legacy file exists we'll use it but show a warning.
82
+ if legacy_default_path.exist?
83
+ warn(<<~WARN.squish)
84
+ DEPRECATION WARNING: active_record_doctor is using the default
85
+ configuration file located in #{legacy_default_path.basename}. However,
86
+ that default will change to #{new_default_path.basename} in the future.
87
+
88
+ In order to avoid errors, please rename the file from
89
+ #{legacy_default_path.basename} to #{new_default_path.basename}.
90
+ WARN
91
+
92
+ return legacy_default_path
93
+ end
94
+
95
+ # Second, if the legacy file does NOT exist, but the new one does then
96
+ # we'll use that.
97
+ if new_default_path.exist?
98
+ return new_default_path
99
+ end
100
+
101
+ # Otherwise, there's no configuration file in use.
102
+ nil
103
+ else
104
+ # If an explicit configuration file was set then we use it as is.
105
+ config_path
74
106
  end
75
107
  end
76
108
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordDoctor
4
- VERSION = "1.13.0"
4
+ VERSION = "1.14.0"
5
5
  end
@@ -19,6 +19,5 @@ ActiveRecordDoctor::Rake::Task.new do |task|
19
19
  # This file is imported when active_record_doctor is being used as part of a
20
20
  # Rails app so it's the right place for all Rails-specific settings.
21
21
  task.deps = [:environment]
22
- task.config_path = Rails.root.join(".active_record_doctor")
23
22
  task.setup = -> { Rails.application.eager_load! }
24
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_doctor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Navis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-04 00:00:00.000000000 Z
11
+ date: 2023-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord