active_status 0.1.0 → 1.0.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: d73120fdb2c6678c393901193462d336ee9f610cd14337efd0303719d0c9badc
4
- data.tar.gz: a5bbe644b5e4c2656753beba09858263d31263890288b26b6b68b464bae98254
3
+ metadata.gz: c098e00eae5672f4d3c5a4ab072c27731cf075a6aebadf1eb3a5cd95fc5ac56b
4
+ data.tar.gz: 4e2ed1c690f77302447b313ab1667d87b6aab8e21ceaaa082492ffd245ed4647
5
5
  SHA512:
6
- metadata.gz: 403e849b33d8228139fd0a49c927e1347c63d659bad078156a0aa423a4246bef76820c78274ec37e9dd72b501f4e8f68ddb7ff6d9427989dc305b0e09c6759fa
7
- data.tar.gz: 7958be692b57f4d01d47630b3c5c6823f25b5ff388971d28f7a745d50235a5ed7440361e0391bcd4cb99a553359e544da83cf715651ef4b6b8f77d83fc32581e
6
+ metadata.gz: 366c8d4c6d849541d61409a2e277ed828d644256d40352eee71370b6828de5e12f3db6bccaa7f1bd886c05ce035a24ad8f045908ed7a2de8e941815c522d6016
7
+ data.tar.gz: a1205f0ef564523f1af180699cd9cf334a9d08ef65e6abd4f2bf42137f480abed83d9b1666907ffe68e0e6310bb24edea8dc16fa879ae10ca61ed7fdd4739a57
@@ -5,9 +5,9 @@ module ActiveStatus
5
5
  report.build
6
6
 
7
7
  if report.success?
8
- head ActiveStatus.configuration.success
8
+ head ActiveStatus.config.success_code
9
9
  else
10
- render json: report.errors, status: ActiveStatus.configuration.error
10
+ render json: report.errors, status: ActiveStatus.config.error_code
11
11
  end
12
12
  end
13
13
  end
@@ -1,20 +1,15 @@
1
1
  require 'active_status/error'
2
- require 'active_status/engine'
3
2
  require 'active_status/report'
3
+ require 'active_status/version'
4
4
  require 'active_status/configuration'
5
+ require 'active_status/engine' if defined?(Rails::Engine)
5
6
 
6
7
  module ActiveStatus
7
- class << self
8
- attr_accessor :configuration
8
+ def self.config
9
+ @config ||= Configuration.new
9
10
  end
10
11
 
11
12
  def self.configure
12
- self.configuration ||= Configuration.new
13
-
14
- yield configuration
15
- end
16
-
17
- def self.reconfigure
18
- self.configuration = Configuration.new
13
+ yield config
19
14
  end
20
15
  end
@@ -1,18 +1,20 @@
1
1
  module ActiveStatus
2
2
  class Configuration
3
- attr_accessor :checks, :error, :success, :verbose
3
+ attr_accessor :error_code, :success_code, :verbose, :checks
4
4
 
5
5
  def initialize
6
- self.checks = []
7
- self.error = 503
8
- self.success = 200
9
- self.verbose = false
6
+ reset!
10
7
  end
11
8
 
12
- def check(name, &block)
13
- checks << name
9
+ def reset!
10
+ @checks = {}
11
+ @verbose = false
12
+ @error_code = 503
13
+ @success_code = 200
14
+ end
14
15
 
15
- Report.define_check(name, block)
16
+ def check(name, &block)
17
+ @checks[name] = block
16
18
  end
17
19
  end
18
20
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveStatus
2
- class Engine < ::Rails::Engine
2
+ class Engine < Rails::Engine
3
3
  isolate_namespace ActiveStatus
4
4
  end
5
5
  end
@@ -2,15 +2,15 @@ module ActiveStatus
2
2
  class Error
3
3
  attr_accessor :name, :error, :message
4
4
 
5
- def initialize(name, error, message)
6
- self.name = name
7
- self.error = error.name
8
- self.message = message&.squish
5
+ def initialize(name, error, message = nil)
6
+ @name = name
7
+ @error = error
8
+ @message = message
9
9
  end
10
10
 
11
11
  def as_json(_ = nil)
12
12
  hash = { name: name, error: error }
13
- return hash unless ActiveStatus.configuration.verbose
13
+ return hash unless ActiveStatus.config.verbose
14
14
 
15
15
  hash.merge({ message: message })
16
16
  end
@@ -6,16 +6,14 @@ module ActiveStatus
6
6
  @errors = []
7
7
  end
8
8
 
9
- def self.define_check(name, body)
10
- define_method(name, body)
11
- end
12
-
13
9
  def build
14
- ActiveStatus.configuration.checks.each do |check|
10
+ ActiveStatus.config.checks.each do |check, method|
15
11
  begin
16
- send(check)
12
+ success = method.call
13
+
14
+ add_error(Error.new(check, 'failure')) unless success
17
15
  rescue StandardError => e
18
- @errors << Error.new(check, e.class, e.message)
16
+ add_error(Error.new(check, e.class.name, e.message))
19
17
  end
20
18
  end
21
19
  end
@@ -23,5 +21,9 @@ module ActiveStatus
23
21
  def success?
24
22
  @errors.empty?
25
23
  end
