status_cat 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -20
  3. data/lib/status_cat/checkers/delayed_job.rb +2 -2
  4. data/lib/status_cat/checkers/fitbit.rb +20 -0
  5. data/lib/status_cat/checkers/profilesio.rb +13 -0
  6. data/lib/status_cat/checkers/send_hub.rb +13 -0
  7. data/lib/status_cat/checkers/twilio.rb +13 -0
  8. data/lib/status_cat/status.rb +1 -1
  9. data/lib/status_cat/version.rb +1 -1
  10. data/lib/status_cat.rb +4 -0
  11. data/spec/controllers/status_cat/status_controller_spec.rb +8 -10
  12. data/spec/coverage_spec.rb +1 -3
  13. data/spec/dummy/config/environments/test.rb +1 -1
  14. data/spec/dummy/db/development.sqlite3 +0 -0
  15. data/spec/dummy/db/test.sqlite3 +0 -0
  16. data/spec/dummy/log/development.log +0 -1232
  17. data/spec/dummy/log/test.log +12344 -6383
  18. data/spec/helpers/status_cat/status_helper_spec.rb +17 -28
  19. data/spec/lib/status_cat/checkers/action_mailer_spec.rb +9 -15
  20. data/spec/lib/status_cat/checkers/active_record_spec.rb +5 -11
  21. data/spec/lib/status_cat/checkers/base_spec.rb +9 -16
  22. data/spec/lib/status_cat/checkers/delayed_job_spec.rb +4 -10
  23. data/spec/lib/status_cat/checkers/fitbit_spec.rb +33 -0
  24. data/spec/lib/status_cat/checkers/profilesio_spec.rb +38 -0
  25. data/spec/lib/status_cat/checkers/s3_spec.rb +1 -3
  26. data/spec/lib/status_cat/checkers/send_hub_spec.rb +33 -0
  27. data/spec/lib/status_cat/checkers/stripe_spec.rb +1 -3
  28. data/spec/lib/status_cat/checkers/twilio_spec.rb +33 -0
  29. data/spec/lib/status_cat/config_spec.rb +36 -29
  30. data/spec/lib/status_cat/engine_spec.rb +1 -4
  31. data/spec/lib/status_cat/status_spec.rb +19 -27
  32. data/spec/lib/status_cat/version_spec.rb +3 -6
  33. data/spec/lib/status_cat_spec.rb +2 -7
  34. data/spec/lib/tasks/status_cat.rake_spec.rb +2 -7
  35. data/spec/mailers/status_cat/status_mailer_spec.rb +9 -13
  36. data/spec/spec_helper.rb +21 -1
  37. data/spec/support/shared/checker.rb +4 -6
  38. data/spec/views/status_cat/status/index.html.erb_spec.rb +3 -5
  39. data/spec/views/status_cat/status_mailer/failure.html.erb_spec.rb +1 -3
  40. data/spec/views/status_cat/status_mailer/failure.text.erb_spec.rb +1 -4
  41. metadata +107 -41
  42. data/spec/data/report.txt +0 -10
  43. data/spec/data/report.txt.tmp +0 -10
  44. data/spec/data/status_report_format.txt +0 -1
  45. data/spec/data/status_report_format.txt.tmp +0 -1
  46. data/spec/dummy/config/passwords.yml +0 -5
  47. data/spec/dummy/db/production.sqlite3 +0 -0
  48. data/spec/dummy/tmp/cache/assets/development/sprockets/0891c389c9f47b48b695b65602d93a57 +0 -0
  49. data/spec/dummy/tmp/cache/assets/development/sprockets/400d7aa6ca317151fe36fc9f02ccfc4e +0 -0
  50. data/spec/dummy/tmp/cache/assets/development/sprockets/40da66d7323888023264d2f06b7525d4 +0 -0
  51. data/spec/dummy/tmp/cache/assets/development/sprockets/4bddf542ba5114155847240380cf6e7c +0 -0
  52. data/spec/dummy/tmp/cache/assets/development/sprockets/572759e0267736e8961ff1fad85cfe47 +0 -0
  53. data/spec/dummy/tmp/cache/assets/development/sprockets/6cec2a8a17b78e61daecff44044e1179 +0 -0
  54. data/spec/dummy/tmp/pids/server.pid +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b882ffa38cb65b30eb750f5d2372d16da99d41f4
4
- data.tar.gz: 227303d64942573f29aba5f35d90a7924fca1273
3
+ metadata.gz: 0ac65c223e10fd528530d66c77a8c4faa08c766f
4
+ data.tar.gz: 1140f72ea64a6300ccff6d24587f911d98ea13f8
5
5
  SHA512:
