okcomputer-checks 1.0.0 → 1.1.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: f08b3ef15b8e6a67e2cbedc17b6baf74353dce27f1823727d00a58adeca766b9
4
- data.tar.gz: 515adfddf900ebb319b84534ed565824f6523414919dc6a3ba8dacf666f5cbb1
3
+ metadata.gz: d3f6daa10543667d831f916643cd8509bd71267cf9027a4ca5e2455a424dabc2
4
+ data.tar.gz: e39221047f08e96a9d15ba478a204dc4dcd2a4cdab789fff63cc5cb50ede5d97
5
5
  SHA512:
6
- metadata.gz: eeb1ce14eb840282329501590b401b9f51d27763fc78b1f5d4899de0e7afed562df1403c50c0bb50999b48b4ef4424fab38a9e51e04dd505e36a226142e9702c
7
- data.tar.gz: 7a77a7dc936f07d0658bb80c9d7233059e1148b8ae5d3058381e26f82d714224f709e2e2c1f77b5a9272fd7993abbcb9168f0a880b052df78c9e18fca1e146a2
6
+ metadata.gz: 6fececbd15ed6ccb3a0ce20c49c624c8377a0213804682992acd17250c6ac17ac52f93a2d9c4f15a7311a0aa9051344d46b17ae02813d07a924c82d0a10d445e
7
+ data.tar.gz: 9879e6cda942bdad1b32de1aba99d4110fe6baeb8dc41cf90f135d09c6af73ffd32ec69fa28176f1738f908b5429bc6e50694cd8feea1b80e48fe9a3c2d564bd
@@ -23,18 +23,28 @@ module OkComputer
23
23
  end
24
24
  end
25
25
 
26
- def add(klass_or_check, check_name, *args)
27
- check = if klass_or_check.is_a?(CheckCollection) || klass_or_check.is_a?(Check)
28
- klass_or_check
29
- else
30
- build_check(klass_or_check, *args)
31
- end
26
+ def add_collection(collection_name, &block)
27
+ checks = CheckCollection.new(collection_name)
28
+ Checks.register(checks, &block)
29
+ register(collection_name, checks)
30
+ end
31
+
32
+ def add_optional(klass_or_check, check_name, *args)
33
+ add(OptionalCheck.new(process_check(klass_or_check, *args)), check_name)
34
+ end
32
35
 
33
- collection.register(check_name, check)
36
+ def add(klass_or_check, check_name, *args)
37
+ register(check_name, process_check(klass_or_check, *args))
34
38
  end
35
39
 
36
40
  private
37
41
 
42
+ def process_check(klass_or_check, *args)
43
+ return klass_or_check if [OptionalCheck, Check, CheckCollection].any? { |k| klass_or_check.is_a?(k) }
44
+
45
+ build_check(klass_or_check, *args)
46
+ end
47
+
38
48
  def build_check(klass, *args)
39
49
  unless klass.is_a?(Class)
40
50
  begin
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OkComputer
4
4
  module Checks
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
@@ -60,5 +60,33 @@ RSpec.describe(OkComputer::Checks) do
60
60
  it { expect(collection.fetch(:search)).to(be_present) }
61
61
  it { is_expected.to(be_success) }
62
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
63
91
  end
64
92
  end
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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - First Circle Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-13 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -266,7 +266,7 @@ homepage: https://github.com/carabao-capital/okcomputer-checks
266
266
  licenses:
267
267
  - MIT
268
268
  metadata:
269
- source_code_uri: https://github.com/carabao-capital/okcomputer-checks/tree/v1.0.0
269
+ source_code_uri: https://github.com/carabao-capital/okcomputer-checks/tree/v1.1.0
270
270
  allowed_push_host: https://rubygems.org
271
271
  post_install_message:
272
272
  rdoc_options: []
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  - !ruby/object:Gem::Version
284
284
  version: '0'
285
285
  requirements: []
286
- rubygems_version: 3.0.6
286
+ rubygems_version: 3.0.8
287
287
  signing_key:
288
288
  specification_version: 4
289
289
  summary: Collection health-check for okcomputer