24
+
25
+ def add_error(error)
26
+ @errors << error
27
+ end
26
28
  end
27
29
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveStatus
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  ActiveStatus.configure do |config|
2
- # config.success = 200
3
- # config.error = 503
4
- # config.verbose = false
2
+ # config.verbose = false
3
+ # config.error_code = 503
4
+ # config.success_code = 200
5
5
 
6
6
  # Example for checking database connection
7
7
  #
metadata CHANGED
@@ -1,57 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_status
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muhammad Usman
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-25 00:00:00.000000000 Z
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rails
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '5.2'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '5.2'
27
- - !ruby/object:Gem::Dependency
28
- name: appraisal
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.3'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.3'
41
- - !ruby/object:Gem::Dependency
42
- name: simplecov
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 0.17.1
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 0.17.1
55
13
  - !ruby/object:Gem::Dependency
56
14
  name: rake
57
15
  requirement: !ruby/object:Gem::Requirement
@@ -73,65 +31,53 @@ dependencies:
73
31
  - !ruby/object:Gem::Version
74
32
  version: 13.0.1
75
33
  - !ruby/object:Gem::Dependency
76
- name: sqlite3
34
+ name: rspec
77
35
  requirement: !ruby/object:Gem::Requirement
78
36
  requirements:
79
37
  - - "~>"
80
38
  - !ruby/object:Gem::Version
81
- version: '1.4'
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: 1.4.2
39
+ version: '3.10'
85
40
  type: :development
86
41
  prerelease: false
87
42
  version_requirements: !ruby/object:Gem::Requirement
88
43
  requirements:
89
44
  - - "~>"
90
45
  - !ruby/object:Gem::Version
91
- version: '1.4'
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: 1.4.2
46
+ version: '3.10'
95
47
  - !ruby/object:Gem::Dependency
96
- name: rspec-rails
48
+ name: rubocop-packaging
97
49
  requirement: !ruby/object:Gem::Requirement
98
50
  requirements:
99
51
  - - "~>"
100
52
  - !ruby/object:Gem::Version
101
- version: '4.0'
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: 4.0.1
53
+ version: 0.5.1
105
54
  type: :development
106
55
  prerelease: false
107
56
  version_requirements: !ruby/object:Gem::Requirement
108
57
  requirements:
109
58
  - - "~>"
110
59
  - !ruby/object:Gem::Version
111
- version: '4.0'
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- version: 4.0.1
60
+ version: 0.5.1
115
61
  - !ruby/object:Gem::Dependency
116
- name: rubocop-rails
62
+ name: rubocop-performance
117
63
  requirement: !ruby/object:Gem::Requirement
118
64
  requirements:
119
65
  - - "~>"
120
66
  - !ruby/object:Gem::Version
121
- version: '2.8'
67
+ version: '1.8'
122
68
  - - ">="
123
69
  - !ruby/object:Gem::Version
124
- version: 2.8.1
70
+ version: 1.8.1
125
71
  type: :development
126
72
  prerelease: false
127
73
  version_requirements: !ruby/object:Gem::Requirement
128
74
  requirements:
129
75
  - - "~>"
130
76
  - !ruby/object:Gem::Version
131
- version: '2.8'
77
+ version: '1.8'
132
78
  - - ">="
133
79
  - !ruby/object:Gem::Version
134
- version: 2.8.1
80
+ version: 1.8.1
135
81
  - !ruby/object:Gem::Dependency
136
82
  name: rubocop-rspec
137
83
  requirement: !ruby/object:Gem::Requirement
@@ -153,25 +99,19 @@ dependencies:
153
99
  - !ruby/object:Gem::Version
154
100
  version: 1.44.1
155
101
  - !ruby/object:Gem::Dependency
156
- name: rubocop-performance
102
+ name: simplecov
157
103
  requirement: !ruby/object:Gem::Requirement
158
104
  requirements:
159
105
  - - "~>"
160
106
  - !ruby/object:Gem::Version
161
- version: '1.8'
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- version: 1.8.1
107
+ version: 0.17.1
165
108
  type: :development
166
109
  prerelease: false
167
110
  version_requirements: !ruby/object:Gem::Requirement
168
111
  requirements:
169
112
  - - "~>"
170
113
  - !ruby/object:Gem::Version
171
- version: '1.8'
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- version: 1.8.1
114
+ version: 0.17.1
175
115
  description: Description of RailsStatusCheck.
176
116
  email:
177
117
  - uxman.sherwani@gmail.com
@@ -198,7 +138,7 @@ metadata:
198
138
  homepage_uri: https://github.com/uxxman/active_status
199
139
  source_code_uri: https://github.com/uxxman/active_status
200
140
  changelog_uri: https://github.com/uxxman/active_status/releases
201
- post_install_message:
141
+ post_install_message:
202
142
  rdoc_options: []
203
143
  require_paths:
204
144
  - lib
@@ -213,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
153
  - !ruby/object:Gem::Version
214
154
  version: '0'
215
155
  requirements: []
216
- rubygems_version: 3.1.2
217
- signing_key:
156
+ rubygems_version: 3.2.3
157
+ signing_key:
218
158
  specification_version: 4
219
159
  summary: Summary of RailsStatusCheck.
220
160
  test_files: []