Skip to content

Commit

Permalink
Replace deprecation gem with ActiveSupport's deprecation behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Aug 2, 2022
1 parent 29af53f commit e11666e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 21 deletions.
5 changes: 1 addition & 4 deletions app/components/blacklight/facet_field_list_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

module Blacklight
class FacetFieldListComponent < Blacklight::Component
extend Deprecation
self.deprecation_horizon = 'blacklight 9.0'

def initialize(facet_field:, layout: nil)
@facet_field = facet_field
@layout = layout == false ? FacetFieldNoLayoutComponent : Blacklight::FacetFieldComponent
Expand All @@ -26,7 +23,7 @@ def render_facet_limit_list(paginator, facet_field, wrapping_element = :li)

render(facet_item_component_class(facet_config).with_collection(collection, wrapping_element: wrapping_element))
end
deprecation_deprecate render_facet_limit_list: 'Call e.g. `render facet_items` instead'
Blacklight.deprecation.deprecate_methods(self, render_facet_limit_list: 'Call e.g. `render facet_items` instead')

def facet_items(wrapping_element: :li, **item_args)
facet_item_component_class.with_collection(facet_item_presenters, wrapping_element: wrapping_element, **item_args)
Expand Down
4 changes: 1 addition & 3 deletions app/components/blacklight/icons/legacy_icon_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
module Blacklight
module Icons
class LegacyIconComponent < ::ViewComponent::Base
extend Deprecation

def initialize(name:, classes: '', aria_hidden: false, label: true, role: 'img', additional_options: {})
@name = name
Deprecation.warn(self, "Calling the LegacyIconComponent with \"#{name}\" is deprecated. Instead create a component for this icon.")
Blacklight.deprecation.warn("Calling the LegacyIconComponent with \"#{name}\" is deprecated. Instead create a component for this icon.")
@classes = classes
@aria_hidden = aria_hidden
@icon = Blacklight::Icon.new(name, classes: classes, label: label, role: role, additional_options: additional_options)
Expand Down
4 changes: 1 addition & 3 deletions app/components/blacklight/response/facet_group_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ module Blacklight
module Response
# Render a group of facet fields
class FacetGroupComponent < Blacklight::Component
extend Deprecation

renders_one :body

# @param [Blacklight::Response] response
Expand Down Expand Up @@ -36,7 +34,7 @@ def render?

# @deprecated
def default_body
Deprecation.warn('Rendering the Blacklight::FacetGroupComponent without a body slot is deprecated.')
Blacklight.deprecation.warn('Rendering the Blacklight::FacetGroupComponent without a body slot is deprecated.')
helpers.render(Blacklight::FacetComponent.with_collection(@fields, response: @response))
end

Expand Down
8 changes: 4 additions & 4 deletions app/controllers/concerns/blacklight/search_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def add_to_search_history search
def nonpersisted_search_session_params
unless method(:blacklisted_search_session_params).source_location.first.end_with?('deprecation/method_wrappers.rb')
# The blacklisted_search_session_params was overridden, so call it.
Deprecation.warn(self, "blacklisted_search_session_params was overriden in your app, " \
"but that method should be renamed to `nonpersisted_search_session_params'. " \
"The original behavior will be removed in the next major release.")
Blacklight.deprecation.warn(self, "blacklisted_search_session_params was overriden in your app, " \
"but that method should be renamed to `nonpersisted_search_session_params'. " \
"The original behavior will be removed in the next major release.")
return blacklisted_search_session_params
end
[:commit, :counter, :total, :search_id, :page, :per_page]
Expand All @@ -117,7 +117,7 @@ def nonpersisted_search_session_params
def blacklisted_search_session_params
nonpersisted_search_session_params
end
deprecation_deprecate blacklisted_search_session_params: 'use nonpersisted_search_session_params instead'
Blacklight.deprecation.deprecate_methods(self, blacklisted_search_session_params: 'use nonpersisted_search_session_params instead')

# calls setup_previous_document then setup_next_document.
# used in the show action for single view pagination.
Expand Down
7 changes: 2 additions & 5 deletions app/helpers/blacklight/render_partials_helper_behavior.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# frozen_string_literal: true

module Blacklight::RenderPartialsHelperBehavior
extend Deprecation
self.deprecation_horizon = 'blacklight 9.0'

##
# Render the document index view
#
Expand All @@ -25,8 +22,8 @@ def render_document_partials(doc, partials = [], locals = {})
render_document_partial(doc, action_name, locals)
end, "\n")
end
deprecation_deprecate render_document_partials: 'Replace this call with: "document_component = blacklight_config.view_config(:atom).summary_component
render document_component.new(presenter: document_presenter(document), component: :div, show: true)"'
Blacklight.deprecation.deprecate_methods(self, render_document_partials: 'Replace this call with: "document_component = blacklight_config.view_config(:atom).summary_component
render document_component.new(presenter: document_presenter(document), component: :div, show: true)"')

##
# Return the list of xml for a given solr document. Doesn't safely escape for HTML.
Expand Down
1 change: 0 additions & 1 deletion blacklight.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ Gem::Specification.new do |s|
s.add_dependency "globalid"
s.add_dependency "jbuilder", '~> 2.7'
s.add_dependency "kaminari", ">= 0.15" # the pagination (page 1,2,3, etc..) of our search results
s.add_dependency "deprecation"
s.add_dependency "i18n", '>= 1.7.0' # added named parameters
s.add_dependency "ostruct", '>= 0.3.2'
s.add_dependency "view_component", '~> 2.43'
Expand Down
5 changes: 4 additions & 1 deletion lib/blacklight.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'kaminari'
require 'deprecation'
require 'blacklight/open_struct_with_hash_access'
require 'blacklight/nested_open_struct_with_hash_access'
require 'jbuilder'
Expand Down Expand Up @@ -132,4 +131,8 @@ def self.logger= logger
def self.root
@root ||= File.expand_path(File.dirname(File.dirname(__FILE__)))
end

def self.deprecation
@deprecation ||= ActiveSupport::Deprecation.new('9.0', 'Blacklight')
end
end

0 comments on commit e11666e

Please sign in to comment.