api_recipes 0.4.2 → 0.5.0
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/CHANGELOG.md +3 -0
- data/lib/api_recipes/exceptions.rb +26 -8
- data/lib/api_recipes/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b41bc13cab8b381a030b1ddb3c7d5303e6f3fa2fea6b2e81731666d14dfbe1c6
|
4
|
+
data.tar.gz: 547f5c2aee809434f49b6f421ae8da7e99094f66b8e33fbd412f26ead62f661b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 203165b29b7f6d2b12f3be7f400c5fd1dc17c8e0df5146007e5fc9238d1a9db34e38b9e9f30c63658e5b7bf207a1bc7ba8303b27d924cd26075ec27e81f115d2
|
7
|
+
data.tar.gz: 36e58f2699754319ec9fefb70658e2bdd1932dcab40e199045e04a40b7445019b431178715ebbc5534d26e67497adcd5b979656b2d645de5da074c24e59dddc0
|
data/CHANGELOG.md
ADDED
@@ -1,10 +1,13 @@
|
|
1
1
|
module ApiRecipes
|
2
2
|
class RouteNameClashError < Exception
|
3
|
+
attr_reader :route, :resource
|
4
|
+
|
3
5
|
def initialize(message = nil, route = nil, resource = nil)
|
6
|
+
@route = route; @resource = resource
|
4
7
|
if message
|
5
8
|
# Nothing to do
|
6
9
|
elsif route
|
7
|
-
message = "route name (#{route}) can't be equal to resource name (#{resource}). Please change route or resource name."
|
10
|
+
message = "route name (#{@route}) can't be equal to resource name (#{@resource}). Please change route or resource name."
|
8
11
|
else
|
9
12
|
message = "route name can't be equal to resource name. Please change route or resource names."
|
10
13
|
end
|
@@ -13,52 +16,67 @@ module ApiRecipes
|
|
13
16
|
end
|
14
17
|
|
15
18
|
class MissingRouteAttribute < Exception
|
19
|
+
attr_reader :resource, :route, :attribute
|
20
|
+
|
16
21
|
def initialize(message = nil, resource = nil, route = nil, attribute = nil)
|
22
|
+
@resource = resource; @route = route; @attribute = attribute
|
17
23
|
if message
|
18
24
|
# Nothing to do
|
19
|
-
elsif route && attribute
|
20
|
-
message = "route '#{resource}.#{route}' requires '#{attribute}' attribute but this was not given"
|
25
|
+
elsif @route && @attribute
|
26
|
+
message = "route '#{@resource}.#{@route}' requires '#{@attribute}' attribute but this was not given"
|
21
27
|
end
|
22
28
|
super(message)
|
23
29
|
end
|
24
30
|
end
|
25
31
|
|
26
32
|
class ResponseCodeNotAsExpected < Exception
|
27
|
-
|
33
|
+
attr_reader :resource, :route, :expected_code, :response_code, :response_body
|
34
|
+
|
35
|
+
def initialize(message = nil, resource = nil, route = nil, expected_code = nil, response_code = nil, response_body = nil)
|
36
|
+
@resource = resource; @route = route; @expected_code = expected_code; @response_code = response_code; @response_body = response_body
|
28
37
|
if message
|
29
38
|
# Nothing to do
|
30
39
|
else
|
31
|
-
message = "response code for request on route '#{resource}.#{route}' has returned #{
|
40
|
+
message = "response code for request on route '#{@resource}.#{@route}' has returned #{@response_code}, but #{@expected_code} was expected. Reason: #{@response_body}"
|
32
41
|
end
|
33
42
|
super(message)
|
34
43
|
end
|
35
44
|
end
|
36
45
|
|
37
46
|
class EndpointConfigIsNotAnHash < Exception
|
47
|
+
attr_reader :endpoint
|
48
|
+
|
38
49
|
def initialize(message = nil, endpoint = nil)
|
50
|
+
@endpoint = endpoint
|
39
51
|
if message
|
40
52
|
# Nothing to do
|
41
53
|
else
|
42
|
-
message = "provided config for endpoint '#{endpoint}' must be an Hash"
|
54
|
+
message = "provided config for endpoint '#{@endpoint}' must be an Hash"
|
43
55
|
end
|
44
56
|
super(message)
|
45
57
|
end
|
46
58
|
end
|
47
59
|
|
48
60
|
class NoConfigurationGivenForEndpoint < Exception
|
61
|
+
attr_reader :endpoint
|
62
|
+
|
49
63
|
def initialize(message = nil, endpoint = nil)
|
64
|
+
@endpoint = endpoint
|
50
65
|
if message
|
51
66
|
# Nothing to do
|
52
67
|
else
|
53
|
-
message = "no configuration provided for endpoint '#{endpoint}'"
|
68
|
+
message = "no configuration provided for endpoint '#{@endpoint}'"
|
54
69
|
end
|
55
70
|
super(message)
|
56
71
|
end
|
57
72
|
end
|
58
73
|
|
59
74
|
class RouteNameClashWithExistentMethod < Exception
|
75
|
+
attr_reader :resource, :route
|
76
|
+
|
60
77
|
def initialize(resource, route)
|
61
|
-
|
78
|
+
@resource = resource; @route = route
|
79
|
+
message = "can't define route '#{@route}' method in resource '#{@resource}' because method '#{@route}' already exists"
|
62
80
|
super(message)
|
63
81
|
end
|
64
82
|
end
|
data/lib/api_recipes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_recipes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Verlato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rspec"
|
50
50
|
- ".travis.yml"
|
51
|
+
- CHANGELOG.md
|
51
52
|
- CODE_OF_CONDUCT.md
|
52
53
|
- Gemfile
|
53
54
|
- Guardfile
|
@@ -94,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
95
|
version: '0'
|
95
96
|
requirements: []
|
96
97
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.7.
|
98
|
+
rubygems_version: 2.7.7
|
98
99
|
signing_key:
|
99
100
|
specification_version: 4
|
100
101
|
summary: Consume HTTP APIs with style
|