arkaan 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/arkaan/utils.rb +1 -0
- data/lib/arkaan/utils/controller.rb +16 -0
- data/lib/arkaan/utils/errors.rb +9 -0
- data/lib/arkaan/utils/errors/bad_request.rb +23 -0
- data/lib/arkaan/utils/errors/forbidden.rb +23 -0
- data/lib/arkaan/utils/errors/not_found.rb +23 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a311220ec19ed965a2f2074c3dfb5e499c36726
|
4
|
+
data.tar.gz: 4a6c21a2a90b14fa500384177d4b6cb4a8bf4bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebe0ae16361d0d2dde20e431d5d3a9c8ff6418ec9ad8de4347919a54109cec6bea8162f1f29517f7acaff89b0d3ae41a9b5880a40f0a70661ec8d1107eb83f89
|
7
|
+
data.tar.gz: ab0ba25a2a172c283a2a3fd6a56ad776c84527a6c614dd7ebbea3c262fa3c95aa3dd867bafb80aa92178c003b5b3984885578e7190974f4471f0f7ea1e42ae26
|
data/lib/arkaan/utils.rb
CHANGED
@@ -120,6 +120,22 @@ module Arkaan
|
|
120
120
|
def select_params(*fields)
|
121
121
|
return params.select { |key, value| fields.include?(key) }
|
122
122
|
end
|
123
|
+
|
124
|
+
def handle_arkaan_exception(exception)
|
125
|
+
custom_error(exception.status, "#{exception.action}.#{exception.field}.#{exception.error}")
|
126
|
+
end
|
127
|
+
|
128
|
+
error Arkaan::Utils::Errors::BadRequest do |exception|
|
129
|
+
handle_arkaan_exception(exception)
|
130
|
+
end
|
131
|
+
|
132
|
+
error Arkaan::Utils::Errors::Forbidden do |exception|
|
133
|
+
handle_arkaan_exception(exception)
|
134
|
+
end
|
135
|
+
|
136
|
+
error Arkaan::Utils::Errors::NotFound do |exception|
|
137
|
+
handle_arkaan_exception(exception)
|
138
|
+
end
|
123
139
|
end
|
124
140
|
end
|
125
141
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Utils
|
3
|
+
module Errors
|
4
|
+
class BadRequest < StandardError
|
5
|
+
attr_accessor :field
|
6
|
+
|
7
|
+
attr_accessor :action
|
8
|
+
|
9
|
+
attr_accessor :error
|
10
|
+
|
11
|
+
def initialize(action:, field:, error:)
|
12
|
+
@action = action
|
13
|
+
@field = field
|
14
|
+
@error = error
|
15
|
+
end
|
16
|
+
|
17
|
+
def status
|
18
|
+
return 400
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Utils
|
3
|
+
module Errors
|
4
|
+
class Forbidden < StandardError
|
5
|
+
attr_accessor :field
|
6
|
+
|
7
|
+
attr_accessor :action
|
8
|
+
|
9
|
+
attr_accessor :error
|
10
|
+
|
11
|
+
def initialize(action:, field:, error:)
|
12
|
+
@action = action
|
13
|
+
@field = field
|
14
|
+
@error = error
|
15
|
+
end
|
16
|
+
|
17
|
+
def status
|
18
|
+
return 403
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Arkaan
|
2
|
+
module Utils
|
3
|
+
module Errors
|
4
|
+
class NotFound < StandardError
|
5
|
+
attr_accessor :field
|
6
|
+
|
7
|
+
attr_accessor :action
|
8
|
+
|
9
|
+
attr_accessor :error
|
10
|
+
|
11
|
+
def initialize(action:, field:, error:)
|
12
|
+
@action = action
|
13
|
+
@field = field
|
14
|
+
@error = error
|
15
|
+
end
|
16
|
+
|
17
|
+
def status
|
18
|
+
return 404
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
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.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Courtois
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec-json_expectations
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rack-test
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,6 +244,10 @@ files:
|
|
230
244
|
- lib/arkaan/specs.rb
|
231
245
|
- lib/arkaan/utils.rb
|
232
246
|
- lib/arkaan/utils/controller.rb
|
247
|
+
- lib/arkaan/utils/errors.rb
|
248
|
+
- lib/arkaan/utils/errors/bad_request.rb
|
249
|
+
- lib/arkaan/utils/errors/forbidden.rb
|
250
|
+
- lib/arkaan/utils/errors/not_found.rb
|
233
251
|
- lib/arkaan/utils/micro_service.rb
|
234
252
|
- lib/arkaan/utils/seeder.rb
|
235
253
|
homepage: https://rubygems.org/gems/arkaan
|