Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds deprecation warnings for the Module and the Class method Solrizer.solr_name #51

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/solrizer.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require 'active_support'
require 'active_support/core_ext/module/attribute_accessors'
require 'deprecation'

module Solrizer
Deprecation.warn(self, "Solrizer has been merged into ActiveFedora please see (https://github.com/samvera/active_fedora/pull/1223)." \
" This means that this Gem is no longer actively maintained, and that there are plans for it to be deprecated." \
" Please see the ActiveFedora documentation for further reference: https://github.com/samvera/active_fedora/wiki.")
extend ActiveSupport::Autoload

autoload :CachingFieldMapper
Expand Down Expand Up @@ -30,10 +34,11 @@ def default_field_mapper=(field_mapper)
def caching_field_mapper
@caching_field_mapper ||= Solrizer::CachingFieldMapper.new(default_field_mapper)
end

def solr_name(*args)
caching_field_mapper.solr_name(*args)
end
deprecation_deprecate solr_name: 'use ActiveFedora.index_field_mapper.solr_name instead'

# @params [Hash] doc the hash to insert the value into
# @params [String] name the name of the field (without the suffix)
Expand All @@ -58,7 +63,7 @@ def insert_field(doc, name, value, *indexer_args)
# @params [String] name the name of the field (without the suffix)
# @params [String,Date] value the value to be inserted
# @params [Array,Hash] indexer_args the arguments that find the indexer
# @returns [Hash] doc the document that was provided with the new field (replacing any field with the same name)
# @returns [Hash] doc the document that was provided with the new field (replacing any field with the same name)
def set_field(doc, name, value, *indexer_args)
# adding defaults indexer
indexer_args = [:stored_searchable] if indexer_args.empty?
Expand Down
12 changes: 7 additions & 5 deletions solrizer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ Gem::Specification.new do |s|
s.summary = %q{A utility for building solr indexes, usually from Fedora repository content with solrizer-fedora extension gem.}
s.description = %q{Use solrizer to populate solr indexes. You can run solrizer from within your app, using the provided rake tasks, or as a JMS listener}

s.add_dependency "activesupport"
s.add_dependency "deprecation"
s.add_dependency "nokogiri"
s.add_dependency "xml-simple"
s.add_dependency "activesupport"
s.add_development_dependency 'rspec', '~> 3.5'

s.add_development_dependency 'pry-byebug'
s.add_development_dependency 'rake'
s.add_development_dependency 'yard'
s.add_development_dependency 'rspec', '~> 3.5'
s.add_development_dependency 'RedCloth' # yard depends on redcloth

s.add_development_dependency 'yard'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
Expand All @@ -29,4 +32,3 @@ Gem::Specification.new do |s|
]
s.require_paths = ["lib"]
end

1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'simplecov'
require 'coveralls'
require 'pry-byebug'

SimpleCov.formatter = Coveralls::SimpleCov::Formatter
SimpleCov.start
Expand Down
6 changes: 5 additions & 1 deletion spec/units/solrizer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@
end

describe ".solr_name" do
it "should delegate to default_field_mapper" do
before do
allow(Deprecation).to receive(:warn)
end
it "should delegate to default_field_mapper and issues a deprecation warning" do
expect(Solrizer.solr_name('foo', type: :string)).to eq "foo_tesim"
expect(Solrizer.solr_name('foo', :sortable)).to eq "foo_si"
expect(Deprecation).to have_received(:warn).at_least :once
end
end
end