From 523a07ecd96f4b75feb854d5524ee930a8fcac52 Mon Sep 17 00:00:00 2001 From: klobuczek Date: Tue, 24 Sep 2024 04:07:47 +0700 Subject: [PATCH] made deprecation activesupport 7.2 compatible --- lib/active_graph.rb | 3 +++ lib/active_graph/migration.rb | 4 ++-- lib/active_graph/node/has_n.rb | 2 +- lib/active_graph/node/id_property.rb | 2 +- lib/active_graph/node/labels.rb | 2 +- lib/active_graph/node/query/query_proxy.rb | 2 +- lib/active_graph/node/scope.rb | 2 +- lib/active_graph/railtie.rb | 4 ++++ lib/active_graph/relationship/query.rb | 2 +- lib/active_graph/shared/persistence.rb | 2 +- spec/e2e/relationship_spec.rb | 4 ++-- 11 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/active_graph.rb b/lib/active_graph.rb index 19be77304..0fa49973f 100644 --- a/lib/active_graph.rb +++ b/lib/active_graph.rb @@ -27,6 +27,9 @@ loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__)) loader.inflector.inflect("ansi" => "ANSI") module ActiveGraph + def self.deprecator + @deprecator ||= ActiveSupport::Deprecation.new("12", "ActiveGraph") + end end loader.setup # loader.eager_load diff --git a/lib/active_graph/migration.rb b/lib/active_graph/migration.rb index 79e3dd38d..e7d0a0680 100644 --- a/lib/active_graph/migration.rb +++ b/lib/active_graph/migration.rb @@ -38,8 +38,8 @@ def initialize(path = default_path) end def migrate - ActiveSupport::Deprecation.warn '`AddIdProperty` task is deprecated and may be removed from future releases. '\ - 'Create a new migration and use the `populate_id_property` helper.', caller + ActiveGraph.deprecator.warn '`AddIdProperty` task is deprecated and may be removed from future releases. ' \ + 'Create a new migration and use the `populate_id_property` helper.', caller models = ActiveSupport::HashWithIndifferentAccess.new(YAML.load_file(models_filename))[:models] output 'This task will add an ID Property every node in the given file.' output 'It may take a significant amount of time, please be patient.' diff --git a/lib/active_graph/node/has_n.rb b/lib/active_graph/node/has_n.rb index a4fcf32b7..7c9374e9d 100644 --- a/lib/active_graph/node/has_n.rb +++ b/lib/active_graph/node/has_n.rb @@ -299,7 +299,7 @@ module ClassMethods # :nocov: def has_association?(name) - ActiveSupport::Deprecation.warn 'has_association? is deprecated and may be removed from future releases, use association? instead.', caller + ActiveGraph.deprecator.warn 'has_association? is deprecated and may be removed from future releases, use association? instead.', caller association?(name) end diff --git a/lib/active_graph/node/id_property.rb b/lib/active_graph/node/id_property.rb index b5b7fcfac..7783524d1 100644 --- a/lib/active_graph/node/id_property.rb +++ b/lib/active_graph/node/id_property.rb @@ -147,7 +147,7 @@ def id_property(name, conf = {}, inherited = false) # rubocop:disable Naming/PredicateName def has_id_property? - ActiveSupport::Deprecation.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller + ActiveGraph.deprecator.warn 'has_id_property? is deprecated and may be removed from future releases, use id_property? instead.', caller id_property? end diff --git a/lib/active_graph/node/labels.rb b/lib/active_graph/node/labels.rb index 212c18f78..04ae0752d 100644 --- a/lib/active_graph/node/labels.rb +++ b/lib/active_graph/node/labels.rb @@ -160,7 +160,7 @@ def mapped_label_name=(name) # rubocop:disable Naming/AccessorMethodName def set_mapped_label_name(name) - ActiveSupport::Deprecation.warn 'set_mapped_label_name is deprecated, use self.mapped_label_name= instead.', caller + ActiveGraph.deprecator.warn 'set_mapped_label_name is deprecated, use self.mapped_label_name= instead.', caller self.mapped_label_name = name end diff --git a/lib/active_graph/node/query/query_proxy.rb b/lib/active_graph/node/query/query_proxy.rb index bf7829b92..9726ad59f 100644 --- a/lib/active_graph/node/query/query_proxy.rb +++ b/lib/active_graph/node/query/query_proxy.rb @@ -72,7 +72,7 @@ def identity # The relationship identifier most recently used by the QueryProxy chain. attr_reader :rel_var def rel_identity - ActiveSupport::Deprecation.warn 'rel_identity is deprecated and may be removed from future releases, use rel_var instead.', caller + ActiveGraph.deprecator.warn 'rel_identity is deprecated and may be removed from future releases, use rel_var instead.', caller @rel_var end diff --git a/lib/active_graph/node/scope.rb b/lib/active_graph/node/scope.rb index 209657897..64f484be5 100644 --- a/lib/active_graph/node/scope.rb +++ b/lib/active_graph/node/scope.rb @@ -55,7 +55,7 @@ def scope(name, proc) # rubocop:disable Naming/PredicateName def has_scope?(name) - ActiveSupport::Deprecation.warn 'has_scope? is deprecated and may be removed from future releases, use scope? instead.', caller + ActiveGraph.deprecator.warn 'has_scope? is deprecated and may be removed from future releases, use scope? instead.', caller scope?(name) end diff --git a/lib/active_graph/railtie.rb b/lib/active_graph/railtie.rb index 3fdbeacb7..1e8278fcb 100644 --- a/lib/active_graph/railtie.rb +++ b/lib/active_graph/railtie.rb @@ -65,6 +65,10 @@ def empty_config end end + initializer "activegraph.deprecator" do |app| + app.deprecators[:activegraph] = ActiveGraph.deprecator + end + def setup!(config = empty_config) config = final_driver_config!(config) scheme = config.delete(:scheme) || 'bolt' diff --git a/lib/active_graph/relationship/query.rb b/lib/active_graph/relationship/query.rb index 6b476be34..c58bd3699 100644 --- a/lib/active_graph/relationship/query.rb +++ b/lib/active_graph/relationship/query.rb @@ -49,7 +49,7 @@ def last private def deprecation_warning! - ActiveSupport::Deprecation.warn 'The ActiveGraph::Relationship::Query module has been deprecated and will be removed in a future version of the gem.', caller + ActiveGraph.deprecator.warn 'The ActiveGraph::Relationship::Query module has been deprecated and will be removed in a future version of the gem.', caller end def where_query diff --git a/lib/active_graph/shared/persistence.rb b/lib/active_graph/shared/persistence.rb index a87a4c50b..4a6209d4f 100644 --- a/lib/active_graph/shared/persistence.rb +++ b/lib/active_graph/shared/persistence.rb @@ -276,7 +276,7 @@ def inject_timestamps! def set_timestamps warning = 'This method has been replaced with `inject_timestamps!` and will be removed in a future version'.freeze - ActiveSupport::Deprecation.warn warning, caller + ActiveGraph.deprecator.warn warning, caller inject_timestamps! end end diff --git a/spec/e2e/relationship_spec.rb b/spec/e2e/relationship_spec.rb index f90743abc..9e8b09986 100644 --- a/spec/e2e/relationship_spec.rb +++ b/spec/e2e/relationship_spec.rb @@ -463,9 +463,9 @@ class ActiveRelSpecTypesInheritedRelClass < ActiveRelSpecTypesAutomaticRelType describe 'objects and queries' do around do |ex| - ActiveSupport::Deprecation.silenced = true + ActiveGraph.deprecator.silenced = true ex.run - ActiveSupport::Deprecation.silenced = false + ActiveGraph.deprecator.silenced = false end let!(:rel1) { MyRelClass.create(from_node: from_node, to_node: to_node, score: 99) }