class RooOnRails::Checks::Papertrail::Token

Output context:

Public Class Methods

new(papertrail_client: nil, **options) click to toggle source
Calls superclass method RooOnRails::Checks::Base::new
# File lib/roo_on_rails/checks/papertrail/token.rb, line 15
def initialize(papertrail_client: nil, **options)
  @papertrail_client = papertrail_client || PapertrailClient
  super(**options)
end

Public Instance Methods

call() click to toggle source
# File lib/roo_on_rails/checks/papertrail/token.rb, line 24
def call
  status, token = shell.run 'git config papertrail.token'
  fail! 'no Papertrail API token configured' if token.strip.empty? || !status
  token.strip!

  client = @papertrail_client.new(token: token)
  begin
    client.list_destinations
  rescue Faraday::ClientError => e
    fail! "connecting to Papertrail failed (#{e.message})"
  end

  pass "connected to Papertrail's API"
  context.papertrail!.client = client
end
fix() click to toggle source
# File lib/roo_on_rails/checks/papertrail/token.rb, line 40
def fix
  say 'Enter your Papertrail API token:'
  say 'This can be found at https://papertrailapp.com/account/profile'
  say '(the token will not be echoed on the terminal; paste and press enter)'
  token = IO.console.getpass.strip
  system "git config papertrail.token #{Shellwords.shellescape token}"
end
intro() click to toggle source
# File lib/roo_on_rails/checks/papertrail/token.rb, line 20
def intro
  'Obtaining Papertrail auth token...'
end