healthier 0.1.2 → 0.1.4
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.
- checksums.yaml +4 -4
- data/README.md +45 -0
- data/app/services/basic_auth_service.rb +1 -1
- data/lib/generators/healthier/config_generator.rb +31 -0
- data/lib/healthier/engine.rb +3 -7
- data/lib/healthier/version.rb +1 -1
- data/lib/healthier.rb +6 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 711f2ef8a3f208c3e4a4cc710fc86f73ff049a1734e0726caca32ef2d3c597f0
|
4
|
+
data.tar.gz: ceb81192506fb5d7132840da224ac48bdb6f31d216dc2867da3d2afca0bd5576
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c2b4a07809bdb88f6bd292ba9b284c5b6612ca525c0929341d4757aa01a6b98a56c3c0e60a160859e8e1b93d7c41cf13dfe9f1946997ec038b15d46b3516b8f
|
7
|
+
data.tar.gz: 8b260ec426e1544f745843ede0eaa38719aa08dd75636aa6a839a65412b7308d8bc2f0a90eba950779b76571d6b8117b9cb73de389861f24f6307fe335cc4731
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# Healthier
|
2
|
+
|
2
3
|
Short description and motivation.
|
3
4
|
|
4
5
|
## Usage
|
6
|
+
|
5
7
|
How to use my plugin.
|
6
8
|
|
7
9
|
## Installation
|
10
|
+
|
8
11
|
Add this line to your application's Gemfile:
|
9
12
|
|
10
13
|
```ruby
|
@@ -12,17 +15,59 @@ gem "healthier"
|
|
12
15
|
```
|
13
16
|
|
14
17
|
And then execute:
|
18
|
+
|
15
19
|
```bash
|
16
20
|
$ bundle
|
17
21
|
```
|
18
22
|
|
19
23
|
Or install it yourself as:
|
24
|
+
|
20
25
|
```bash
|
21
26
|
$ gem install healthier
|
22
27
|
```
|
23
28
|
|
29
|
+
# Installer:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
rails generate healthier:config
|
33
|
+
```
|
34
|
+
|
35
|
+
This will generate these two files:
|
36
|
+
1. config/healthier.yml
|
37
|
+
```yaml
|
38
|
+
---
|
39
|
+
healthier:
|
40
|
+
depends_on:
|
41
|
+
# Uncomment accordingly
|
42
|
+
# - name: 'postgresql'
|
43
|
+
# - name: 'mongodb'
|
44
|
+
# - name: 'redis'
|
45
|
+
# - name: 'rabbitmq'
|
46
|
+
```
|
47
|
+
2. config/initializers/healthier.rb
|
48
|
+
```ruby
|
49
|
+
Healthier.setup do |config|
|
50
|
+
config.depends_on = config.healthier.call
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
In your application routes.rb file:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
mount Healthier::Engine => '/healthier'
|
58
|
+
```
|
59
|
+
|
60
|
+
ENVs for basic authentication:
|
61
|
+
|
62
|
+
```bash
|
63
|
+
USERNAME: 'demouser'
|
64
|
+
PASSWORD: 'demouser@2023'
|
65
|
+
```
|
66
|
+
|
24
67
|
## Contributing
|
68
|
+
|
25
69
|
Contribution directions go here.
|
26
70
|
|
27
71
|
## License
|
72
|
+
|
28
73
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Healthier
|
4
|
+
# Generates a healthier.yml
|
5
|
+
class ConfigGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('templates', __dir__)
|
7
|
+
|
8
|
+
def create_healthier_file
|
9
|
+
create_file 'config/initializers/healthier.rb', <<~RUBY
|
10
|
+
# frozen_string_literal: true
|
11
|
+
|
12
|
+
Healthier.setup do |config|
|
13
|
+
config.depends_on = config.healthier.call
|
14
|
+
end
|
15
|
+
RUBY
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_healthier_yaml
|
19
|
+
create_file 'config/healthier.yml', <<~YAML
|
20
|
+
---
|
21
|
+
healthier:
|
22
|
+
# Uncomment accordingly
|
23
|
+
depends_on:
|
24
|
+
# - name: 'postgresql'
|
25
|
+
# - name: 'mongodb'
|
26
|
+
# - name: 'redis'
|
27
|
+
# - name: 'rabbitmq'
|
28
|
+
YAML
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/healthier/engine.rb
CHANGED
@@ -31,17 +31,13 @@ module Healthier
|
|
31
31
|
FAILURE = 400
|
32
32
|
|
33
33
|
def ping!
|
34
|
-
conf['depends_on'].each_with_object({}) do |
|
35
|
-
obj[
|
34
|
+
conf['depends_on'].each_with_object({}) do |dependant, obj|
|
35
|
+
obj[dependant['name']] = ping_it(dependant['name'])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def conf
|
40
|
-
@conf ||=
|
41
|
-
end
|
42
|
-
|
43
|
-
def config_path
|
44
|
-
Rails.root.join('config/healthier/services.yml')
|
40
|
+
@conf ||= Healthier.depends_on['healthier']
|
45
41
|
end
|
46
42
|
|
47
43
|
def ping_it(service)
|
data/lib/healthier/version.rb
CHANGED
data/lib/healthier.rb
CHANGED
@@ -5,5 +5,10 @@ require 'healthier/engine'
|
|
5
5
|
|
6
6
|
# Healthier
|
7
7
|
module Healthier
|
8
|
-
|
8
|
+
def self.setup
|
9
|
+
yield self
|
10
|
+
end
|
11
|
+
|
12
|
+
mattr_accessor :healthier, default: -> { YAML.load_file(Rails.root.join('config/healthier.yml')) }
|
13
|
+
mattr_accessor :depends_on, default: {}
|
9
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: healthier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nima Yonten
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- app/controllers/healthier/checks_controller.rb
|
39
39
|
- app/services/basic_auth_service.rb
|
40
40
|
- config/routes.rb
|
41
|
+
- lib/generators/healthier/config_generator.rb
|
41
42
|
- lib/healthier.rb
|
42
43
|
- lib/healthier/engine.rb
|
43
44
|
- lib/healthier/version.rb
|