coaster 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coaster/core_ext/standard_error.rb +9 -0
- data/lib/coaster/version.rb +1 -1
- data/test/locales/en.yml +1 -0
- data/test/test_standard_error.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95f0cfd9af5c9ff9cbceb4b658f70bf32f02220b
|
4
|
+
data.tar.gz: d3e9b6913e609cd6ccf231808cf6e64d5a619389
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71bac4518e829fd11a28a75ca4d1b2c3407ed41b6b47eed1e051d565c4e855818db0f6576c73fe744d739f4a62080f55a204c3493df108e532c4b9fc21f872d8
|
7
|
+
data.tar.gz: 244a8da9cfc50a2125ac44193f130071d41343a94128225e59e8264c9d81082338227c11290c58ffccc15d2f1b79d989a659cbacd123626f0c44033d2de7d096
|
@@ -14,6 +14,11 @@ class StandardError
|
|
14
14
|
def http_status
|
15
15
|
500
|
16
16
|
end
|
17
|
+
|
18
|
+
def title
|
19
|
+
t = _translate('.title')
|
20
|
+
t.instance_variable_get(:@missing) ? nil : t
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
attr_accessor :tags, :level, :tkey
|
@@ -63,6 +68,10 @@ class StandardError
|
|
63
68
|
self.class.status
|
64
69
|
end
|
65
70
|
|
71
|
+
def title
|
72
|
+
self.class.title
|
73
|
+
end
|
74
|
+
|
66
75
|
def attributes
|
67
76
|
if cause && cause.respond_to?(:attributes)
|
68
77
|
cause.attributes.merge(@attributes)
|
data/lib/coaster/version.rb
CHANGED
data/test/locales/en.yml
CHANGED
data/test/test_standard_error.rb
CHANGED
@@ -11,6 +11,8 @@ module Coaster
|
|
11
11
|
def self.status; 20 end
|
12
12
|
end
|
13
13
|
|
14
|
+
class UntitledError < StandardError; end
|
15
|
+
|
14
16
|
def setup
|
15
17
|
I18n.backend = I18n::Backend::Simple.new
|
16
18
|
I18n.load_path += [File.expand_path('../locales/en.yml', __FILE__)]
|
@@ -91,5 +93,17 @@ LOG
|
|
91
93
|
rescue => e
|
92
94
|
assert_equal e._translate, 'Test this translation'
|
93
95
|
end
|
96
|
+
|
97
|
+
def test_title
|
98
|
+
raise SampleError, 'foobar'
|
99
|
+
rescue => e
|
100
|
+
assert_equal e.title, 'Test this title'
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_title_missing
|
104
|
+
raise UntitledError, 'untitled'
|
105
|
+
rescue => e
|
106
|
+
assert_equal e.title, nil
|
107
|
+
end
|
94
108
|
end
|
95
109
|
end
|