healthier 0.1.2 → 0.1.4

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: a6edf83e9f94bfec7c31425fb9da3271736b0e088abffcf6075b51e9b3384776
4
- data.tar.gz: 6a61b806971ab5aaea9684f8b5e29bfadd16ad60c7a4106ff1406863e6ef9278
3
+ metadata.gz: 711f2ef8a3f208c3e4a4cc710fc86f73ff049a1734e0726caca32ef2d3c597f0
4
+ data.tar.gz: ceb81192506fb5d7132840da224ac48bdb6f31d216dc2867da3d2afca0bd5576
5
5
  SHA512:
6
- metadata.gz: dbdca601bebf47f6a3e8002d9cb0194bf19269a9f17f6a5833f72922fc371775a34ff018d7c30530ac8318c0bdcb3a914ef8a66c6c2d4eff4f56285faef8bd59
7
- data.tar.gz: b205cd863d5c0cadadcdab264d893e5c489aa65e37e6c5399041894cc645832e077d279231ff6a5d7b2fc1daeb58da270571008257e67ab92003893da3f0de33
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).
@@ -4,7 +4,7 @@
4
4
  class BasicAuthService
5
5
  def self.authorize(controller)
6
6
  controller.authenticate_or_request_with_http_basic do |username, password|
7
- username == 'healthier' && password == 'Selise23'
7
+ username == ENV['USERNAME'] && password == ENV['PASSWORD']
8
8
  end
9
9
  end
10
10
  end
@@ -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
@@ -31,17 +31,13 @@ module Healthier
31
31
  FAILURE = 400
32
32
 
33
33
  def ping!
34
- conf['depends_on'].each_with_object({}) do |service, obj|
35
- obj[service['name']] = ping_it(service['name'])
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 ||= YAML.load_file(config_path)['healthier']
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)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Healthier
4
4
  # MAJOR.MINOR.PATCH
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.4'
6
6
  end
data/lib/healthier.rb CHANGED
@@ -5,5 +5,10 @@ require 'healthier/engine'
5
5
 
6
6
  # Healthier
7
7
  module Healthier
8
- # Your code goes here...
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.2
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-03 00:00:00.000000000 Z
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