arkaan 0.6.1 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a31199bbce66658b871208d0b4225f242842912
4
- data.tar.gz: b1c6d940b08a683cfeffd51858bf9177ae9cd3a5
3
+ metadata.gz: 4fbb8f59c892ce91e7c016d76b3bd36a666a251c
4
+ data.tar.gz: 1a185db4880c3d0986cd70b462c96e2f7eaf446e
5
5
  SHA512:
6
- metadata.gz: a2769ae73df7c8280fd6f32e0f23f4b9b5d7a365dbad5c23f9e5df4cb751726145ab065e44074c4e7b498cd9833ef8388143a14ea11ed1838084bb6b5fd75df9
7
- data.tar.gz: 008b88cd408d6cb199cf8dc005f8d7113bc9d5ee6de9e294b79896f8636562641df8cb27d8460ea69de507a0788dc8e52435ef23b551278bed0287bcea7393b1
6
+ metadata.gz: 2cacca5e1e77eb380d2f8847281524ce5b70f87cd49d98a02dae68d2c8f98f44615157fbc36fb08d4ce7c3d2defed8123d20caadee44ea620c79c71c9c5e4c21
7
+ data.tar.gz: e181c90141dd6a63d81be1ef2517e7a9f0e3bbdceef64877958a379957fee5a6e182ea630cfcf23c91cdc7f93287cd2ef313f9b48ebefabb1812696d04131555
@@ -3,5 +3,6 @@ module Arkaan
3
3
  # @author Vincent Courtois <courtois.vincent@outlook.com>
4
4
  module Utils
5
5
  autoload :Controller, 'arkaan/utils/controller'
6
+ autoload :Seeder , 'arkaan/utils/seeder'
6
7
  end
7
8
  end
@@ -0,0 +1,25 @@
1
+ module Arkaan
2
+ module Utils
3
+ # This class loads the necessary data in the database if they don't exist yet.
4
+ # @author Vincent Courtois <courtois.vincent@outlook.com>
5
+ class Seeder
6
+ include Singleton
7
+
8
+ # Creates the service if it does not exist, and the instance if it does not exist.
9
+ # @return [Arkaan::Monitoring::Service] the created, or found, service corresponding to this micro-service.
10
+ def create_service(key)
11
+ service = Arkaan::Monitoring::Service.where(key: key).first
12
+
13
+ if service.nil?
14
+ service = Arkaan::Monitoring::Service.create!(key: key, path: "/#{key}", premium: true, active: true)
15
+ end
16
+
17
+ if service.instances.where(url: ENV['SERVICE_URL']).first.nil?
18
+ Arkaan::Monitoring::Instance.create!(url: ENV['SERVICE_URL'], running: true, service: service, active: true)
19
+ end
20
+
21
+ return service
22
+ end
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkaan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Courtois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2017-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -209,6 +209,7 @@ files:
209
209
  - lib/arkaan/permissions/right.rb
210
210
  - lib/arkaan/utils.rb
211
211
  - lib/arkaan/utils/controller.rb
212
+ - lib/arkaan/utils/seeder.rb
212
213
  homepage: https://rubygems.org/gems/arkaan
213
214
  licenses:
214
215
  - MIT