diff --git a/lib/swiftype.rb b/lib/swiftype.rb index 1b26ff2..9467e98 100644 --- a/lib/swiftype.rb +++ b/lib/swiftype.rb @@ -2,5 +2,11 @@ module Swiftype extend Swiftype::Configuration + + def self.const_missing(const_name) + super unless const_name == :Easy + warn "`Swiftype::Easy` has been deprecated. Use `Swiftype::Client` instead." + Client + end end diff --git a/lib/swiftype/client.rb b/lib/swiftype/client.rb index e27719b..c0c6914 100644 --- a/lib/swiftype/client.rb +++ b/lib/swiftype/client.rb @@ -7,6 +7,11 @@ module Swiftype class Client include Swiftype::Request + def self.configure(&block) + warn "`Swiftype::Easy.configure` has been deprecated. Use `Swiftype.configure` instead." + Swiftype.configure &block + end + # Create a new Swiftype::Client client # # @param options [Hash] a hash of configuration options that will overrided what is set on the Swiftype class. diff --git a/spec/deprecated_spec.rb b/spec/deprecated_spec.rb new file mode 100644 index 0000000..8809688 --- /dev/null +++ b/spec/deprecated_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'deprecated classes and methods' do + context 'Swiftype::Easy' do + it 'returns Swiftype::Client' do + Swiftype::Easy.should == Swiftype::Client + end + end + + context 'Swiftype::Easy.configure' do + it 'calls warn and calls Swiftype.configure' do + Swiftype::Client.should_receive(:warn) + Swiftype::Easy.configure do |config| + config.api_key = 'got set' + end + + Swiftype.api_key.should == 'got set' + end + end +end