Skip to content

Commit d90d805

Browse files
authored
Merge pull request #410 from samvera/remove_deprecation_dependency
Replace custom deprecation gem with ActiveSupport::Deprecation
2 parents 4b03d43 + c113b0b commit d90d805

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

lib/qa.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,22 @@ def self.config(&block)
2525
@config
2626
end
2727

28+
def self.deprecator
29+
@deprecator ||= deprecator_instance
30+
end
31+
32+
# TODO: refactor when support for Rails < 7.1.0 is dropped
33+
def self.deprecator_instance
34+
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0')
35+
ActiveSupport::Deprecation.new("6.0.0", "Qa")
36+
else
37+
Rails.logger
38+
end
39+
end
40+
2841
def self.deprecation_warning(in_msg: nil, msg:)
29-
return if Rails.env == 'test'
3042
in_msg = in_msg.present? ? "In #{in_msg}, " : ''
31-
warn "[DEPRECATED] #{in_msg}#{msg} It will be removed in the next major release."
43+
deprecator.warn "#{in_msg}#{msg} It will be removed in the next major release."
3244
end
3345

3446
# Raised when the authority is not valid

lib/qa/engine.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,12 @@ class Engine < ::Rails::Engine
1717
Rails.autoloaders.main.ignore(Rails.root.join('lib', 'generators'))
1818
end
1919
end
20+
21+
# Allow main application to configure deprecation behavior
22+
if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1.0')
23+
initializer "qa.deprecator" do |app|
24+
app.deprecators[:qa] = Qa.deprecator
25+
end
26+
end
2027
end
2128
end

qa.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Gem::Specification.new do |s|
1818
s.metadata = { "rubygems_mfa_required" => "true" }
1919

2020
s.add_dependency 'activerecord-import'
21-
s.add_dependency 'deprecation'
2221
s.add_dependency 'faraday', '< 3.0', '!= 2.0.0'
2322
s.add_dependency 'geocoder'
2423
s.add_dependency 'ldpath'

0 commit comments

Comments
 (0)