class Twurl::RequestController
Constants
- INVALID_URI_MESSAGE
- NO_URI_MESSAGE
- OPEN_TIMEOUT_MESSAGE
- READ_TIMEOUT_MESSAGE
Public Instance Methods
dispatch()
click to toggle source
# File lib/twurl/request_controller.rb 9 def dispatch 10 if client.needs_to_authorize? 11 raise Exception, "You need to authorize first." 12 end 13 options.path ||= OAuthClient.rcfile.alias_from_options(options) 14 raise Exception, NO_URI_MESSAGE if options.path.empty? 15 perform_request 16 end
perform_request()
click to toggle source
# File lib/twurl/request_controller.rb 18 def perform_request 19 client.perform_request_from_options(options) { |response| 20 response.read_body { |body| 21 CLI.print options.json_format ? JsonFormatter.format(body) : body 22 } 23 } 24 rescue URI::InvalidURIError 25 CLI.puts INVALID_URI_MESSAGE 26 rescue Net::ReadTimeout 27 CLI.puts READ_TIMEOUT_MESSAGE 28 rescue Net::OpenTimeout 29 CLI.puts OPEN_TIMEOUT_MESSAGE 30 end