chocolate_shell 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/chocolate_shell.rb +44 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d50c7e0210416c6f673f4a46acd68aaad13ff6c6
|
4
|
+
data.tar.gz: 7668e3c52a4fb18983b0ca0da1fe13478660e111
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86a2155e7fd76fabe05fc080047b2c4655a87bd95221b09da25d9afefe1a314efa0719d99b0ebb9ab35657d8694e11539ad64e3c7a4c7e06adf6c3efe63366a8
|
7
|
+
data.tar.gz: ca938bc9c97c83792f664bc620ee99211f5e8d900c88cab265f25a034ea1d00f157ae4e50aa0950c5d7a3c75e00759d8850500f111328ba1e06d871d96e4e1c6
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module ChocolateShell
|
2
|
+
module Boundary
|
3
|
+
def self.included(klass)
|
4
|
+
imethods = klass.instance_methods(false)
|
5
|
+
|
6
|
+
klass.send(:define_method, "initialize") do |value|
|
7
|
+
@result = value
|
8
|
+
super()
|
9
|
+
end
|
10
|
+
|
11
|
+
klass.send(:define_method, "on_error") do |handler|
|
12
|
+
err =
|
13
|
+
if @method && handler.respond_to?(@method)
|
14
|
+
handler.__send__(@method, @result, @error) || @error
|
15
|
+
elsif @method
|
16
|
+
@error
|
17
|
+
end
|
18
|
+
|
19
|
+
@result = nil if err
|
20
|
+
|
21
|
+
[@result, err]
|
22
|
+
end
|
23
|
+
|
24
|
+
imethods.each do |method|
|
25
|
+
klass.send(:define_method, "protected_#{method}") do
|
26
|
+
return self if @failed
|
27
|
+
|
28
|
+
begin
|
29
|
+
@result = __send__("original_#{method}", @result)
|
30
|
+
rescue => e
|
31
|
+
@failed = true
|
32
|
+
@error = e
|
33
|
+
@method = method
|
34
|
+
end
|
35
|
+
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
klass.send(:alias_method, "original_#{method}", method)
|
40
|
+
klass.send(:alias_method, method, "protected_#{method}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chocolate_shell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Voss
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: flog
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler-audit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: For error handling
|
84
|
+
email: bwvoss@gmail.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- lib/chocolate_shell.rb
|
90
|
+
homepage: http://github.com/bwvoss
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.5
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Provides a clean boundary for error handling and logging
|
114
|
+
test_files: []
|
115
|
+
has_rdoc:
|