smoke_monster 0.2.3 → 0.3.0

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.
@@ -0,0 +1,7 @@
1
+ class Proc
2
+ def call_safely
3
+ self.call
4
+ rescue
5
+ yield if block_given?
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module SmokeMonster
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,35 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ module SafetyProc
4
+ class << self
5
+ attr_accessor :called
6
+ end
7
+ end
8
+
9
+ describe "Safety Proc" do
10
+ describe "a proc that will throw an exception" do
11
+ before do
12
+ SafetyProc.called = false
13
+ @proc = -> do
14
+ SafetyProc.called = true
15
+ raise 'k'
16
+ end
17
+ end
18
+
19
+ it "should trap the exception yet still call the method" do
20
+ @proc.call_safely
21
+ SafetyProc.called.must_equal true
22
+ end
23
+ end
24
+
25
+ describe "a proc with a block to call on error" do
26
+ before do
27
+ SafetyProc.called = false
28
+ end
29
+
30
+ it "call the block" do
31
+ @proc = -> { raise 'k' }.call_safely { SafetyProc.called = true }
32
+ SafetyProc.called.must_equal true
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smoke_monster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-04 00:00:00.000000000 Z
12
+ date: 2012-07-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Unexplained, dark magic.
15
15
  email:
@@ -29,11 +29,13 @@ files:
29
29
  - lib/smoke_monster/cover.rb
30
30
  - lib/smoke_monster/lambda_to_object.rb
31
31
  - lib/smoke_monster/lazy_cover.rb
32
+ - lib/smoke_monster/safety_proc.rb
32
33
  - lib/smoke_monster/version.rb
33
34
  - smoke_monster.gemspec
34
35
  - spec/smoke_monster/array_to_object_spec.rb
35
36
  - spec/smoke_monster/cover_spec.rb
36
37
  - spec/smoke_monster/lambda_to_object_spec.rb
38
+ - spec/smoke_monster/safety_proc_spec.rb
37
39
  - spec/spec_helper.rb
38
40
  homepage: http://www.github.com/darrencauthon/smoke_monster
39
41
  licenses: []
@@ -63,4 +65,5 @@ test_files:
63
65
  - spec/smoke_monster/array_to_object_spec.rb
64
66
  - spec/smoke_monster/cover_spec.rb
65
67
  - spec/smoke_monster/lambda_to_object_spec.rb
68
+ - spec/smoke_monster/safety_proc_spec.rb
66
69
  - spec/spec_helper.rb