ruby-ant-server 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ant/http_exceptions.rb +58 -0
- data/lib/ant/version.rb +1 -1
- metadata +3 -3
- data/lib/ant/server/http_exceptions.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67b68263025555b3e1ee19ebf348e454c12fa5f193d087894c7681be696b6e5c
|
4
|
+
data.tar.gz: 20f48f6e38ae463cb8bcc20052ebcc0317a2968e06d6e382d83fb118fc3f60dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 469da9f77d2224962e8bf2781e819d44beac795534838cb8a1858df483403c61cdd785414c915e8e4e5e0b597d150a089f82a1873986c8d781e249f2d236f2bd
|
7
|
+
data.tar.gz: e5a29afcfab0acd598bdf60525053afbc6f025ceeb1d2b8937bdae1c3b8f566d9f89d3a33cf8ca42b2f05207dbddca8e5d79a9b12161e24a634472992b29a21f
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'exceptions'
|
4
|
+
|
5
|
+
module Ant
|
6
|
+
module Exceptions
|
7
|
+
module HTTP
|
8
|
+
class << self
|
9
|
+
EXCEPTION_TYPES = {
|
10
|
+
success: Ant::Exceptions::AntSuccess,
|
11
|
+
fail: Ant::Exceptions::AntFail,
|
12
|
+
error: Ant::Exceptions::AntError
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
def new_http_exception(class_name, http_code, type)
|
16
|
+
parent = exception_type(type)
|
17
|
+
http_exception_class = Class.new(parent) do
|
18
|
+
def initialize(message, object = {})
|
19
|
+
super(message, nil, object)
|
20
|
+
end
|
21
|
+
|
22
|
+
define_method 'http_code' do
|
23
|
+
http_code
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
const_set(class_name, http_exception_class)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def exception_type(type)
|
33
|
+
EXCEPTION_TYPES[type.to_sym]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
http_codes = [
|
38
|
+
{ code_name: 'Ok', code: 200, type: :success },
|
39
|
+
{ code_name: 'Created', code: 201, type: :success },
|
40
|
+
{ code_name: 'Accepted', code: 202, type: :success },
|
41
|
+
{ code_name: 'NoContent', code: 204, type: :success },
|
42
|
+
{ code_name: 'BadRequest', code: 400, type: :fail },
|
43
|
+
{ code_name: 'Unauthorized', code: 401, type: :fail },
|
44
|
+
{ code_name: 'Forbidden', code: 403, type: :fail },
|
45
|
+
{ code_name: 'NotFound', code: 404, type: :fail },
|
46
|
+
{ code_name: 'NotValid', code: 422, type: :fail }
|
47
|
+
]
|
48
|
+
|
49
|
+
http_codes.each do |code|
|
50
|
+
Exceptions::HTTP.new_http_exception(
|
51
|
+
code[:code_name],
|
52
|
+
code[:code],
|
53
|
+
code[:type]
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gilberto Vargas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cute_logger
|
@@ -242,10 +242,10 @@ files:
|
|
242
242
|
- lib/ant/dry/daemon.rb
|
243
243
|
- lib/ant/dry/resource_injector.rb
|
244
244
|
- lib/ant/exceptions.rb
|
245
|
+
- lib/ant/http_exceptions.rb
|
245
246
|
- lib/ant/nanoservice.rb
|
246
247
|
- lib/ant/server/format.rb
|
247
248
|
- lib/ant/server/grape.rb
|
248
|
-
- lib/ant/server/http_exceptions.rb
|
249
249
|
- lib/ant/server/logger.rb
|
250
250
|
- lib/ant/server/nanoservice/datasource/exceptions.rb
|
251
251
|
- lib/ant/server/nanoservice/datasource/id_generators.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../exceptions'
|
4
|
-
|
5
|
-
module Exceptions
|
6
|
-
module HTTP
|
7
|
-
class << self
|
8
|
-
EXCEPTION_TYPES = {
|
9
|
-
success: Ant::Exceptions::AntSuccess,
|
10
|
-
fail: Ant::Exceptions::AntFail,
|
11
|
-
error: Ant::Exceptions::AntError
|
12
|
-
}.freeze
|
13
|
-
|
14
|
-
def new_http_exception(class_name, http_code, type)
|
15
|
-
parent = exception_type(type)
|
16
|
-
http_exception_class = Class.new(parent) do
|
17
|
-
def initialize(message, object = {})
|
18
|
-
super(message, nil, object)
|
19
|
-
end
|
20
|
-
|
21
|
-
define_method 'http_code' do
|
22
|
-
http_code
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
const_set(class_name, http_exception_class)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def exception_type(type)
|
32
|
-
EXCEPTION_TYPES[type.to_sym]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
http_codes = [
|
37
|
-
{ code_name: 'Ok', code: 200, type: :success },
|
38
|
-
{ code_name: 'Created', code: 201, type: :success },
|
39
|
-
{ code_name: 'Accepted', code: 202, type: :success },
|
40
|
-
{ code_name: 'NoContent', code: 204, type: :success },
|
41
|
-
{ code_name: 'BadRequest', code: 400, type: :fail },
|
42
|
-
{ code_name: 'Unauthorized', code: 401, type: :fail },
|
43
|
-
{ code_name: 'Forbidden', code: 403, type: :fail },
|
44
|
-
{ code_name: 'NotFound', code: 404, type: :fail },
|
45
|
-
{ code_name: 'NotValid', code: 422, type: :fail }
|
46
|
-
]
|
47
|
-
|
48
|
-
http_codes.each do |code|
|
49
|
-
Exceptions::HTTP.new_http_exception(
|
50
|
-
code[:code_name],
|
51
|
-
code[:code],
|
52
|
-
code[:type]
|
53
|
-
)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|