6
- metadata.gz: bf39488d55b43e4d54fc3111266f34c6fb03a33e8d833ea6e9c2fff1b4376cc1cebc38c4112c9f07e916c730c18aa74ea3aaf79674433be2fd4b27dc05206205
7
- data.tar.gz: 5b74c43a3f6d86aa30fbe03fb2c126d52c5a4949fc6f264b49663562539e4931315cc3e03c7506b27a16b8680e735cbfc381704605bc2af9eab74f525a8d08bb
6
+ metadata.gz: 54b688cdeb93d39a70dd877ec14adeebb209ebed46e6f20bc5cbdcdaa3bfb437afb02e7da42cfd64107c62d1632f3978a4c0a2dba28d02bc7f28ad71cab5c93e
7
+ data.tar.gz: 1be6f957bfb9bf1bbb707920c501c89230ef0e15e105b53a396a21483522de10a7b61307508a87c065d9b90780bb10f4323df9988326adbe9bb6f919c3571d8f
data/README.md CHANGED
@@ -17,6 +17,10 @@ such as:
17
17
  * AWS S3
18
18
  * Delayed Job
19
19
  * Stripe
20
+ * Fitbit
21
+ * Profiles.io
22
+ * SendHub
23
+ * Twilio
20
24
 
21
25
  ## Getting Started
22
26
 
@@ -40,21 +44,22 @@ such as:
40
44
 
41
45
  Status.configure do |config|
42
46
 
43
- config.authenticate_with do
44
- authenticate!
45
- end
47
+ config.authenticate_with do
48
+ authenticate!
49
+ end
46
50
 
47
- config.authorize_with do
48
- authorize!
49
- end
51
+ config.authorize_with do
52
+ authorize!
53
+ end
50
54
 
51
- config.layout = 'admin'
55
+ config.layout = 'admin'
52
56
 
53
- config.noreply = 'noreply@schrodingersbox.com'
54
- config.to = 'ops@schrodingersbox.com'
55
- config.from = 'ops@schrodingersbox.com'
56
- config.subject = "#{Rails.env.upcase} StatusCat Failure"
57
+ config.noreply = 'noreply@schrodingersbox.com'
58
+ config.to = 'ops@schrodingersbox.com'
59
+ config.from = 'ops@schrodingersbox.com'
60
+ config.subject = "#{Rails.env.upcase} StatusCat Failure"
57
61
 
62
+ config.enabled = [ :action_mailer, :active_record ]
58
63
  end
59
64
 
60
65
  ## How To
@@ -150,17 +155,18 @@ Create or add to `config/initializers/status_cat.rb`
150
155
 
151
156
  ## History
152
157
 
153
- Version 0.0.2 = Rails 3 compatible
154
- Version 0.0.3 = Rails 4 compatible
158
+ * Version 0.0.2 = Rails 3 compatible
159
+ * Version 0.0.3 = Rails 4 compatible
155
160
 
156
161
  ## TODO
157
162
 
158
- * Add disk space checker with externally configurable limit
159
- * Add Zencoder checker?
160
- * Add NewRelic checker?
163
+ * Add disk space checker with externally configurable limit
164
+ * Add Zencoder checker?
165
+ * Add NewRelic checker?
161
166
 
162
- * Dynamically create rake tasks for each checker
167
+ * Dynamically create rake tasks for each checker
163
168
 
164
- * Doc
165
- * General checker concept
166
- * Shared spec
169
+ * Doc
170
+ * General checker concept
171
+ * Shared spec
172
+ * Env vars to configure services
@@ -9,12 +9,12 @@ module StatusCat
9
9
  @status = 'delayed_job gem not installed'
10
10
  else
11
11
  @status = fail_on_exception do
12
- sql = 'select count(*) from delayed_jobs'
12
+ sql = 'select count(*) from delayed_jobs where failed_at is null'
13
13
  result = ::ActiveRecord::Base.connection.execute( sql ).first
14
14
  @value = result.is_a?( Hash ) ? result[ 'count' ] : result[ 0 ]
15
15
 
16
16
  expires = 1.day.ago
17
- sql = "select count(*) from delayed_jobs where created_at < '#{expires.to_s( :db )}'"
17
+ sql = "select count(*) from delayed_jobs where created_at < '#{expires.to_s( :db )}' and failed_at is null"
18
18
  result = ::ActiveRecord::Base.connection.execute( sql ).first
19
19
  value = result.is_a?( Hash ) ? result[ 'count' ] : result[ 0 ]
20
20
 
