kinetic_cafe_error 1.8.1 → 1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -9
- data/History.rdoc +12 -0
- data/Rakefile +1 -1
- data/lib/kinetic_cafe/error.rb +1 -50
- data/lib/kinetic_cafe/error_module.rb +47 -0
- data/test/test_kinetic_cafe_error_hierarchy.rb +6 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fec4aacd3216e7dd65b34bc85e3c6f6a388de85d
|
4
|
+
data.tar.gz: b7456d64b7ad2bf4b8c0260d70543e552506de13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 777e6024ab58cc36d601b584dec51eb5ed0e9e2cc58b37741f75c71232568e5ada44653c283ea59c5aadcafb27b8675d363cec706a5b413ba202c8d84b963064
|
7
|
+
data.tar.gz: 85348156230d8e3ed1ef759b99202e06e1f0d24e8cc600fb032b0543fceae617f0041659bd9fe09540ab6b25f5648de866055f90d4d955c5e93dc59795f6058d
|
data/.travis.yml
CHANGED
@@ -3,9 +3,6 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 2.2.2
|
5
5
|
- 2.1.6
|
6
|
-
- 2.0.0
|
7
|
-
- 1.9.3
|
8
|
-
- jruby-1.7
|
9
6
|
- jruby-9.0.0.0
|
10
7
|
- jruby-head
|
11
8
|
- ruby-head
|
@@ -28,10 +25,4 @@ before_script:
|
|
28
25
|
script: rake travis
|
29
26
|
after_script:
|
30
27
|
- rake travis:after -t
|
31
|
-
notifications:
|
32
|
-
email:
|
33
|
-
recipients:
|
34
|
-
- FIX@example.com
|
35
|
-
on_success: change
|
36
|
-
on_failure: always
|
37
28
|
sudo: false
|
data/History.rdoc
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
=== 1.9 / 2015-11-30
|
2
|
+
|
3
|
+
* 2 bug fixes:
|
4
|
+
|
5
|
+
* The #stringify method needed to be moved to KineticCafe::ErrorModule so
|
6
|
+
that hierarchies *not* built from KineticCafe::Error can properly use query
|
7
|
+
parameter parsing.
|
8
|
+
|
9
|
+
* kinetic_cafe_error has required Ruby 2.1 or higher since version 1.5
|
10
|
+
because of the inclusion of i18n-tasks as a dependency. This is now
|
11
|
+
reflected in the dependencies.
|
12
|
+
|
1
13
|
=== 1.8.1 / 2015-10-26
|
2
14
|
|
3
15
|
* Re-release because 1.8 was yanked
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ spec = Hoe.spec 'kinetic_cafe_error' do
|
|
15
15
|
developer('Austin Ziegler', 'aziegler@kineticcafe.com')
|
16
16
|
developer('Jero Sutlovic', 'jsutlovic@kineticcafe.com')
|
17
17
|
|
18
|
-
require_ruby_version '>= 1
|
18
|
+
require_ruby_version '>= 2.1'
|
19
19
|
|
20
20
|
self.history_file = 'History.rdoc'
|
21
21
|
self.readme_file = 'README.rdoc'
|
data/lib/kinetic_cafe/error.rb
CHANGED
@@ -25,7 +25,7 @@ module KineticCafe # :nodoc:
|
|
25
25
|
# rescue clause and handled there, as is shown in the included
|
26
26
|
# KineticCafe::ErrorHandler controller concern for Rails.
|
27
27
|
class Error < ::StandardError
|
28
|
-
VERSION = '1.
|
28
|
+
VERSION = '1.9' # :nodoc:
|
29
29
|
|
30
30
|
# Get the KineticCafe::Error functionality.
|
31
31
|
include KineticCafe::ErrorModule
|
@@ -169,55 +169,6 @@ module KineticCafe # :nodoc:
|
|
169
169
|
base.singleton_class.send :undef_method, :__rack_status
|
170
170
|
end
|
171
171
|
end
|
172
|
-
|
173
|
-
private
|
174
|
-
|
175
|
-
def default_status
|
176
|
-
defined?(Rack::Utils) && :bad_request || 400
|
177
|
-
end
|
178
|
-
|
179
|
-
def default_severity
|
180
|
-
:error
|
181
|
-
end
|
182
|
-
|
183
|
-
def stringify(object, namespace = nil)
|
184
|
-
case object
|
185
|
-
when Hash
|
186
|
-
stringify_hash(object, namespace).compact.sort.join('; ')
|
187
|
-
when Array
|
188
|
-
stringify_array(object, namespace)
|
189
|
-
else
|
190
|
-
stringify_value(namespace, object)
|
191
|
-
end
|
192
|
-
end
|
193
|
-
|
194
|
-
def stringify_hash(hash, namespace)
|
195
|
-
hash.collect do |key, value|
|
196
|
-
key = namespace ? "#{namespace}[#{key}]" : key
|
197
|
-
case value
|
198
|
-
when Hash
|
199
|
-
next if value.nil?
|
200
|
-
stringify(value, key)
|
201
|
-
when Array
|
202
|
-
stringify_array(key, value)
|
203
|
-
else
|
204
|
-
stringify_value(key, value)
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
|
209
|
-
def stringify_array(key, array)
|
210
|
-
key = "#{key}[]"
|
211
|
-
if array.empty?
|
212
|
-
stringify_value(key, [])
|
213
|
-
else
|
214
|
-
array.collect { |value| stringify(value, key) }.join(', ')
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
def stringify_value(key, value)
|
219
|
-
"#{key}: #{value}"
|
220
|
-
end
|
221
172
|
end
|
222
173
|
end
|
223
174
|
|
@@ -200,6 +200,53 @@ module KineticCafe # :nodoc:
|
|
200
200
|
@i18n_params.update(cause: @cause.message)
|
201
201
|
end
|
202
202
|
|
203
|
+
def stringify(object, namespace = nil)
|
204
|
+
case object
|
205
|
+
when Hash
|
206
|
+
stringify_hash(object, namespace).compact.sort.join('; ')
|
207
|
+
when Array
|
208
|
+
stringify_array(object, namespace)
|
209
|
+
else
|
210
|
+
stringify_value(namespace, object)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def stringify_hash(hash, namespace)
|
215
|
+
hash.collect do |key, value|
|
216
|
+
key = namespace ? "#{namespace}[#{key}]" : key
|
217
|
+
case value
|
218
|
+
when Hash
|
219
|
+
next if value.nil?
|
220
|
+
stringify(value, key)
|
221
|
+
when Array
|
222
|
+
stringify_array(key, value)
|
223
|
+
else
|
224
|
+
stringify_value(key, value)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
def stringify_array(key, array)
|
230
|
+
key = "#{key}[]"
|
231
|
+
if array.empty?
|
232
|
+
stringify_value(key, [])
|
233
|
+
else
|
234
|
+
array.collect { |value| stringify(value, key) }.join(', ')
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
def stringify_value(key, value)
|
239
|
+
"#{key}: #{value}"
|
240
|
+
end
|
241
|
+
|
242
|
+
def default_status
|
243
|
+
defined?(Rack::Utils) && :bad_request || 400
|
244
|
+
end
|
245
|
+
|
246
|
+
def default_severity
|
247
|
+
:error
|
248
|
+
end
|
249
|
+
|
203
250
|
class << self
|
204
251
|
##
|
205
252
|
# The base for I18n key resolution. Defaults to 'kcerrors'.
|
@@ -91,6 +91,12 @@ describe KineticCafe::Error, '.hierarchy' do
|
|
91
91
|
assert My < KineticCafe::ErrorModule
|
92
92
|
end
|
93
93
|
|
94
|
+
it 'can handle a query parameter (issue #9)' do
|
95
|
+
expected = { query: "id: 1" }
|
96
|
+
actual = My.new(query: { id: 1 }).instance_variable_get(:@i18n_params)
|
97
|
+
assert_equal expected, actual
|
98
|
+
end
|
99
|
+
|
94
100
|
it 'cannot be extended a second time' do
|
95
101
|
ex = assert_raises do
|
96
102
|
KineticCafe::Error.hierarchy(class: :My)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinetic_cafe_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Austin Ziegler
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -283,14 +283,14 @@ dependencies:
|
|
283
283
|
requirements:
|
284
284
|
- - "~>"
|
285
285
|
- !ruby/object:Gem::Version
|
286
|
-
version: '3.
|
286
|
+
version: '3.14'
|
287
287
|
type: :development
|
288
288
|
prerelease: false
|
289
289
|
version_requirements: !ruby/object:Gem::Requirement
|
290
290
|
requirements:
|
291
291
|
- - "~>"
|
292
292
|
- !ruby/object:Gem::Version
|
293
|
-
version: '3.
|
293
|
+
version: '3.14'
|
294
294
|
description: |-
|
295
295
|
kinetic_cafe_error provides an API-smart error base class and a DSL for
|
296
296
|
defining errors. Under Rails, it also provides a controller concern
|
@@ -365,7 +365,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
365
365
|
requirements:
|
366
366
|
- - ">="
|
367
367
|
- !ruby/object:Gem::Version
|
368
|
-
version: 1
|
368
|
+
version: '2.1'
|
369
369
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
370
370
|
requirements:
|
371
371
|
- - ">="
|