From ef566beb4551ccad4970fe945214f7efbd2dca65 Mon Sep 17 00:00:00 2001 From: Kevin Perez Date: Thu, 4 Jan 2024 18:57:33 -0600 Subject: [PATCH] Add deprecation warning for WickedPdf.config= This adds a deprecation warning for the old way to set config. Users have the option to silence the warning if they want to do so. --- lib/wicked_pdf.rb | 10 +++++++++- test/test_helper.rb | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/wicked_pdf.rb b/lib/wicked_pdf.rb index 38d477a5..ab34d959 100644 --- a/lib/wicked_pdf.rb +++ b/lib/wicked_pdf.rb @@ -20,10 +20,18 @@ class WickedPdf DEFAULT_BINARY_VERSION = Gem::Version.new('0.9.9') @@config = {} - cattr_accessor :config + cattr_accessor :config, :silence_deprecations include Progress + def self.config=(config) + unless @@silence_deprecations + ::Kernel.warn "WickedPdf.config= is deprecated and will be removed in future versions. Use WickedPdf.configure instead." + end + + @@config = config + end + def self.configure config = OpenStruct.new(@@config) yield config diff --git a/test/test_helper.rb b/test/test_helper.rb index 15990f93..74257052 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -11,6 +11,7 @@ require 'wicked_pdf' Rails.backtrace_cleaner.remove_silencers! +WickedPdf.silence_deprecations = true if (assets_dir = Rails.root.join('app/assets')) && File.directory?(assets_dir) # Copy CSS file