@@ -0,0 +1,20 @@
1
+ module StatusCat
2
+ module Checkers
3
+ class Fitbit < Base
4
+ def initialize
5
+ @value = ENV[ 'FITBIT_CONSUMER_KEY' ]
6
+ @status = fail_on_exception do
7
+ user_info = ::Fitgem::Client.new(
8
+ :consumer_key => ENV[ 'FITBIT_CONSUMER_KEY' ],
9
+ :consumer_secret => ENV[ 'FITBIT_CONSUMER_SECRET' ],
10
+ :token => ENV[ 'FITBIT_TEST_TOKEN' ],
11
+ :secret => ENV[ 'FITBIT_TEST_SECRET' ],
12
+ :user_id => ENV[ 'FITBIT_TEST_USER_ID' ]
13
+ ).user_info
14
+
15
+ user_info[ 'errors' ] ? user_info.inspect : nil
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ module StatusCat
2
+ module Checkers
3
+ class Profilesio < Base
4
+ def initialize
5
+ @value = ENV['PROFILESIO_KEY']
6
+ @status = fail_on_exception do
7
+ response = ::HTTParty.get('https://profiles.io/record/register')
8
+ response.code == 200 ? nil : 'fail'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module StatusCat
2
+ module Checkers
3
+ class SendHub < Base
4
+ def initialize
5
+ @value = ENV[ 'SEND_HUB_NUMBER' ]
6
+ @status = fail_on_exception do
7
+ send_hub = ::SendHub.new( ENV[ 'SEND_HUB_API_KEY' ], ENV[ 'SEND_HUB_NUMBER' ] )
8
+ send_hub.get_contacts ? nil : 'fail'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module StatusCat
2
+ module Checkers
3
+ class Twilio < Base
4
+ def initialize
5
+ @value = ENV[ 'TWILIO_SID' ]
6
+ @status = fail_on_exception do
7
+ twilio = ::Twilio::REST::Client.new( ENV[ 'TWILIO_SID' ], ENV[ 'TWILIO_TOKEN' ] )
8
+ twilio.account.messages.total ? nil : 'fail'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -19,7 +19,7 @@ module StatusCat
19
19
  # Emails ::failed list if it is not empty
20
20
  def self.cron
21
21
  checkers = self.failed
22
- StatusCat::StatusMailer.failure( checkers ).deliver unless checkers.empty?
22
+ StatusCat::StatusMailer.failure( checkers ).deliver_now unless checkers.empty?
23
23
  end
24
24
 
25
25
  # Constructs a checker instance given it's name
@@ -1,3 +1,3 @@
1
1
  module StatusCat
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/status_cat.rb CHANGED
@@ -6,8 +6,12 @@ require 'status_cat/checkers/base'
6
6
  require 'status_cat/checkers/action_mailer'
7
7
  require 'status_cat/checkers/active_record'
8
8
  require 'status_cat/checkers/delayed_job'
9
+ require 'status_cat/checkers/fitbit'
10
+ require 'status_cat/checkers/profilesio'
9
11
  require 'status_cat/checkers/s3'
12
+ require 'status_cat/checkers/send_hub'
10
13
  require 'status_cat/checkers/stripe'
14
+ require 'status_cat/checkers/twilio'
11
15
 
12
16
  module StatusCat
13
17
 
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe StatusCat::StatusController do
4
2
 
5
3
  routes { StatusCat::Engine.routes }
@@ -8,21 +6,23 @@ describe StatusCat::StatusController do
8
6
 
9
7
  it 'gets successfully' do
10
8
  get :index
11
- response.should be_success
9
+ expect( response ).to be_success
12
10
  end
13
11
 
14
12
  it 'assigns @checkers to StatusCat::Status.all' do
15
13
  get :index
16
14
 
17
15
  @checkers = assigns[ :checkers ]
18
- @checkers.should_not be( nil )
19
- @checkers.length.should eql( StatusCat::Status.all.length )
20
- @checkers.each { |checker| checker.should be_a_kind_of( StatusCat::Checkers::Base ) }
16
+ expect( @checkers ).to_not be( nil )
17
+ expect( @checkers.length ).to eql( StatusCat::Status.all.length )
18
+ @checkers.each { |checker| expect( checker ).to be_a_kind_of( StatusCat::Checkers::Base ) }
21
19
  end
22
20
 
23
21
  it 'uses the configured before authentication filter' do
24
- expect( @controller ).to receive( :instance_eval ).with( &StatusCat.config.authenticate_with )
25
- expect( @controller ).to receive( :instance_eval ).with( &StatusCat.config.authorize_with )
22
+ allow( Rails.env ).to receive( :test? ).and_return( false )
23
+ expect( controller ).to receive( :authenticate! )
24
+ expect( controller ).to receive( :authorize! )
25
+
26
26
  get :index
27
27
  end
28
28
 
@@ -30,7 +30,5 @@ describe StatusCat::StatusController do
30
30
  get :index
31
31
  expect( response ).to render_template( StatusCat.config.layout )
32
32
  end
33
-
34
33
  end
35
-
36
34
  end
@@ -3,8 +3,6 @@
3
3
  # Ensures every eligible file has a corresponding spec
4
4
  ################################################################################
5
5
 
6
- require 'spec_helper'
7
-
8
6
  describe 'coverage' do
9
7
 
10
8
  it 'has a spec for every file' do
@@ -14,7 +12,7 @@ describe 'coverage' do
14
12
  ].each do |dir|
15
13
  Dir.glob( File.join( ENGINE_ROOT, dir, '**', '*.{rb,erb,rake}' ) ) do |path|
16
14
  path = path.sub( /#{ENGINE_ROOT}\//, '' )
17
- path.should have_a_spec
15
+ expect( path ).to have_a_spec
18
16
  end
19
17
  end
20
18
  end
@@ -8,7 +8,7 @@ Dummy::Application.configure do
8
8
  config.cache_classes = true
9
9
 
10
10
  # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
11
+ config.serve_static_files = true
12
12
  config.static_cache_control = "public, max-age=3600"
13
13
 
14
14
  # Show full error reports and disable caching
Binary file
Binary file