ananke 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ananke/helpers.rb +2 -1
- data/lib/ananke/routing.rb +7 -1
- data/lib/version.rb +1 -1
- data/spec/lib/error_spec.rb +26 -1
- data/spec/lib/validation_spec.rb +3 -1
- metadata +3 -3
data/lib/ananke/helpers.rb
CHANGED
@@ -78,7 +78,8 @@ module Ananke
|
|
78
78
|
return Ananke.send("call_#{repository_name}_#{method_name}", params), 200
|
79
79
|
rescue StandardError => error
|
80
80
|
raise if !error.message.start_with?(method_name.to_s)
|
81
|
-
|
81
|
+
message = error.message.split(method_name.to_s).last.split('-').last.split(':').last.strip
|
82
|
+
return message, 400
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
data/lib/ananke/routing.rb
CHANGED
@@ -41,7 +41,7 @@ module Ananke
|
|
41
41
|
def make_response(path, mod, link_list, link_to_list, obj, key)
|
42
42
|
if obj.class == Array
|
43
43
|
result_list = []
|
44
|
-
obj.each{|i| result_list << make_response_item(path, mod, link_list, link_to_list, i, key)}
|
44
|
+
obj.each{|i| result_list << make_response_item(path, mod, link_list, link_to_list, i, key) if i}
|
45
45
|
|
46
46
|
dic = result_list.empty? ? {} : {"#{path}_list".to_sym => result_list}
|
47
47
|
link_self = build_link_self(path, '') if Ananke.settings[:links]
|
@@ -73,6 +73,7 @@ module Ananke
|
|
73
73
|
|
74
74
|
obj, obj_status = repository_call(mod, :one, new_params)
|
75
75
|
error obj_status, obj if obj_status >= 400
|
76
|
+
not_found if obj && obj.class == Array && obj.empty?
|
76
77
|
|
77
78
|
status obj_status
|
78
79
|
make_response(path, mod, link_list, link_to_list, obj, key)
|
@@ -83,6 +84,7 @@ module Ananke
|
|
83
84
|
|
84
85
|
obj, obj_status = repository_call(mod, :all)
|
85
86
|
error obj_status, obj if obj_status >= 400
|
87
|
+
not_found if obj && obj.class == Array && obj.empty?
|
86
88
|
|
87
89
|
status obj_status
|
88
90
|
make_response(path, mod, link_list, link_to_list, obj, key)
|
@@ -96,6 +98,7 @@ module Ananke
|
|
96
98
|
|
97
99
|
obj, obj_status = repository_call(mod, :add, new_params)
|
98
100
|
error obj_status, obj if obj_status >= 400
|
101
|
+
not_found if obj && obj.class == Array && obj.empty?
|
99
102
|
|
100
103
|
status 201
|
101
104
|
make_response(path, mod, link_list, link_to_list, obj, key)
|
@@ -110,6 +113,7 @@ module Ananke
|
|
110
113
|
|
111
114
|
obj, obj_status = repository_call(mod, :edit, new_params)
|
112
115
|
error obj_status, obj if obj_status >= 400
|
116
|
+
not_found if obj && obj.class == Array && obj.empty?
|
113
117
|
|
114
118
|
status obj_status
|
115
119
|
make_response(path, mod, link_list, link_to_list, obj, key)
|
@@ -126,6 +130,7 @@ module Ananke
|
|
126
130
|
|
127
131
|
obj, obj_status = repository_call(mod, :delete, new_params)
|
128
132
|
error obj_status, obj if obj_status >= 400
|
133
|
+
not_found if obj && obj.class == Array && obj.empty?
|
129
134
|
|
130
135
|
status obj_status
|
131
136
|
end
|
@@ -146,6 +151,7 @@ module Ananke
|
|
146
151
|
|
147
152
|
obj, obj_status = repository_call(mod, r[:name], new_params)
|
148
153
|
error obj_status, obj if obj_status >= 400
|
154
|
+
not_found if obj && obj.class == Array && obj.empty?
|
149
155
|
|
150
156
|
obj_list = obj.class == Array ? obj : [obj]
|
151
157
|
|
data/lib/version.rb
CHANGED
data/spec/lib/error_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe 'Resource Route-For' do
|
|
25
25
|
|
26
26
|
get "/errors/exception400/1"
|
27
27
|
check_status(400)
|
28
|
-
last_response.body.should == '
|
28
|
+
last_response.body.should == 'Some Exception'
|
29
29
|
end
|
30
30
|
|
31
31
|
it """
|
@@ -45,4 +45,29 @@ describe 'Resource Route-For' do
|
|
45
45
|
get "/errors/exception500/1"
|
46
46
|
check_status(500)
|
47
47
|
end
|
48
|
+
|
49
|
+
it """
|
50
|
+
should return a code 404 for an empty Array object returned
|
51
|
+
""" do
|
52
|
+
module Repository
|
53
|
+
module Errors
|
54
|
+
def self.one(id)
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
def self.empty(id)
|
58
|
+
[]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
route :errors do
|
63
|
+
id :id
|
64
|
+
route_for :empty
|
65
|
+
end
|
66
|
+
|
67
|
+
get "/errors/empty/1"
|
68
|
+
check_status(404)
|
69
|
+
|
70
|
+
get "/errors/1"
|
71
|
+
check_status(404)
|
72
|
+
end
|
48
73
|
end
|
data/spec/lib/validation_spec.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ananke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andries Coetzee
|
@@ -130,7 +130,7 @@ licenses: []
|
|
130
130
|
post_install_message: |
|
131
131
|
**************************************************
|
132
132
|
|
133
|
-
Thank you for installing ananke-1.0.
|
133
|
+
Thank you for installing ananke-1.0.4
|
134
134
|
|
135
135
|
Please be sure to look at README.rdoc to see what might have changed
|
136
136
|
since the last release and how to use this GEM.
|
@@ -159,7 +159,7 @@ rubyforge_project:
|
|
159
159
|
rubygems_version: 1.5.0
|
160
160
|
signing_key:
|
161
161
|
specification_version: 3
|
162
|
-
summary: ananke-1.0.
|
162
|
+
summary: ananke-1.0.4
|
163
163
|
test_files:
|
164
164
|
- spec/dumping.rb
|
165
165
|
- spec/cov_adapter.rb
|