okcomputer-checks 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f8fe4e2977b1bf89c003d9c98e9924ebfc5953872592d678cb4df4a3d4e7a9b
4
- data.tar.gz: 8fbda4d43ee4dc061e6ec523c6fc6184010d19b55dc35b339aa62e3e6ce77fdf
3
+ metadata.gz: 41eda4e9586e4a32ff6970f2e0e137fadca066b2a66a35fd8d183acd57eee2f1
4
+ data.tar.gz: 9f63356d73fb5763bf2f5c43bf09a27cdd70e0e00b51c4e0fa718ef5614b52df
5
5
  SHA512:
6
- metadata.gz: 3cf97da455d7e78cdb9891bc9d33a33704ee4577fb73d9fef8008cfe1755428ee9381cefc5805e754673902349c54aab357d7f47acda3bad3ae149989fade7ce
7
- data.tar.gz: 327f6fac075c99ef6fd72cb48c555167021754f7b5552d4d48f4afdec821f9eb04a3376943d0d8f18a19124c145dc132311e0a9f35a485481853c0f31802c495
6
+ metadata.gz: 02f6393c2a8582ef23d0f130fcf6f540d8a080be2d51260b8f7c7b962661366ddbefa92adec04e1b84662558422426c01e5b4220a563b358524209223400085d
7
+ data.tar.gz: 1d20ed20e739de95fbc8f5fc4cbf2b7cbb2b8f9695a1e29f7e4791f2e72e50ec2c50447cfe7873f28c501d93c892c3f77a66c1b562c15c404e54fdc3556969ca
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0 (2023-09-10)
4
+
5
+
6
+ ### Features
7
+
8
+ * Force gem rebuild ([e78fc31](https://github.com/itsmechlark/okcomputer-checks/commit/e78fc31497c62b4bca02f6e537b25e8536e49bcb))
9
+ * Support Rails 6.1 & 7.0, & Ruby 3 ([16a82c4](https://github.com/itsmechlark/okcomputer-checks/commit/16a82c49b43975c9bd47734414f0956f50ce43e1))
10
+
11
+
12
+ ### Miscellaneous
13
+
14
+ * Added codespell ignore ([e80815b](https://github.com/itsmechlark/okcomputer-checks/commit/e80815b0ffae9bc5020f371c1f8191abbda1385b))
15
+ * Fixes rubocop warnings ([0f9a91e](https://github.com/itsmechlark/okcomputer-checks/commit/0f9a91ecda60b79529639f0758d37e58ec9a9410))
16
+ * Update gem information ([24ce807](https://github.com/itsmechlark/okcomputer-checks/commit/24ce807a7692f40f7252b7d1c7dbe2fb9ca321cd))
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday'
4
- require 'ok_computer/built_in_checks/http_check'
3
+ require "faraday"
4
+ require "ok_computer/built_in_checks/http_check"
5
5
 
6
6
  module OkComputer
7
7
  class AlgoliaCheck < HttpCheck
8
8
  StatusFailed = Class.new(StandardError)
9
9
 
10
- STATUS_URL = 'https://status.algolia.com/1/status'
10
+ STATUS_URL = "https://status.algolia.com/1/status"
11
11
 
12
12
  attr_accessor :app_id, :api_key
13
13
 
@@ -21,9 +21,9 @@ module OkComputer
21
21
  # Public: Return the status of the Monitoring check
22
22
  def check
23
23
  status, body = perform_request
24
- raise(StatusFailed, body) unless status == 200 && body['status'].values.all? { |v| v == 'operational' }
24
+ raise(StatusFailed, body) unless status == 200 && body["status"].values.all?("operational")
25
25
 
26
- mark_message('Monitoring check successful')
26
+ mark_message("Monitoring check successful")
27
27
  rescue StandardError => e
28
28
  mark_message("Error: '#{e}'")
29
29
  mark_failure
@@ -31,9 +31,9 @@ module OkComputer
31
31
 
32
32
  def perform_request
33
33
  response = Faraday.get(url, request: { timeout: request_timeout }) do |req|
34
- req.headers['Content-Type'] = 'application/json'
35
- req.headers['X-Algolia-API-Key'] = api_key
36
- req.headers['X-Algolia-Application-Id'] = app_id
34
+ req.headers["Content-Type"] = "application/json"
35
+ req.headers["X-Algolia-API-Key"] = api_key
36
+ req.headers["X-Algolia-Application-Id"] = app_id
37
37
  end
38
38
 
39
39
  [response.status, MultiJson.decode(response.body)]
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'faraday'
4
- require 'ok_computer/built_in_checks/http_check'
3
+ require "faraday"
4
+ require "ok_computer/built_in_checks/http_check"
5
5
 
6
6
  module OkComputer
7
7
  class HubspotCheck < HttpCheck
8
8
  StatusFailed = Class.new(StandardError)
9
9
 
10
- STATUS_URL = 'https://api.hubapi.com/integrations/v1/limit/daily'
10
+ STATUS_URL = "https://api.hubapi.com/integrations/v1/limit/daily"
11
11
 
12
12
  attr_accessor :api_key
13
13
 
@@ -22,7 +22,7 @@ module OkComputer
22
22
  status, body = perform_request
23
23
  raise(StatusFailed, body) unless status == 200
24
24
 
25
- mark_message('Rate-Limit check successful')
25
+ mark_message("Rate-Limit check successful")
26
26
  rescue StandardError => e
27
27
  mark_message("Error: '#{e}'")
28
28
  mark_failure
@@ -30,8 +30,8 @@ module OkComputer
30
30
 
31
31
  def perform_request
32
32
  response = Faraday.get(url, request: { timeout: request_timeout }) do |req|
33
- req.headers['Content-Type'] = 'application/json'
34
- req.params['hapikey'] = api_key
33
+ req.headers["Content-Type"] = "application/json"
34
+ req.params["hapikey"] = api_key
35
35
  end
36
36
 
37
37
  [response.status, MultiJson.decode(response.body)]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'nexmo'
3
+ require "nexmo"
4
4
 
5
5
  module OkComputer
6
6
  class NexmoCheck < Check
@@ -8,11 +8,11 @@ module OkComputer
8
8
 
9
9
  attr_accessor :client
10
10
 
11
- def initialize(client: nil, api_key: nil, api_secret: nil, signature_secret: nil)
11
+ def initialize(client: nil, api_key: nil, api_secret: nil, signature_secret: nil) # rubocop:disable Lint/MissingSuper
12
12
  client ||= Nexmo::Client.new(
13
13
  api_key: api_key,
14
14
  api_secret: api_secret,
15
- signature_secret: signature_secret
15
+ signature_secret: signature_secret,
16
16
  )
17
17
 
18
18
  self.client = client
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pusher'
3
+ require "pusher"
4
4
 
5
5
  module OkComputer
6
6
  class PusherCheck < Check
@@ -8,13 +8,13 @@ module OkComputer
8
8
 
9
9
  attr_accessor :client
10
10
 
11
- def initialize(client: nil, app_id: nil, app_key: nil, app_secret: nil, app_cluster: nil)
11
+ def initialize(client: nil, app_id: nil, app_key: nil, app_secret: nil, app_cluster: nil) # rubocop:disable Lint/MissingSuper
12
12
  client ||= Pusher::Client.new(
13
13
  app_id: app_id,
14
14
  key: app_key,
15
15
  secret: app_secret,
16
16
  cluster: app_cluster,
17
- use_tls: true
17
+ use_tls: true,
18
18
  )
19
19
 
20
20
  self.client = client
@@ -23,14 +23,14 @@ module OkComputer
23
23
  # Public: Return the status of the Channels check
24
24
  def check
25
25
  perform_request
26
- mark_message('Channels check successful')
26
+ mark_message("Channels check successful")
27
27
  rescue StandardError => e
28
28
  mark_message("Error: '#{e}'")
29
29
  mark_failure
30
30
  end
31
31
 
32
32
  def perform_request
33
- client.get('/channels')
33
+ client.get("/channels")
34
34
  rescue StandardError => e
35
35
  raise(ChannelError, e)
36
36
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/core_ext/module/delegation'
3
+ require "active_support/core_ext/module/delegation"
4
4
 
5
- require 'ok_computer/check_collection'
6
- require 'ok_computer/registry'
5
+ require "ok_computer/check_collection"
6
+ require "ok_computer/registry"
7
7
 
8
8
  module OkComputer
9
9
  # :nodoc:
@@ -13,7 +13,7 @@ module OkComputer
13
13
 
14
14
  delegate_missing_to :collection
15
15
 
16
- def initialize(collection = nil)
16
+ def initialize(collection = nil) # rubocop:disable Lint/MissingSuper
17
17
  self.collection = if collection.is_a?(CheckCollection)
18
18
  collection
19
19
  elsif collection
@@ -29,23 +29,23 @@ module OkComputer
29
29
  register(collection_name, checks)
30
30
  end
31
31
 
32
- def add_optional(klass_or_check, check_name, *args)
33
- add(OptionalCheck.new(process_check(klass_or_check, *args)), check_name)
32
+ def add_optional(klass_or_check, check_name, **args)
33
+ add(OptionalCheck.new(process_check(klass_or_check, **args)), check_name)
34
34
  end
35
35
 
36
- def add(klass_or_check, check_name, *args)
37
- register(check_name, process_check(klass_or_check, *args))
36
+ def add(klass_or_check, check_name, **args)
37
+ register(check_name, process_check(klass_or_check, **args))
38
38
  end
39
39
 
40
40
  private
41
41
 
42
- def process_check(klass_or_check, *args)
42
+ def process_check(klass_or_check, **args)
43
43
  return klass_or_check if [OptionalCheck, Check, CheckCollection].any? { |k| klass_or_check.is_a?(k) }
44
44
 
45
- build_check(klass_or_check, *args)
45
+ build_check(klass_or_check, **args)
46
46
  end
47
47
 
48
- def build_check(klass, *args)
48
+ def build_check(klass, **args)
49
49
  unless klass.is_a?(Class)
50
50
  begin
51
51
  klass = OkComputer.const_get("#{klass}_check".camelize)
@@ -53,7 +53,7 @@ module OkComputer
53
53
  raise LoadError, "Could not register #{klass.inspect}."
54
54
  end
55
55
  end
56
- klass.new(*args)
56
+ klass.new(**args)
57
57
  end
58
58
  end
59
59
  end
@@ -2,6 +2,12 @@
2
2
 
3
3
  module OkComputer
4
4
  module Checks
5
- VERSION = '1.1.1'
5
+ VERSION = "1.2.0"
6
+
7
+ class << self
8
+ def gem_version
9
+ Gem::Version.new(VERSION)
10
+ end
11
+ end
6
12
  end
7
13
  end
@@ -1,24 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_support/dependencies/autoload'
3
+ require "active_support/dependencies/autoload"
4
4
 
5
- require 'ok_computer/check'
6
- require 'ok_computer/checks/registry'
5
+ require "ok_computer/check"
6
+ require "ok_computer/checks/registry"
7
7
 
8
8
  module OkComputer
9
9
  extend ActiveSupport::Autoload
10
10
 
11
- autoload :AlgoliaCheck, 'ok_computer/checks/algolia_check'
12
- autoload :HubspotCheck, 'ok_computer/checks/hubspot_check'
13
- autoload :NexmoCheck, 'ok_computer/checks/nexmo_check'
14
- autoload :PusherCheck, 'ok_computer/checks/pusher_check'
11
+ autoload :AlgoliaCheck, "ok_computer/checks/algolia_check"
12
+ autoload :HubspotCheck, "ok_computer/checks/hubspot_check"
13
+ autoload :NexmoCheck, "ok_computer/checks/nexmo_check"
14
+ autoload :PusherCheck, "ok_computer/checks/pusher_check"
15
15
 
16
16
  # :nodoc:
17
17
  module Checks
18
- def self.register(collection = nil)
19
- registry = Registry.new(collection)
20
- yield registry if block_given?
21
- registry
18
+ class << self
19
+ def register(collection = nil)
20
+ registry = Registry.new(collection)
21
+ yield registry if block_given?
22
+ registry
23
+ end
22
24
  end
23
25
  end
24
26
  end
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'ok_computer/checks'
3
+ require "ok_computer/checks"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okcomputer-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - First Circle Engineering
7
+ - John Chlark Sumatra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2023-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -54,6 +54,20 @@ dependencies:
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codecov
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,21 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: codecov
84
+ name: code-scanning-rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: dotenv
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - ">="
@@ -123,19 +151,33 @@ dependencies:
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
153
  - !ruby/object:Gem::Dependency
126
- name: rspec-rails
154
+ name: rake
127
155
  requirement: !ruby/object:Gem::Requirement
128
156
  requirements:
129
157
  - - "~>"
130
158
  - !ruby/object:Gem::Version
131
- version: '3.0'
159
+ version: '13.0'
132
160
  type: :development
133
161
  prerelease: false
134
162
  version_requirements: !ruby/object:Gem::Requirement
135
163
  requirements:
136
164
  - - "~>"
137
165
  - !ruby/object:Gem::Version
138
- version: '3.0'
166
+ version: '13.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec-rails
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: rubocop-performance
141
183
  requirement: !ruby/object:Gem::Requirement
@@ -165,7 +207,7 @@ dependencies:
165
207
  - !ruby/object:Gem::Version
166
208
  version: '0'
167
209
  - !ruby/object:Gem::Dependency
168
- name: rubocop-shopify
210
+ name: rubocop-rake
169
211
  requirement: !ruby/object:Gem::Requirement
170
212
  requirements:
171
213
  - - ">="
@@ -179,7 +221,7 @@ dependencies:
179
221
  - !ruby/object:Gem::Version
180
222
  version: '0'
181
223
  - !ruby/object:Gem::Dependency
182
- name: simplecov
224
+ name: rubocop-rspec
183
225
  requirement: !ruby/object:Gem::Requirement
184
226
  requirements:
185
227
  - - ">="
@@ -193,19 +235,47 @@ dependencies:
193
235
  - !ruby/object:Gem::Version
194
236
  version: '0'
195
237
  - !ruby/object:Gem::Dependency
196
- name: sqlite3
238
+ name: rubocop-shopify
197
239
  requirement: !ruby/object:Gem::Requirement
198
240
  requirements:
199
241
  - - "~>"
200
242
  - !ruby/object:Gem::Version
201
- version: 1.3.6
243
+ version: '2.14'
202
244
  type: :development
203
245
  prerelease: false
204
246
  version_requirements: !ruby/object:Gem::Requirement
205
247
  requirements:
206
248
  - - "~>"
207
249
  - !ruby/object:Gem::Version
208
- version: 1.3.6
250
+ version: '2.14'
251
+ - !ruby/object:Gem::Dependency
252
+ name: simplecov
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: 0.21.2
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ">="
263
+ - !ruby/object:Gem::Version
264
+ version: 0.21.2
265
+ - !ruby/object:Gem::Dependency
266
+ name: simplecov-lcov
267
+ requirement: !ruby/object:Gem::Requirement
268
+ requirements:
269
+ - - ">="
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ type: :development
273
+ prerelease: false
274
+ version_requirements: !ruby/object:Gem::Requirement
275
+ requirements:
276
+ - - ">="
277
+ - !ruby/object:Gem::Version
278
+ version: '0'
209
279
  - !ruby/object:Gem::Dependency
210
280
  name: webmock
211
281
  requirement: !ruby/object:Gem::Requirement
@@ -221,22 +291,17 @@ dependencies:
221
291
  - !ruby/object:Gem::Version
222
292
  version: '0'
223
293
  description: "\n Collection health-check for okcomputer\n "
224
- email: tech@firstcircle.com
294
+ email:
295
+ - clark@sumatra.com.ph
225
296
  executables: []
226
297
  extensions: []
227
298
  extra_rdoc_files:
228
299
  - LICENSE
229
300
  - README.md
230
301
  files:
231
- - ".rubocop.yml"
232
- - Appraisals
233
- - Gemfile
302
+ - CHANGELOG.md
234
303
  - LICENSE
235
304
  - README.md
236
- - gemfiles/rails_5.1_stable.gemfile
237
- - gemfiles/rails_5.2_stable.gemfile
238
- - gemfiles/rails_6.0_stable.gemfile
239
- - gemfiles/rails_edge.gemfile
240
305
  - lib/ok_computer/checks.rb
241
306
  - lib/ok_computer/checks/algolia_check.rb
242
307
  - lib/ok_computer/checks/hubspot_check.rb
@@ -245,29 +310,15 @@ files:
245
310
  - lib/ok_computer/checks/registry.rb
246
311
  - lib/ok_computer/checks/version.rb
247
312
  - lib/okcomputer-checks.rb
248
- - okcomputer-checks.gemspec
249
- - spec/dummy/config.ru
250
- - spec/dummy/config/application.rb
251
- - spec/dummy/config/boot.rb
252
- - spec/dummy/config/database.yml
253
- - spec/dummy/config/environment.rb
254
- - spec/dummy/config/initializers/okcomputer.rb
255
- - spec/dummy/config/routes.rb
256
- - spec/dummy/log/.keep
257
- - spec/ok_computer/algolia_check_spec.rb
258
- - spec/ok_computer/checks_spec.rb
259
- - spec/ok_computer/hubspot_check_spec.rb
260
- - spec/ok_computer/nexmo_check_spec.rb
261
- - spec/ok_computer/pusher_check_spec.rb
262
- - spec/rails_helper.rb
263
- - spec/spec_helper.rb
264
- - spec/support/check_matcher.rb
265
- homepage: https://github.com/carabao-capital/okcomputer-checks
313
+ homepage: https://github.com/itsmechlark/okcomputer-checks
266
314
  licenses:
267
315
  - MIT
268
316
  metadata:
269
- source_code_uri: https://github.com/carabao-capital/okcomputer-checks/tree/v1.1.1
270
- allowed_push_host: https://rubygems.org
317
+ homepage_uri: https://github.com/itsmechlark/okcomputer-checks
318
+ changelog_uri: https://github.com/itsmechlark/okcomputer-checks/releases/tag/v1.2.0
319
+ source_code_uri: https://github.com/itsmechlark/okcomputer-checks/tree/v1.2.0
320
+ bug_tracker_uri: https://github.com/itsmechlark/okcomputer-checks/issues
321
+ github_repo: https://github.com/itsmechlark/okcomputer-checks
271
322
  post_install_message:
272
323
  rdoc_options: []
273
324
  require_paths:
@@ -276,31 +327,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
276
327
  requirements:
277
328
  - - ">="
278
329
  - !ruby/object:Gem::Version
279
- version: 2.6.5
330
+ version: 2.7.0
280
331
  required_rubygems_version: !ruby/object:Gem::Requirement
281
332
  requirements:
282
333
  - - ">="
283
334
  - !ruby/object:Gem::Version
284
335
  version: '0'
285
336
  requirements: []
286
- rubygems_version: 3.0.8
337
+ rubygems_version: 3.2.33
287
338
  signing_key:
288
339
  specification_version: 4
289
340
  summary: Collection health-check for okcomputer
290
- test_files:
291
- - spec/dummy/config.ru
292
- - spec/dummy/config/application.rb
293
- - spec/dummy/config/boot.rb
294
- - spec/dummy/config/database.yml
295
- - spec/dummy/config/environment.rb
296
- - spec/dummy/config/initializers/okcomputer.rb
297
- - spec/dummy/config/routes.rb
298
- - spec/dummy/log/.keep
299
- - spec/ok_computer/algolia_check_spec.rb
300
- - spec/ok_computer/checks_spec.rb
301
- - spec/ok_computer/hubspot_check_spec.rb
302
- - spec/ok_computer/nexmo_check_spec.rb
303
- - spec/ok_computer/pusher_check_spec.rb
304
- - spec/rails_helper.rb
305
- - spec/spec_helper.rb
306
- - spec/support/check_matcher.rb
341
+ test_files: []
data/.rubocop.yml DELETED
@@ -1,27 +0,0 @@
1
- inherit_gem:
2
- rubocop-shopify: rubocop.yml
3
-
4
- AllCops:
5
- DisabledByDefault: false
6
- TargetRubyVersion: 2.6
7
- Exclude:
8
- - gemfiles/*
9
- - spec/dummy/**/*
10
-
11
- Lint/MissingSuper:
12
- Exclude:
13
- - lib/ok_computer/checks/*
14
-
15
- Metrics/BlockLength:
16
- Exclude:
17
- - spec/ok_computer/*
18
- - okcomputer-checks.gemspec
19
-
20
- Naming/FileName:
21
- Exclude:
22
- - lib/okcomputer-checks.rb
23
-
24
- ## TODOs
25
-
26
- Style/Documentation:
27
- Enabled: false
data/Appraisals DELETED
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- appraise 'rails-5.1-stable' do
4
- gem 'rails', github: 'rails/rails', branch: '5-1-stable'
5
- end
6
-
7
- appraise 'rails-5.2-stable' do
8
- gem 'rails', github: 'rails/rails', branch: '5-2-stable'
9
- end
10
-
11
- appraise 'rails-6.0-stable' do
12
- gem 'rails', github: 'rails/rails', branch: '6-0-stable'
13
- gem 'sqlite3', '~> 1.4'
14
- end
15
-
16
- appraise 'rails-edge' do
17
- gem 'rails', github: 'rails/rails', branch: :master
18
- gem 'arel', github: 'rails/arel', branch: :master
19
- gem 'sqlite3', '~> 1.4'
20
- end
data/Gemfile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- gem 'rails'
6
- gem 'sprockets', '~> 3.0'
7
-
8
- gemspec
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", github: "rails/rails", branch: "5-1-stable"
6
- gem "sprockets", "~> 3.0"
7
-
8
- gemspec path: "../"
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", github: "rails/rails", branch: "5-2-stable"
6
- gem "sprockets", "~> 3.0"
7
-
8
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", github: "rails/rails", branch: "6-0-stable"
6
- gem "sprockets", "~> 3.0"
7
- gem "sqlite3", "~> 1.4"
8
-
9
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "rails", github: "rails/rails", branch: :master
6
- gem "sprockets", "~> 3.0"
7
- gem "arel", github: "rails/arel", branch: :master
8
- gem "sqlite3", "~> 1.4"
9
-
10
- gemspec path: "../"
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.push(File.expand_path('lib', __dir__))
4
-
5
- # Maintain your gem's version:
6
- require 'ok_computer/checks/version'
7
-
8
- # Describe your gem and declare its dependencies:
9
- Gem::Specification.new do |s|
10
- s.name = 'okcomputer-checks'
11
- s.version = OkComputer::Checks::VERSION
12
- s.author = 'First Circle Engineering'
13
- s.email = 'tech@firstcircle.com'
14
- s.license = 'MIT'
15
- s.homepage = 'https://github.com/carabao-capital/okcomputer-checks'
16
- s.summary = 'Collection health-check for okcomputer'
17
- s.description = %(
18
- Collection health-check for okcomputer
19
- )
20
-
21
- s.files = %x(git ls-files).split("\n") - %w[.gitignore .travis.yml .ruby-version]
22
- s.test_files = %x(git ls-files -- spec/*).split("\n")
23
- s.require_paths = ['lib']
24
- s.extra_rdoc_files = %w[LICENSE README.md]
25
-
26
- s.metadata = {
27
- 'source_code_uri' => "https://github.com/carabao-capital/okcomputer-checks/tree/v#{s.version}",
28
- 'allowed_push_host' => 'https://rubygems.org',
29
- }
30
-
31
- s.required_ruby_version = '>= 2.6.5'
32
-
33
- s.add_dependency('activesupport')
34
- s.add_dependency('faraday')
35
- s.add_dependency('okcomputer')
36
-
37
- s.add_development_dependency('appraisal')
38
- s.add_development_dependency('codecov')
39
- s.add_development_dependency('em-http-request')
40
- s.add_development_dependency('nexmo')
41
- s.add_development_dependency('pusher')
42
- s.add_development_dependency('rspec-rails', '~> 3.0')
43
- s.add_development_dependency('rubocop-performance')
44
- s.add_development_dependency('rubocop-rails')
45
- s.add_development_dependency('rubocop-shopify')
46
- s.add_development_dependency('simplecov')
47
- s.add_development_dependency('sqlite3', '~> 1.3.6')
48
- s.add_development_dependency('webmock')
49
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path('boot', __dir__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require
6
- require 'okcomputer'
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- config.encoding = 'utf-8'
11
- config.filter_parameters += [:password]
12
- config.active_support.escape_html_entities_in_json = true
13
- config.assets.enabled = false
14
- config.secret_key_base = '78987c1cc6dc799c6baf50cadf73700ae861e5d81d28b2ec702b6e168d0cf3c8ad7be699f1d0f98e5b2b563ca70d9516b9c2a66184de39516c09a19aa2d96817'
15
- config.session_store(:cookie_store, key: '_dummy_session')
16
- config.cache_classes = true
17
- config.consider_all_requests_local = true
18
- config.action_controller.perform_caching = false
19
- config.action_dispatch.show_exceptions = false
20
- config.action_controller.allow_forgery_protection = false
21
- config.action_mailer.delivery_method = :test
22
- config.active_support.deprecation = :stderr
23
- config.eager_load = false
24
- end
25
- end
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- gemfile = File.expand_path('../../../Gemfile', __dir__)
3
-
4
- if File.exist?(gemfile)
5
- ENV['BUNDLE_GEMFILE'] = gemfile
6
- require 'bundler'
7
- Bundler.setup
8
- end
9
-
10
- $:.unshift(File.expand_path('../../../lib', __dir__))
@@ -1,5 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- database: ":memory:"
4
- pool: 5
5
- timeout: 5000
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('application', __dir__)
3
-
4
- # Initialize the rails application
5
- Dummy::Application.initialize!
@@ -1 +0,0 @@
1
- OkComputer.require_authentication('foo', 'bar')
@@ -1,2 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- end
data/spec/dummy/config.ru DELETED
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('config/environment', __dir__)
4
- run Dummy::Application
data/spec/dummy/log/.keep DELETED
File without changes
@@ -1,48 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe(OkComputer::AlgoliaCheck) do
6
- let(:app_id) { 'APPID' }
7
- let(:api_key) { 'apikey' }
8
- let(:response) { { status: 200, body: MultiJson.encode({}) } }
9
-
10
- subject(:check) { described_class.new(app_id: app_id, api_key: api_key) }
11
-
12
- before { stub_request(:get, %r{/1/status}).to_return(response) }
13
-
14
- context('when successful') do
15
- let(:response) do
16
- {
17
- status: 200,
18
- body: MultiJson.encode(status: { 'c4-fr' => 'operational', 'c2-eu' => 'operational' }),
19
- }
20
- end
21
-
22
- it { is_expected.to(be_successful_check) }
23
- it { is_expected.to(have_message('Monitoring check successful')) }
24
- end
25
-
26
- context('when 401 fails') do
27
- let(:response) do
28
- {
29
- status: 401,
30
- body: MultiJson.encode(message: 'Invalid Application-Id or API-Key'),
31
- }
32
- end
33
-
34
- it { is_expected.not_to(be_successful_check) }
35
- it { is_expected.to(have_message("Error: '{\"message\"=>\"Invalid Application-Id or API-Key\"}'")) }
36
- end
37
-
38
- context('when not operational') do
39
- let(:response) do
40
- {
41
- status: 200,
42
- body: MultiJson.encode(status: { 'c4-fr' => 'degraded_performance', 'c2-eu' => 'major_outage' }),
43
- }
44
- end
45
-
46
- it { is_expected.not_to(be_successful_check) }
47
- end
48
- end
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe(OkComputer::Checks) do
6
- let(:response) do
7
- {
8
- status: 200,
9
- body: MultiJson.encode(status: { 'c4-fr' => 'operational' }),
10
- }
11
- end
12
-
13
- subject(:collection) { described_class.register }
14
-
15
- before { stub_request(:get, %r{/1/status}).to_return(response) }
16
-
17
- describe('.register') do
18
- let(:app_id) { 'APPID' }
19
- let(:api_key) { 'apikey' }
20
-
21
- context('when klass') do
22
- before do
23
- described_class.register do |r|
24
- r.add(:algolia, :search, app_id: app_id, api_key: api_key)
25
- end
26
- collection.run
27
- end
28
-
29
- it { expect(collection.fetch(:search)).to(be_present) }
30
- it { is_expected.to(be_success) }
31
- end
32
-
33
- context('when check') do
34
- let(:check) { OkComputer::AlgoliaCheck.new(app_id: app_id, api_key: api_key) }
35
-
36
- before do
37
- described_class.register do |r|
38
- r.add(check, :search)
39
- end
40
- collection.run
41
- end
42
-
43
- it { expect(collection.fetch(:search)).to(be_present) }
44
- it { is_expected.to(be_success) }
45
- end
46
-
47
- context('when check collection') do
48
- let(:check) { OkComputer::AlgoliaCheck.new(app_id: app_id, api_key: api_key) }
49
- let(:check_collection) { OkComputer::CheckCollection.new(:custom) }
50
-
51
- before do
52
- check_collection.register(:search, check)
53
- described_class.register do |r|
54
- r.add(check_collection, :custom)
55
- end
56
- collection.run
57
- end
58
-
59
- it { expect(collection.fetch(:custom)).to(be_present) }
60
- it { expect(collection.fetch(:search)).to(be_present) }
61
- it { is_expected.to(be_success) }
62
- end
63
-
64
- describe('#add_collection') do
65
- subject(:search) { collection.fetch(:search) }
66
-
67
- before do
68
- described_class.register do |r|
69
- r.add_collection(:search) do |s|
70
- s.add(:algolia, :algolia, app_id: app_id, api_key: api_key)
71
- end
72
- end
73
- collection.run
74
- end
75
-
76
- it { expect(search.fetch(:algolia)).to(be_present) }
77
- it { is_expected.to(be_success) }
78
- end
79
-
80
- describe('#add_optional') do
81
- before do
82
- described_class.register do |r|
83
- r.add_optional(:algolia, :search, app_id: app_id, api_key: api_key)
84
- end
85
- collection.run
86
- end
87
-
88
- it { expect(collection.fetch(:search)).to(be_present) }
89
- it { is_expected.to(be_success) }
90
- end
91
- end
92
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe(OkComputer::HubspotCheck) do
6
- let(:api_key) { 'apikey' }
7
- let(:response) { { status: 200, body: MultiJson.encode({}) } }
8
-
9
- subject(:check) { described_class.new(api_key: api_key) }
10
-
11
- before { stub_request(:get, %r{/integrations/v1/limit/daily}).to_return(response) }
12
-
13
- context('when successful') do
14
- it { is_expected.to(be_successful_check) }
15
- it { is_expected.to(have_message('Rate-Limit check successful')) }
16
- end
17
-
18
- context('when 401 fails') do
19
- let(:response) { { status: 401, body: MultiJson.encode({}) } }
20
-
21
- it { is_expected.not_to(be_successful_check) }
22
- it { is_expected.to(have_message("Error: '{}'")) }
23
- end
24
-
25
- context('when rate-limit exceeded') do
26
- let(:response) do
27
- {
28
- status: 429,
29
- body: MultiJson.encode(status: 'error'),
30
- }
31
- end
32
-
33
- it { is_expected.not_to(be_successful_check) }
34
- end
35
- end
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe(OkComputer::NexmoCheck) do
6
- let(:api_key) { 'nexmo-api-key' }
7
- let(:api_secret) { 'nexmo-api-secret' }
8
- let(:signature_secret) { 'nexmo-signature-secret' }
9
- let(:client) do
10
- Nexmo::Client.new(
11
- api_key: api_key,
12
- api_secret: api_secret,
13
- signature_secret: signature_secret
14
- )
15
- end
16
- let(:headers) { { 'Content-Type' => 'application/json;charset=utf-8' } }
17
- let(:response) { { status: 200, body: MultiJson.encode({}), headers: headers } }
18
-
19
- subject(:check) { described_class.new(client: client) }
20
-
21
- before { stub_request(:get, %r{/account/get-balance}).to_return(response) }
22
-
23
- context('when successful') do
24
- let(:response) do
25
- {
26
- status: 200,
27
- body: MultiJson.encode(value: 10.28, autoReload: false),
28
- headers: headers,
29
- }
30
- end
31
-
32
- it { is_expected.to(be_successful_check) }
33
- it { is_expected.to(have_message('Balance 10.28 check successful')) }
34
-
35
- context('when not client') do
36
- subject(:check) do
37
- described_class.new(
38
- api_key: api_key,
39
- api_secret: api_secret,
40
- signature_secret: signature_secret
41
- )
42
- end
43
-
44
- it { is_expected.to(be_successful_check) }
45
- end
46
- end
47
-
48
- context('when 401 fails') do
49
- let(:response) { { status: 401, body: MultiJson.encode({}), headers: headers } }
50
-
51
- it { is_expected.not_to(be_successful_check) }
52
- it { is_expected.to(have_message("Error: 'Nexmo::AuthenticationError'")) }
53
- end
54
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails_helper'
4
-
5
- RSpec.describe(OkComputer::PusherCheck) do
6
- let(:client) do
7
- Pusher::Client.new({
8
- app_id: '20',
9
- key: '12345678900000001',
10
- secret: '12345678900000001',
11
- host: 'api.pusherapp.com',
12
- port: 80,
13
- })
14
- end
15
- let(:response) { { status: 200, body: MultiJson.encode({}) } }
16
-
17
- subject(:check) { described_class.new(client: client) }
18
-
19
- before { stub_request(:get, %r{/apps/20/channels}).to_return(response) }
20
-
21
- context('when successful') do
22
- let(:response) do
23
- {
24
- status: 200,
25
- body: MultiJson.encode(channels: { channel1: {}, channel2: {} }),
26
- }
27
- end
28
-
29
- it { is_expected.to(be_successful_check) }
30
- it { is_expected.to(have_message('Channels check successful')) }
31
-
32
- context('when not client') do
33
- subject(:check) do
34
- described_class.new(
35
- app_id: '20',
36
- app_key: '12345678900000001',
37
- app_secret: '12345678900000001'
38
- )
39
- end
40
-
41
- it { is_expected.to(be_successful_check) }
42
- end
43
- end
44
-
45
- context('when 401 fails') do
46
- let(:response) { { status: 401, body: MultiJson.encode({}) } }
47
-
48
- it { is_expected.not_to(be_successful_check) }
49
- it { is_expected.to(have_message("Error: '{}'")) }
50
- end
51
-
52
- context('when 403 fails') do
53
- let(:response) { { status: 403, body: MultiJson.encode({}) } }
54
-
55
- it { is_expected.not_to(be_successful_check) }
56
- it { is_expected.to(have_message("Error: 'Unknown error (status code 403): {}'")) }
57
- end
58
- end
data/spec/rails_helper.rb DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Configure Rails Environment
4
- ENV['RAILS_ENV'] = 'test'
5
-
6
- require 'spec_helper'
7
- require File.expand_path('dummy/config/environment.rb', __dir__)
8
- require 'rspec/rails'
9
-
10
- Rails.backtrace_cleaner.remove_silencers!
11
-
12
- RSpec.configure do |config|
13
- config.use_transactional_fixtures = true
14
- config.infer_spec_type_from_file_location!
15
- end
data/spec/spec_helper.rb DELETED
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'simplecov'
4
- SimpleCov.start('rails') do
5
- add_filter '/spec/'
6
- end
7
- if ENV['CI'] == 'true'
8
- require 'codecov'
9
- SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
- end
11
-
12
- require 'bundler/setup'
13
- require 'em-http' # As of webmock 1.4.0, em-http must be loaded first
14
- require 'multi_json'
15
- require 'webmock/rspec'
16
-
17
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
18
-
19
- RSpec.configure do |config|
20
- config.run_all_when_everything_filtered = true
21
- config.filter_run(:focus)
22
-
23
- config.expect_with(:rspec) do |expectations|
24
- expectations.syntax = :expect
25
- end
26
-
27
- config.mock_with(:rspec) do |mocks|
28
- mocks.syntax = :expect
29
- end
30
-
31
- config.order = :random
32
-
33
- config.before(:each) do
34
- WebMock.reset!
35
- WebMock.disable_net_connect!
36
- end
37
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # RSpec::Matchers.define :be_a_multiple_of do |expected|
4
- # match do |actual|
5
- # actual % expected == 0
6
- # end
7
- # end
8
- # 9.should be_a_multiple_of(3)
9
- # expect(9).to be_a_multiple_of(3)
10
-
11
- RSpec::Matchers.define(:have_message) do |message|
12
- match do |actual|
13
- actual.check
14
- actual.message.include?(message)
15
- end
16
-
17
- failure_message do |actual|
18
- "expected '#{actual.message}' to include '#{message}'"
19
- end
20
-
21
- failure_message_when_negated do |actual|
22
- "expected '#{actual.message}' to not include '#{message}'"
23
- end
24
- end
25
-
26
- RSpec::Matchers.define(:be_successful_check) do |_message|
27
- match do |actual|
28
- actual.check
29
- actual.success?
30
- end
31
-
32
- failure_message do |actual|
33
- "expected #{actual.inspect} to be successful"
34
- end
35
-
36
- failure_message_when_negated do |actual|
37
- "expected '#{actual}' to not be successful"
38
- end
39
- end