Sha256: 36e77d00f2d2894c51cb06fece398f18847367207e1fe34f7d81bd03c3c55863
Contents?: true
Size: 1.49 KB
Versions: 28
Compression:
Stored size: 1.49 KB
Contents
require 'roo_on_rails/checks/base' require 'roo_on_rails/checks/git/origin' require 'roo_on_rails/papertrail_client' require 'io/console' require 'shellwords' module RooOnRails module Checks module Papertrail # Output context: # - papertrail.client: a connected Papertrail client class Token < Base requires Git::Origin def initialize(papertrail_client: nil, **options) @papertrail_client = papertrail_client || PapertrailClient super(**options) end def intro 'Obtaining Papertrail auth token...' end 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 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 end end end end
Version data entries
28 entries across 28 versions & 1 rubygems