module Hub::GitHubAPI::Verbose

Constants

DUMP_HEADERS

Public Instance Methods

dump_body(obj) click to toggle source
# File lib/hub/github_api.rb, line 407
def dump_body(obj)
  verbose_puts obj.body if obj.body
end
dump_headers(obj, indent) click to toggle source
# File lib/hub/github_api.rb, line 413
def dump_headers(obj, indent)
  DUMP_HEADERS.each do |header|
    if value = obj[header]
      verbose_puts '%s%s: %s' % [
        indent,
        header,
        value.sub(/^(basic|token) (.+)/, '\1 [REDACTED]'),
      ]
    end
  end
end
dump_request_info(req, url) click to toggle source
# File lib/hub/github_api.rb, line 390
def dump_request_info(req, url)
  verbose_puts "> %s %s://%s%s" % [
    req.method.to_s.upcase,
    url.scheme,
    url.host,
    req.path,
  ]
  dump_headers(req, '> ')
  dump_body(req)
end
dump_response_info(res) click to toggle source
# File lib/hub/github_api.rb, line 401
def dump_response_info(res)
  verbose_puts "< HTTP %s" % res.status
  dump_headers(res, '< ')
  dump_body(res)
end
finalize_request(req, url) click to toggle source
Calls superclass method
# File lib/hub/github_api.rb, line 374
def finalize_request(req, url)
  super
  dump_request_info(req, url) if verbose?
end
perform_request(*) click to toggle source
Calls superclass method
# File lib/hub/github_api.rb, line 379
def perform_request(*)
  res = super
  dump_response_info(res) if verbose?
  res
end
verbose_puts(msg) click to toggle source
# File lib/hub/github_api.rb, line 385
def verbose_puts(msg)
  msg = "\e[36m%s\e[m" % msg if $stderr.tty?
  $stderr.puts msg
end