ruby-ant-server 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ant/client/rest_client.rb +37 -14
- data/lib/ant/client/session/base.rb +0 -1
- data/lib/ant/configs/service_manager.rb +20 -0
- data/lib/ant/server/grape.rb +3 -0
- data/lib/ant/server/logger.rb +2 -1
- data/lib/ant/server/request_response.rb +4 -3
- data/lib/ant/version.rb +1 -1
- metadata +3 -11
- data/lib/ant/dry/daemon.rb +0 -31
- data/lib/ant/server/nanoservice/datasource/mongo.rb +0 -0
- data/lib/ant/server/nanoservice/schema.rb +0 -15
- data/lib/ant/server/nanoservice/validator.rb +0 -0
- data/lib/ant/server/nanoservice/validators/date.rb +0 -0
- data/lib/ant/server/nanoservice/validators/numeric.rb +0 -0
- data/lib/ant/server/nanoservice/validators/relation.rb +0 -0
- data/lib/ant/server/nanoservice/validators/text.rb +0 -0
- data/lib/ant/ssl/revocation_list.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c23b274800913526c9bd21f3d5153f7cdaa8c1ccbee688a0a9627eaa0d58775f
|
4
|
+
data.tar.gz: 904bca95ee34e8d6187b827e8dc46f009b4b409fb1355554929223481aa67b84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c209c719b33be8784cf1efb21d0dd6afab10f454813d2c93d19bc64949d461f523178ebcccfd06870c81b248e03d7f9b1847e0f9e18b620641365258b7cc7f2
|
7
|
+
data.tar.gz: d393682d18ad69334e804810296b7471c25080e7bb3687984569da6a8c57934ec9146c94778d3e55aa8687258be87d2a80d9314c6a7a44b9c2f0dc1a216a2208
|
@@ -15,29 +15,52 @@ module Ant
|
|
15
15
|
@validator = Validator.build(configs)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def get(path, data = {})
|
19
|
+
perform_request(:get, path, data)
|
20
|
+
end
|
21
|
+
|
22
|
+
def post(path, data = {})
|
23
|
+
perform_request(:post, path, data)
|
24
|
+
end
|
25
|
+
|
26
|
+
def put(path, data = {})
|
27
|
+
perform_request(:put, path, data)
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete(path, data = {})
|
31
|
+
perform_request(:delete, path, data)
|
32
|
+
end
|
33
|
+
|
34
|
+
def patch(path, data = {})
|
35
|
+
perform_request(:patch, path, data)
|
36
|
+
end
|
37
|
+
|
38
|
+
def raw_get(path, data = {})
|
39
|
+
perform_raw_request(:get, path, data)
|
40
|
+
end
|
22
41
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
42
|
+
def raw_post(path, data = {})
|
43
|
+
perform_raw_request(:post, path, data)
|
26
44
|
end
|
27
45
|
|
28
46
|
private
|
29
47
|
|
30
|
-
def
|
48
|
+
def perform_raw_request(method, path, data)
|
31
49
|
log_debug('Performing request', method: method, path: path, data: data)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
50
|
+
init_time = Time.now
|
51
|
+
uri = (path.start_with?('http') ? path : "#{@endpoint}#{path}")
|
52
|
+
result = @session.perform_request(method, uri,
|
53
|
+
@format.pack(data))
|
54
|
+
log_info('Request perfomed',
|
55
|
+
path: path,
|
56
|
+
server: @endpoint,
|
57
|
+
verb: method,
|
58
|
+
processing_time: (Time.now - init_time).to_f * 1000)
|
59
|
+
result
|
37
60
|
end
|
38
61
|
|
39
62
|
def perform_request(method, path, data)
|
40
|
-
result =
|
63
|
+
result = perform_raw_request(method, path, data)
|
41
64
|
unpacked = @format.unpack(result)
|
42
65
|
@validator.validate(unpacked)
|
43
66
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# TODO: Comming soon!
|
4
|
+
|
5
|
+
require 'ant/dry/resource_injector'
|
6
|
+
|
7
|
+
module Ant
|
8
|
+
module Configuration
|
9
|
+
# Allow to autoload configurations into ruby.
|
10
|
+
# It allows to implement new plugins.
|
11
|
+
class ServiceManager
|
12
|
+
extend Ant::DRY::ResourceInjector
|
13
|
+
def initialize(configs)
|
14
|
+
@configs = configs
|
15
|
+
end
|
16
|
+
|
17
|
+
def register_plugin(name); end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/ant/server/grape.rb
CHANGED
data/lib/ant/server/logger.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Ant
|
2
2
|
module Server
|
3
3
|
class RequestResponse
|
4
|
-
attr_reader :params, :exception, :result
|
5
|
-
attr_writer :exception, :result
|
4
|
+
attr_reader :params, :exception, :result, :start_timestamp
|
5
|
+
attr_writer :exception, :result, :start_timestamp
|
6
6
|
def initialize(request:, params:)
|
7
7
|
@request = request
|
8
8
|
@params = params
|
9
|
+
@start_timestamp = Time.now
|
9
10
|
end
|
10
11
|
|
11
12
|
def data
|
@@ -29,7 +30,7 @@ module Ant
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def path
|
32
|
-
@request.
|
33
|
+
@request.env['PATH_INFO']
|
33
34
|
end
|
34
35
|
end
|
35
36
|
end
|
data/lib/ant/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-ant-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilberto Vargas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cute_logger
|
@@ -239,7 +239,7 @@ files:
|
|
239
239
|
- lib/ant/client/validator.rb
|
240
240
|
- lib/ant/client/validator/jsend.rb
|
241
241
|
- lib/ant/client/validator/no_validator.rb
|
242
|
-
- lib/ant/
|
242
|
+
- lib/ant/configs/service_manager.rb
|
243
243
|
- lib/ant/dry/resource_injector.rb
|
244
244
|
- lib/ant/exceptions.rb
|
245
245
|
- lib/ant/http_exceptions.rb
|
@@ -251,23 +251,15 @@ files:
|
|
251
251
|
- lib/ant/server/nanoservice/datasource/id_generators.rb
|
252
252
|
- lib/ant/server/nanoservice/datasource/json_repository.rb
|
253
253
|
- lib/ant/server/nanoservice/datasource/model.rb
|
254
|
-
- lib/ant/server/nanoservice/datasource/mongo.rb
|
255
254
|
- lib/ant/server/nanoservice/datasource/repository.rb
|
256
255
|
- lib/ant/server/nanoservice/datasource/sequel.rb
|
257
256
|
- lib/ant/server/nanoservice/factory.rb
|
258
|
-
- lib/ant/server/nanoservice/schema.rb
|
259
|
-
- lib/ant/server/nanoservice/validator.rb
|
260
|
-
- lib/ant/server/nanoservice/validators/date.rb
|
261
|
-
- lib/ant/server/nanoservice/validators/numeric.rb
|
262
|
-
- lib/ant/server/nanoservice/validators/relation.rb
|
263
|
-
- lib/ant/server/nanoservice/validators/text.rb
|
264
257
|
- lib/ant/server/request_response.rb
|
265
258
|
- lib/ant/server/response.rb
|
266
259
|
- lib/ant/ssl.rb
|
267
260
|
- lib/ant/ssl/certificate.rb
|
268
261
|
- lib/ant/ssl/configuration.rb
|
269
262
|
- lib/ant/ssl/inventory.rb
|
270
|
-
- lib/ant/ssl/revocation_list.rb
|
271
263
|
- lib/ant/version.rb
|
272
264
|
homepage: https://github.com/KueskiEngineering/ruby-ant-server
|
273
265
|
licenses:
|
data/lib/ant/dry/daemon.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Ant
|
2
|
-
module DRY
|
3
|
-
class Daemon
|
4
|
-
def initialize(wait_time, attach, proc)
|
5
|
-
@proc = proc
|
6
|
-
@wait_time = wait_time
|
7
|
-
@attach = attach
|
8
|
-
@finish = false
|
9
|
-
end
|
10
|
-
|
11
|
-
def task
|
12
|
-
loop do
|
13
|
-
begin
|
14
|
-
@proc.exec
|
15
|
-
rescue StandarError => ex
|
16
|
-
log_error('Unexpected error', error: ex)
|
17
|
-
end
|
18
|
-
sleep(@wait_time)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def run
|
23
|
-
if @attach
|
24
|
-
task
|
25
|
-
else
|
26
|
-
Thread.new(&:task)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|