coaster 1.0.6 → 1.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb23e4c7362906cc9877bde117d7f1027adc08726b718526dd16bfe967355553
4
- data.tar.gz: f23ecb00881002158f99bc56daa261317f54b0620de3c6766b4fab93dc0d1e31
3
+ metadata.gz: ca45b5184489708bdeeb0381f2d540576f1b58cc324b3dca4f5bd698f021c687
4
+ data.tar.gz: 69ab2837c8159634389fefc993503c130bb8e14efcda3a2621646d909a3f9a4f
5
5
  SHA512:
6
- metadata.gz: b95bdef229ab03c481d31bf5f768ab9e1dec2a7d4d638d3bf1418da33e0665759030de2ef621fad94860b697373b8988dbe61b7955c479e7c9c1e3288c4ac656
7
- data.tar.gz: 57982252eddf851fe0245a8b141aeaab2e3213219ef49688ef59004cf9478054a1849e016f80289b5f3e93e2ec84f8b022fb3e8991bfc602aa1401709eebf481
6
+ metadata.gz: 417805608b285316128c95f4aadaa83d26ab9f2666e0273e1ee987baca5b4d346596dd0d1d8de925f7273bf6a4ee3ac057ceaf43c6213874b025e9df51533c5f
7
+ data.tar.gz: 795b2a27aaadf52aad1e6f723397dc13be68e3cd7028ca5c1a982cd9dda6cbe92d688ea4324ed72fd609274993c91c29978bf0d2ecc52bad7b4d6a82c68b4341
@@ -102,8 +102,18 @@ class StandardError
102
102
  def code; attributes[:code] || status end
103
103
  def code=(value); attributes[:code] = value end
104
104
  def title; attributes[:title] || self.class.title end
105
- def report?; attributes.key?(:report) ? attributes[:report] : self.class.report? end
106
- def intentional?; attributes.key?(:intentional) ? attributes[:intentional] : self.class.intentional? end
105
+ def it_might_happen?; attributes[:it] == :might_happen end
106
+ def it_should_not_happen?; attributes[:it] == :should_not_happen end
107
+ def report?
108
+ return attributes[:report] if attributes.key?(:report)
109
+ return false if it_might_happen?
110
+ self.class.report?
111
+ end
112
+ def intentional? # not logging in test
113
+ return attributes[:intentional] if attributes.key?(:intentional)
114
+ return true if it_should_not_happen?
115
+ self.class.intentional?
116
+ end
107
117
  def object; attributes[:object] || attributes[:obj] end
108
118
  alias_method :obj, :object
109
119
 
@@ -1,3 +1,3 @@
1
1
  module Coaster
2
- VERSION = '1.0.6'
2
+ VERSION = '1.0.7'
3
3
  end
@@ -158,12 +158,23 @@ LOG
158
158
 
159
159
  class SampleErrorSub < SampleError; end
160
160
  class SampleErrorSubSub < SampleErrorSub; end
161
- SampleError.after_logging(:blah) { @blah = 101 }
161
+ SampleError.after_logging(:blah) do
162
+ self.attributes[:abc] = 100
163
+ @blah = 101
164
+ end
162
165
  def test_before_logging
163
166
  e = SampleErrorSubSub.new(m: 'foo')
164
167
  assert !e.after_logging_blocks[:blah].nil?
165
168
  e.logging
169
+ assert_equal e.attributes[:abc], 100
166
170
  assert_equal e.instance_variable_get(:@blah), 101
167
171
  end
172
+ class SampleErrorMightHappen < SampleErrorSub
173
+ def it_might_happen?; true end
174
+ end
175
+ def test_might_happen
176
+ e = SampleErrorMightHappen.new('fbar')
177
+ assert !e.report?
178
+ end
168
179
  end
169
180
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coaster
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - buzz jung
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -226,7 +226,7 @@ signing_key:
226
226
  specification_version: 4
227
227
  summary: A little convenient feature for standard library
228
228
  test_files:
229
+ - test/test_object_translation.rb
229
230
  - test/locales/en.yml
230
231
  - test/test_standard_error.rb
231
232
  - test/test_helper.rb
232
- - test/test_object_translation.rb