kinetic_cafe_error 1.9 → 1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -4
- data/Appraisals +7 -0
- data/History.rdoc +10 -0
- data/Manifest.txt +3 -0
- data/Rakefile +1 -0
- data/gemfiles/rack_1.6.gemfile +7 -0
- data/gemfiles/rack_2.gemfile +7 -0
- data/lib/kinetic_cafe/error.rb +1 -1
- data/lib/kinetic_cafe/error_dsl.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/test_kinetic_cafe_error_dsl.rb +25 -0
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed2b06cb85a613bdd8ac56aa6e8216188f257395
|
4
|
+
data.tar.gz: 7077a564338ef9bb8f885c51e86c36033b975671
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94f9b44dbd23fe6ac116dae799503402231d89d7ceb76fdec18cd781c6933d09e7ad471626bc515cfdd324275b25d11cd05981f6a1edb71dde6f530e8ab3840b
|
7
|
+
data.tar.gz: c0c6d9491699c4b9f184774552688b35c8fe0b21514e865d26811a4e488b7c5239329335850ab4fc6c4b42b3ddc26ac8ec1874e4f21ececbf9c0d2489c3b59b2
|
data/.travis.yml
CHANGED
@@ -1,19 +1,24 @@
|
|
1
1
|
---
|
2
2
|
language: ruby
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
6
|
-
-
|
4
|
+
- 2.3.0
|
5
|
+
- 2.2.4
|
6
|
+
- 2.1
|
7
|
+
- jruby-9.0.4.0
|
7
8
|
- jruby-head
|
8
9
|
- ruby-head
|
9
10
|
- rbx-2
|
10
11
|
matrix:
|
12
|
+
exclude:
|
13
|
+
- rvm: 2.1
|
14
|
+
gemfile: gemfiles/rack_2.gemfile
|
11
15
|
allow_failures:
|
12
16
|
- rvm: rbx-2
|
13
17
|
- rvm: jruby-head
|
14
18
|
- rvm: ruby-head
|
15
19
|
gemfile:
|
16
|
-
-
|
20
|
+
- gemfiles/rack_1.6.gemfile
|
21
|
+
- gemfiles/rack_2.gemfile
|
17
22
|
before_script:
|
18
23
|
- |
|
19
24
|
case "${TRAVIS_RUBY_VERSION}" in
|
data/Appraisals
ADDED
data/History.rdoc
CHANGED
data/Manifest.txt
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
.gemtest
|
3
3
|
.rubocop.yml
|
4
4
|
.travis.yml
|
5
|
+
Appraisals
|
5
6
|
Contributing.rdoc
|
6
7
|
Gemfile
|
7
8
|
History.rdoc
|
@@ -23,6 +24,8 @@ config/locales/kinetic_cafe_error.en-US.yml
|
|
23
24
|
config/locales/kinetic_cafe_error.en.yml
|
24
25
|
config/locales/kinetic_cafe_error.fr-CA.yml
|
25
26
|
config/locales/kinetic_cafe_error.fr.yml
|
27
|
+
gemfiles/rack_1.6.gemfile
|
28
|
+
gemfiles/rack_2.gemfile
|
26
29
|
lib/kinetic_cafe/error.rb
|
27
30
|
lib/kinetic_cafe/error/minitest.rb
|
28
31
|
lib/kinetic_cafe/error_dsl.rb
|
data/Rakefile
CHANGED
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.10' # :nodoc:
|
29
29
|
|
30
30
|
# Get the KineticCafe::Error functionality.
|
31
31
|
include KineticCafe::ErrorModule
|
@@ -103,6 +103,7 @@ module KineticCafe
|
|
103
103
|
end
|
104
104
|
|
105
105
|
key.tap do |k|
|
106
|
+
k.gsub!(/[^[:word:]]/, '_')
|
106
107
|
k.squeeze!('_')
|
107
108
|
k.gsub!(/^_+/, '')
|
108
109
|
k.gsub!(/_+$/, '')
|
@@ -177,6 +178,8 @@ module KineticCafe
|
|
177
178
|
|
178
179
|
if defined?(Rack::Utils) && rack_status
|
179
180
|
Rack::Utils::SYMBOL_TO_STATUS_CODE.each_key do |name|
|
181
|
+
# Make the Rack names safe to use
|
182
|
+
name = name.to_s.gsub(/[^[:word:]]/, '_').squeeze('_').to_sym
|
180
183
|
if rack_status.fetch(:methods, true)
|
181
184
|
base.singleton_class.send :define_method, name do |options = {}|
|
182
185
|
define_error(options.merge(status: name))
|
data/test/test_helper.rb
CHANGED
@@ -104,6 +104,12 @@ describe KineticCafe::ErrorDSL do
|
|
104
104
|
refute base.private_instance_methods.include?(:default_severity)
|
105
105
|
assert_equal :error, instance.send(:default_severity)
|
106
106
|
end
|
107
|
+
|
108
|
+
it 'strips non-word characters from a key' do
|
109
|
+
child = base.define_error key: :"child(ren)"
|
110
|
+
instance = child.new
|
111
|
+
assert_equal 'child_ren', instance.name
|
112
|
+
end
|
107
113
|
end
|
108
114
|
|
109
115
|
describe 'class-based definition' do
|
@@ -184,6 +190,11 @@ describe KineticCafe::ErrorDSL do
|
|
184
190
|
refute base.private_instance_methods.include?(:default_status)
|
185
191
|
assert_equal :not_found, instance.send(:default_status)
|
186
192
|
end
|
193
|
+
|
194
|
+
it 'strips non-word characters from a key' do
|
195
|
+
base.define_error class: :"child(ren)", status: :not_found
|
196
|
+
assert base.const_defined?(:ChildRenNotFound)
|
197
|
+
end
|
187
198
|
end
|
188
199
|
|
189
200
|
describe 'with numeric status' do
|
@@ -279,6 +290,20 @@ describe KineticCafe::ErrorDSL do
|
|
279
290
|
assert base.respond_to?(:not_found)
|
280
291
|
refute base.const_defined?(:NotFound)
|
281
292
|
end
|
293
|
+
|
294
|
+
it 'protects against badly named Rack status symbols' do
|
295
|
+
begin
|
296
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE[:"another_(silly)_love_song"] = 999
|
297
|
+
base = Class.new(StandardError) do
|
298
|
+
extend KineticCafe::ErrorDSL
|
299
|
+
end
|
300
|
+
assert base.respond_to?(:another_silly_love_song)
|
301
|
+
assert base.const_defined?(:AnotherSillyLoveSong)
|
302
|
+
ensure
|
303
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE.delete(:"another_(silly)_love_song")
|
304
|
+
$debugme = false
|
305
|
+
end
|
306
|
+
end
|
282
307
|
end
|
283
308
|
|
284
309
|
describe 'when Rack::Utils is not defined' do
|
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.10'
|
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:
|
12
|
+
date: 2016-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '4.0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: appraisal
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.1'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.1'
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: hoe-doofus
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -317,6 +331,7 @@ files:
|
|
317
331
|
- ".gemtest"
|
318
332
|
- ".rubocop.yml"
|
319
333
|
- ".travis.yml"
|
334
|
+
- Appraisals
|
320
335
|
- Contributing.rdoc
|
321
336
|
- Gemfile
|
322
337
|
- History.rdoc
|
@@ -338,6 +353,8 @@ files:
|
|
338
353
|
- config/locales/kinetic_cafe_error.en.yml
|
339
354
|
- config/locales/kinetic_cafe_error.fr-CA.yml
|
340
355
|
- config/locales/kinetic_cafe_error.fr.yml
|
356
|
+
- gemfiles/rack_1.6.gemfile
|
357
|
+
- gemfiles/rack_2.gemfile
|
341
358
|
- lib/kinetic_cafe/error.rb
|
342
359
|
- lib/kinetic_cafe/error/minitest.rb
|
343
360
|
- lib/kinetic_cafe/error_dsl.rb
|
@@ -373,7 +390,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
373
390
|
version: '0'
|
374
391
|
requirements: []
|
375
392
|
rubyforge_project:
|
376
|
-
rubygems_version: 2.
|
393
|
+
rubygems_version: 2.5.1
|
377
394
|
signing_key:
|
378
395
|
specification_version: 4
|
379
396
|
summary: kinetic_cafe_error provides an API-smart error base class and a DSL for defining
|