arkaan 0.10.20 → 0.10.21
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/lib/arkaan.rb +2 -0
- data/lib/arkaan/decorators.rb +7 -0
- data/lib/arkaan/decorators/service.rb +37 -0
- data/lib/arkaan/factories.rb +7 -0
- data/lib/arkaan/factories/services.rb +17 -0
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9e5590c7b5776567dfca8179a55c9ea24ddd76c
|
4
|
+
data.tar.gz: 359cd55594d85a2146c2b3bcbbea688b8a83f503
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d9d612b8ae8dabb4ed92c673daa203dae96984cb7758b4c69641ebac359589787bf22c4874923d4d717c2a12690b82e945e570874cc8f99e1edaadd73856734
|
7
|
+
data.tar.gz: c969f7ebef770b1ddf1f3820a3f8f36916e27b5f6b48be70e003b2204b36b4af540ff45bcb9859f54d08556972d2dc8ed7edaa81dcf2ff59d419c94cae40f6f4
|
data/lib/arkaan.rb
CHANGED
@@ -13,6 +13,8 @@ module Arkaan
|
|
13
13
|
autoload :Campaign , 'arkaan/campaign'
|
14
14
|
autoload :Campaigns , 'arkaan/campaigns'
|
15
15
|
autoload :Concerns , 'arkaan/concerns'
|
16
|
+
autoload :Dacorators , 'arkaan/decorators'
|
17
|
+
autoload :Phone , 'arkaan/factories'
|
16
18
|
autoload :Monitoring , 'arkaan/monitoring'
|
17
19
|
autoload :OAuth , 'arkaan/oauth'
|
18
20
|
autoload :Permissions , 'arkaan/permissions'
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Decorators
|
3
|
+
# Decorator for a service, providing methods to make requests on it.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
class Service < Draper::Decorator
|
6
|
+
delegate_all
|
7
|
+
|
8
|
+
# Makes a POST request to the given service with the following steps :
|
9
|
+
# 1. Gets an active and running instance of the service to make the request.
|
10
|
+
# 2. Creates a Faraday connection to use it as a pipeline for the request.
|
11
|
+
# 3. Makes the actual request and returns an object with the status and body of the response.
|
12
|
+
#
|
13
|
+
# @param route [String] the URL you want to reach on the service.
|
14
|
+
# @param parameters [Hash] the additional parameters to pass in the JSON body.
|
15
|
+
# @return [Hash, Boolean] FALSE if no instance are found, or an object with :status and :body keys correspding
|
16
|
+
# to the status and body of the response to the request
|
17
|
+
def post(route, parameters)
|
18
|
+
instance = object.instances.where(active: true, running: true).first
|
19
|
+
return false if instance.nil?
|
20
|
+
connection = Faraday.new(instance.url) do
|
21
|
+
faraday.request :url_encoded
|
22
|
+
faraday.response :logger
|
23
|
+
faraday.adapter Faraday.default_adapter
|
24
|
+
end
|
25
|
+
responde = connection.post do |req|
|
26
|
+
req.url route
|
27
|
+
req.headers['Content-Type'] = 'application/json'
|
28
|
+
req.body = parameters.to_json
|
29
|
+
end
|
30
|
+
return {
|
31
|
+
status: response.status,
|
32
|
+
body: JSON.parse(response.body)
|
33
|
+
}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Factories
|
3
|
+
# This class provides methods to create decorated services.
|
4
|
+
# @author Vincent Courtois <courtois.vincent@outlook.com>
|
5
|
+
class Services
|
6
|
+
|
7
|
+
# Searches for a service via its key and returns it decorated.
|
8
|
+
# @param key [String] the key of the server you want to find.
|
9
|
+
# @return [Arkaan::Decorators::Service, NilClass] nil if the service is not found, or the decorated service.
|
10
|
+
def self.search(key)
|
11
|
+
service = Arkaan::Monitoring::Service.where(key: key).first
|
12
|
+
return nil if service.nil?
|
13
|
+
return Arkaan::Decorators::Service.new(service)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arkaan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
@@ -240,6 +240,10 @@ files:
|
|
240
240
|
- lib/arkaan/concerns/enumerable.rb
|
241
241
|
- lib/arkaan/concerns/premiumable.rb
|
242
242
|
- lib/arkaan/concerns/sluggable.rb
|
243
|
+
- lib/arkaan/decorators.rb
|
244
|
+
- lib/arkaan/decorators/service.rb
|
245
|
+
- lib/arkaan/factories.rb
|
246
|
+
- lib/arkaan/factories/services.rb
|
243
247
|
- lib/arkaan/monitoring.rb
|
244
248
|
- lib/arkaan/monitoring/action.rb
|
245
249
|
- lib/arkaan/monitoring/gateway.rb
|