safely_block 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff610f8bed6b2446fd70d85987ec4e622e5f5021
4
- data.tar.gz: 56a9d89bee3fd0aa4804623e29639b3aeb39e8a2
3
+ metadata.gz: 0de79be5d7e0795c8a2e1497590a89685074a744
4
+ data.tar.gz: 33632c2284079dea7fef3c8d94a0903691402f34
5
5
  SHA512:
6
- metadata.gz: 06cf78fcab0ee8e6a743f27b5ca9b95f45049a47c78700013da0298f7c7967616df9c6f6f082e1a013f5e06fa12e6636d2e7fc811747fa0aa7a362328754ecba
7
- data.tar.gz: 1dcf67c2f094f854f358986240c14fe5e5afcfe6514d58a1f1cc95e8f670e5caa96462180a538f3e93427b9ef419bf1be66902c913d811adc0f889cd92dcc577
6
+ metadata.gz: 9082a7502e3b3df897c3fed0b968bb7d950bfc0fb44f86e3d51b4b5ee3aca867a8cddf6b49f78c1f9df96eda653cc2607c8dceabd5e888560cbbabe3722bb7fd
7
+ data.tar.gz: 3c5c86c9e3609db1b03e76cfb2eb723ee82d7e0a3bf4a5a18374dd96aaf7526e90d305aa9ee8f4f525fa3bf153ff35a7a6b232baa5912b8ff126a9272ca106a0
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm: 2.4.2
3
+ gemfile:
4
+ - Gemfile
5
+ sudo: false
6
+ before_install: gem install bundler
7
+ script: bundle exec rake test
8
+ notifications:
9
+ email:
10
+ on_success: never
11
+ on_failure: change
@@ -1,3 +1,7 @@
1
+ ## 0.2.1
2
+
3
+ - Tag exceptions reported with `report_exception`
4
+
1
5
  ## 0.2.0
2
6
 
3
7
  - Added `tag` option to `safely` method
data/README.md CHANGED
@@ -10,6 +10,8 @@ Exceptions are rescued and automatically reported to your favorite reporting ser
10
10
 
11
11
  In development and test environments, exceptions are raised so you can fix them.
12
12
 
13
+ [![Build Status](https://travis-ci.org/ankane/safely.svg?branch=master)](https://travis-ci.org/ankane/safely)
14
+
13
15
  ## Use It Everywhere
14
16
 
15
17
  “Oh no, analytics brought down search”
@@ -7,7 +7,15 @@ module Safely
7
7
  attr_accessor :raise_envs, :tag, :report_exception_method, :throttle_counter
8
8
  attr_writer :env
9
9
 
10
- def report_exception(e)
10
+ def report_exception(e, tag: nil)
11
+ tag = Safely.tag if tag.nil?
12
+ if tag && e.message
13
+ e = e.dup # leave original exception unmodified
14
+ message = e.message
15
+ e.define_singleton_method(:message) do
16
+ "[#{tag == true ? "safely" : tag}] #{message}"
17
+ end
18
+ end
11
19
  report_exception_method.call(e)
12
20
  end
13
21
 
@@ -42,15 +50,7 @@ module Safely
42
50
  if sample ? rand < 1.0 / sample : true
43
51
  begin
44
52
  unless Array(silence).any? { |c| e.is_a?(c) } || Safely.throttled?(e, throttle)
45
- tag = Safely.tag if tag.nil?
46
- if tag && e.message
47
- e = e.dup # leave original exception unmodified
48
- message = e.message
49
- e.define_singleton_method(:message) do
50
- "[#{tag == true ? "safely" : tag}] #{message}"
51
- end
52
- end
53
- Safely.report_exception(e)
53
+ Safely.report_exception(e, tag: tag)
54
54
  end
55
55
  rescue => e2
56
56
  $stderr.puts "FAIL-SAFE #{e2.class.name}: #{e2.message}"
@@ -1,3 +1,3 @@
1
1
  module Safely
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -69,6 +69,17 @@ class TestSafely < Minitest::Test
69
69
  assert_equal "[hi] Boom", ex.message
70
70
  end
71
71
 
72
+ def test_report_exception_tag
73
+ ex = nil
74
+ Safely.report_exception_method = -> (e) { ex = e }
75
+ begin
76
+ raise Safely::TestError, "Boom"
77
+ rescue => e
78
+ Safely.report_exception(e)
79
+ end
80
+ assert_equal "[safely] Boom", ex.message
81
+ end
82
+
72
83
  def test_return_value
73
84
  assert_equal 1, safely { 1 }
74
85
  assert_nil safely { raise Safely::TestError, "Boom" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safely_block
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2018-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: errbase
@@ -74,6 +74,7 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - ".travis.yml"
77
78
  - CHANGELOG.md
78
79
  - Gemfile
79
80
  - LICENSE.txt
@@ -105,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  version: '0'
106
107
  requirements: []
107
108
  rubyforge_project:
108
- rubygems_version: 2.6.8
109
+ rubygems_version: 2.6.13
109
110
  signing_key:
110
111
  specification_version: 4
111
112
  summary: Awesome exception handling