robustly 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: ca4ab42ad4c9c82369991b01dcada93a3a58138e
4
- data.tar.gz: e2bbafae919d162f320e9f1632bb054fe1eeae07
3
+ metadata.gz: e02c3021e070fa4899fa7f53aefcd64bffe6fe82
4
+ data.tar.gz: 2aad8ec66ed86f10cb2614ddf3bf27d026755a45
5
5
  SHA512:
6
- metadata.gz: 988758ad8ae65d80cb04f2bc4c25ee6d31c595c5427541bd9561310888065bba57d0b7b33068bb13974cf60bee7206a1a69471d5bb194293dd10edcd7aa7b475
7
- data.tar.gz: 37dc2e5d78b0d5921924bca8d0cd888cce520ff72063ce0799df974f3413e3b0c88ddea5dc88230889b77e306ca1b1ad7a92d0f8b2f4bb7844f51c05b7ce1ea8
6
+ metadata.gz: 4c1b7cab85c2cb0fbe9f673018e6a2316df077e79854e854ab10ff5d71a9fdc63efe3799cda541a93a2719de281a4ad8c1d91797e995453447a3c1999dff45ff
7
+ data.tar.gz: 888840c69445f1546f126369db68250502031feb38824a5344e4ea897aa2b47c1cab8f3d6d400609199cc74bf569f6dcacbde10f7cea0559a7833243f438b5b8
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Don’t let small errors bring down the system
4
4
 
5
5
  ```ruby
6
- robustly do
6
+ safely do
7
7
  # keep going if this code fails
8
8
  end
9
9
  ```
@@ -29,7 +29,7 @@ Robustly.report_exception_method = proc {|e| Rollbar.report_exception(e) }
29
29
  And throttle reporting with:
30
30
 
31
31
  ```ruby
32
- robustly throttle: 1000 do
32
+ safely throttle: 1000 do
33
33
  # reports ~ 1/1000 errors
34
34
  end
35
35
  ```
@@ -37,7 +37,7 @@ end
37
37
  Specify a default value to return on errors:
38
38
 
39
39
  ```ruby
40
- robustly default: 30 do
40
+ safely default: 30 do
41
41
  # big bucks, no whammy
42
42
  end
43
43
  ```
@@ -45,7 +45,7 @@ end
45
45
  Catch specific errors
46
46
 
47
47
  ```ruby
48
- robustly only: ActiveRecord::RecordNotUnique do
48
+ safely only: ActiveRecord::RecordNotUnique do
49
49
  # all other exceptions will be raised
50
50
  end
51
51
  ```
@@ -17,7 +17,7 @@ module Robustly
17
17
 
18
18
  module Methods
19
19
 
20
- def robustly(options = {}, &block)
20
+ def safely(options = {}, &block)
21
21
  class_names = Array(options[:only] || StandardError)
22
22
  begin
23
23
  yield
@@ -29,7 +29,8 @@ module Robustly
29
29
  options[:default]
30
30
  end
31
31
  end
32
- alias_method :yolo, :robustly
32
+ alias_method :yolo, :safely
33
+ alias_method :robustly, :safely # legacy
33
34
 
34
35
  end
35
36
 
@@ -1,3 +1,3 @@
1
1
  module Robustly
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -7,30 +7,30 @@ class TestRobustly < Minitest::Test
7
7
  Robustly.report_exception_method = proc {|e| Errbase.report(e) }
8
8
  end
9
9
 
10
- def test_robustly_development_environment
10
+ def test_safely_development_environment
11
11
  Robustly.env = "development"
12
12
  assert_raises(Robustly::TestError) do
13
- robustly do
13
+ safely do
14
14
  raise Robustly::TestError
15
15
  end
16
16
  end
17
17
  end
18
18
 
19
- def test_robustly_test_environment
19
+ def test_safely_test_environment
20
20
  Robustly.env = "test"
21
21
  assert_raises(Robustly::TestError) do
22
- robustly do
22
+ safely do
23
23
  raise Robustly::TestError
24
24
  end
25
25
  end
26
26
  end
27
27
 
28
- def test_robustly_production_environment
28
+ def test_safely_production_environment
29
29
  exception = Robustly::TestError.new
30
30
  mock = MiniTest::Mock.new
31
31
  mock.expect :report_exception, nil, [exception]
32
32
  Robustly.report_exception_method = proc {|e| mock.report_exception(e) }
33
- robustly do
33
+ safely do
34
34
  raise exception
35
35
  end
36
36
  assert mock.verify
@@ -47,24 +47,35 @@ class TestRobustly < Minitest::Test
47
47
  assert mock.verify
48
48
  end
49
49
 
50
+ def test_robustly
51
+ exception = Robustly::TestError.new
52
+ mock = MiniTest::Mock.new
53
+ mock.expect :report_exception, nil, [exception]
54
+ Robustly.report_exception_method = proc {|e| mock.report_exception(e) }
55
+ robustly do
56
+ raise exception
57
+ end
58
+ assert mock.verify
59
+ end
60
+
50
61
  def test_return_value
51
- assert_equal 1, robustly { 1 }
52
- assert_equal nil, robustly { raise Robustly::TestError }
62
+ assert_equal 1, safely { 1 }
63
+ assert_equal nil, safely { raise Robustly::TestError }
53
64
  end
54
65
 
55
66
  def test_default
56
- assert_equal 1, robustly(default: 2) { 1 }
57
- assert_equal 2, robustly(default: 2) { raise Robustly::TestError }
67
+ assert_equal 1, safely(default: 2) { 1 }
68
+ assert_equal 2, safely(default: 2) { raise Robustly::TestError }
58
69
  end
59
70
 
60
71
  def test_only
61
- assert_equal nil, robustly(only: Robustly::TestError) { raise Robustly::TestError }
62
- assert_raises(RuntimeError, "Boom") { robustly(only: Robustly::TestError) { raise RuntimeError.new("Boom") } }
72
+ assert_equal nil, safely(only: Robustly::TestError) { raise Robustly::TestError }
73
+ assert_raises(RuntimeError, "Boom") { safely(only: Robustly::TestError) { raise RuntimeError.new("Boom") } }
63
74
  end
64
75
 
65
76
  def test_only_array
66
- assert_equal nil, robustly(only: [Robustly::TestError]) { raise Robustly::TestError }
67
- assert_raises(RuntimeError, "Boom") { robustly(only: [Robustly::TestError]) { raise RuntimeError.new("Boom") } }
77
+ assert_equal nil, safely(only: [Robustly::TestError]) { raise Robustly::TestError }
78
+ assert_raises(RuntimeError, "Boom") { safely(only: [Robustly::TestError]) { raise RuntimeError.new("Boom") } }
68
79
  end
69
80
 
70
81
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: robustly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-12 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: errbase