Class: Slipsquare::Middleware::InjectClient

Inherits:
Base
  • Object
show all
Defined in:
lib/slipsquare/middleware/inject_client.rb

Constant Summary

Constants inherited from Base

Base::CLEAR, Base::GREEN, Base::RED, Base::YELLOW

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Slipsquare::Middleware::Base

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/slipsquare/middleware/inject_client.rb', line 7

def call(env)

  Dropbox::API::Config.app_key    = env['config'].app_key
  Dropbox::API::Config.app_secret = env['config'].secret_key
  Dropbox::API::Config.mode       = 'dropbox'

  begin
    client = Dropbox::API::Client.new(:token  => env['config'].app_token, :secret =>  env['config'].app_secret)
  rescue Dropbox::API::Error => e
    say "Connection to Dropbox failed (#{e})", :red
    exit 1
  end

  env['dropbox-client'] = client

  @app.call(env)
end