Class: AlacrityRails::Diagnostic
- Inherits:
-
Object
- Object
- AlacrityRails::Diagnostic
- Defined in:
- lib/alacrity-rails/diagnostic.rb
Class Method Summary collapse
Instance Method Summary collapse
- #api_token_present ⇒ Object
- #logger ⇒ Object
- #middleware_appears_first ⇒ Object
- #middleware_present ⇒ Object
- #run ⇒ Object
- #run_check(check_name) ⇒ Object
- #valid_api_token ⇒ Object
Class Method Details
.run ⇒ Object
3 |
# File 'lib/alacrity-rails/diagnostic.rb', line 3 def self.run; new.run end |
Instance Method Details
#api_token_present ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/alacrity-rails/diagnostic.rb', line 32 def api_token_present [ Config.api_token.present?, %< The API token could not be found in the server environment. You can find it on https://alacrityapp.com then set it in your server config as `ALACRITY_API_TOKEN`. > ] end |
#logger ⇒ Object
5 |
# File 'lib/alacrity-rails/diagnostic.rb', line 5 def logger; @logger ||= Logger.new(STDOUT) end |
#middleware_appears_first ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/alacrity-rails/diagnostic.rb', line 66 def middleware_appears_first [ Rails.application.config.middleware.first == (AlacrityRails::Middleware), %< The AlacrityRails::Middleware is not first in your middleware stack. Anything appearing above it will not be included in metrics tracking. #{Rails.application.config.middleware.map(&:inspect).to_yaml} > ] end |
#middleware_present ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'lib/alacrity-rails/diagnostic.rb', line 56 def middleware_present [ Rails.application.config.middleware.include?(AlacrityRails::Middleware), %< The AlacrityRails::Middleware is absent from your middleware stack. Make sure your application is not overriding the middleware stack in an initializer. > ] end |
#run ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/alacrity-rails/diagnostic.rb', line 7 def run run_check :api_token_present run_check :valid_api_token run_check :middleware_present run_check :middleware_appears_first puts puts end |
#run_check(check_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/alacrity-rails/diagnostic.rb', line 17 def run_check(check_name) logger << "CHECK: #{check_name.to_s.humanize}..." successful, = public_send(check_name) if successful logger << "PASSED\n" else logger << "FAILED\n" logger << logger << exit end end |
#valid_api_token ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/alacrity-rails/diagnostic.rb', line 43 def valid_api_token response = Client.transmit(Transaction::ConnectionTest.new) [ response.value.code == '200', %< Oh no! Its seems like we have a problem! #{JSON.parse(response.value.body)['message']} > ] end |