Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

removed lazy-requiring of rest-client and heroku-api #1188

Merged
merged 1 commit into from
Aug 20, 2014
Merged
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
27 changes: 11 additions & 16 deletions lib/heroku/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class << self

def api
@api ||= begin
require("heroku-api")
api = Heroku::API.new(default_params.merge(:api_key => password))

def api.request(params, &block)
Expand Down Expand Up @@ -75,7 +74,6 @@ def password # :nodoc:
end

def api_key(user = get_credentials[0], password = get_credentials[1])
require("heroku-api")
api = Heroku::API.new(default_params)
api.post_login(user, password).body["api_key"]
rescue Heroku::API::Errors::Unauthorized => e
Expand Down Expand Up @@ -240,22 +238,19 @@ def ask_for_password
end

def ask_for_and_save_credentials
require("heroku-api") # for the errors
begin
@credentials = ask_for_credentials
write_credentials
check
rescue Heroku::API::Errors::NotFound, Heroku::API::Errors::Unauthorized => e
delete_credentials
display "Authentication failed."
retry if retry_login?
exit 1
rescue Exception => e
delete_credentials
raise e
end
@credentials = ask_for_credentials
write_credentials
check
check_for_associated_ssh_key unless Heroku::Command.current_command == "keys:add"
@credentials
rescue Heroku::API::Errors::NotFound, Heroku::API::Errors::Unauthorized => e
delete_credentials
display "Authentication failed."
retry if retry_login?
exit 1
rescue Exception => e
delete_credentials
raise e
end

def check_for_associated_ssh_key
Expand Down
8 changes: 2 additions & 6 deletions lib/heroku/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
require "heroku"
require "heroku/command"
require "heroku/helpers"

# workaround for rescue/reraise to define errors in command.rb failing in 1.8.6
if RUBY_VERSION =~ /^1.8.6/
require('heroku-api')
require('rest_client')
end
require 'rest_client'
require 'heroku-api'

begin
# attempt to load the JSON parser bundled with ruby for multi_json
Expand Down
3 changes: 0 additions & 3 deletions lib/heroku/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def self.gem_version_string
attr_accessor :host, :user, :password

def initialize(user, password, host=Heroku::Auth.host)
require 'rest_client'
@user = user
@password = password
@host = host
Expand Down Expand Up @@ -349,7 +348,6 @@ class Service
attr_accessor :attached

def initialize(client, app)
require 'rest_client'
@client = client
@app = app
end
Expand Down Expand Up @@ -435,7 +433,6 @@ class AppCrashed < RuntimeError; end
# support for console sessions
class ConsoleSession
def initialize(id, app, client)
require 'rest_client'
@id = id; @app = app; @client = client
end
def run(cmd)
Expand Down
1 change: 0 additions & 1 deletion lib/heroku/client/heroku_postgresql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def self.headers
attr_reader :attachment
def initialize(attachment)
@attachment = attachment
require 'rest_client'
end

def heroku_postgresql_host
Expand Down
1 change: 0 additions & 1 deletion lib/heroku/client/organizations.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'heroku-api'
require "heroku/client"

class Heroku::Client::Organizations
Expand Down
1 change: 0 additions & 1 deletion lib/heroku/client/pgbackups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ class Heroku::Client::Pgbackups
include Heroku::Helpers

def initialize(uri)
require 'rest_client'
@uri = URI.parse(uri)
end

Expand Down
11 changes: 2 additions & 9 deletions lib/heroku/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,8 @@ def self.prepare_run(cmd, args=[])
end

def self.run(cmd, arguments=[])
begin
object, method = prepare_run(cmd, arguments.dup)
object.send(method)
rescue Interrupt, StandardError, SystemExit => error
# load likely error classes, as they may not be loaded yet due to defered loads
require 'heroku-api'
require 'rest_client'
raise(error)
end
object, method = prepare_run(cmd, arguments.dup)
object.send(method)
rescue Heroku::API::Errors::Unauthorized, RestClient::Unauthorized => e
retry_login = handle_auth_error(e)
retry if retry_login
Expand Down
5 changes: 0 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

require "excon"

# ensure these are around for errors
# as their require is generally deferred
require "heroku-api"
require "rest_client"

require "heroku/cli"
require "rspec"
require "rr"
Expand Down