Class: RooOnRails::Checks::Papertrail::Token
- Defined in:
- lib/roo_on_rails/checks/papertrail/token.rb
Overview
Output context:
-
papertrail.client: a connected Papertrail client
Instance Method Summary collapse
- #call ⇒ Object
- #fix ⇒ Object
-
#initialize(papertrail_client: nil, **options) ⇒ Token
constructor
A new instance of Token.
- #intro ⇒ Object
Methods inherited from Base
Methods included from Helpers
Constructor Details
#initialize(papertrail_client: nil, **options) ⇒ Token
Returns a new instance of Token.
15 16 17 18 |
# File 'lib/roo_on_rails/checks/papertrail/token.rb', line 15 def initialize(papertrail_client: nil, **) @papertrail_client = papertrail_client || PapertrailClient super(**) end |
Instance Method Details
#call ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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.})" end pass "connected to Papertrail's API" context.papertrail!.client = client end |
#fix ⇒ Object
40 41 42 43 44 45 46 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/roo_on_rails/checks/papertrail/token.rb', line 20 def intro 'Obtaining Papertrail auth token...' end |