Skip to content

Commit

Permalink
ObsoleteClient to handle instantiations of clients from old library (t…
Browse files Browse the repository at this point in the history
…wilio#341)

* ObsoleteClient to handle instantiations of clients from old library

* Added pre-commit hook
  • Loading branch information
tmconnors authored and dougblack committed Sep 15, 2017
1 parent ec1cc35 commit 8be56fe
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: test lint-changed lint docs
.PHONY: githooks test lint-changed lint docs

CHANGED_RUBY_FILES = $(shell git status --porcelain | grep ".rb" | awk -F ' ' '{print $2}' | tr '\n' ' ')

install:
install: githooks
bundle install; bundle exec rake install

test-install:
Expand All @@ -17,6 +17,10 @@ docs:
lint:
rubocop --cache true --parallel

githooks:
cp githooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

authors:
echo "Authors\n=======\n\nA huge thanks to all of our contributors:\n\n" > AUTHORS.md
git log --raw | grep "^Author: " | cut -d ' ' -f2- | cut -d '<' -f1 | sed 's/^/- /' | sort | uniq >> AUTHORS.md
Expand Down
1 change: 1 addition & 0 deletions githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
make test
3 changes: 3 additions & 0 deletions lib/twilio-ruby/framework/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ def to_s
"[HTTP #{status_code}] #{code} : #{message}"
end
end

class ObsoleteError < StandardError
end
end
end
10 changes: 10 additions & 0 deletions lib/twilio-ruby/framework/obsolete_client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Twilio
module REST
class ObsoleteClient
def initialize(*)
raise ObsoleteError, "#{self.class} has been removed from this version of the library. "\
'Please refer to current documentation for guidance.'
end
end
end
end
28 changes: 28 additions & 0 deletions lib/twilio-ruby/rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,5 +365,33 @@ def to_s
"#<Twilio::REST::Client #{@account_sid}>"
end
end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class BaseClient < ObsoleteClient; end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class IpMessagingClient < ObsoleteClient; end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class LookupsClient < ObsoleteClient; end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class MonitorClient < ObsoleteClient; end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class PricingClient < ObsoleteClient; end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class TaskRouterClient < ObsoleteClient; end

##
# Dummy client which provides no functionality. Please use Twilio::REST::Client instead.
class TrunkingClient < ObsoleteClient; end
end
end
49 changes: 49 additions & 0 deletions spec/rest/client_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
require 'spec_helper'

describe Twilio::REST::ObsoleteClient do
it 'raise an exception' do
expect { Twilio::REST::ObsoleteClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::BaseClient do
it 'raise an exception' do
expect { Twilio::REST::BaseClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::IpMessagingClient do
it 'raise an exception' do
expect { Twilio::REST::IpMessagingClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::LookupsClient do
it 'raise an exception' do
expect { Twilio::REST::LookupsClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::MonitorClient do
it 'raise an exception' do
expect { Twilio::REST::MonitorClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::PricingClient do
it 'raise an exception' do
expect { Twilio::REST::PricingClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::TaskRouterClient do
it 'raise an exception' do
expect { Twilio::REST::TaskRouterClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

describe Twilio::REST::TrunkingClient do
it 'raise an exception' do
expect { Twilio::REST::TrunkingClient.new }.to raise_error(Twilio::REST::ObsoleteError)
end
end

0 comments on commit 8be56fe

Please sign in to comment.