clean-annotations 0.2.0 → 0.4.0

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
  SHA256:
3
- metadata.gz: 5f74077b036028e5f0f718c84721e72834896bf88562fca24d3ffcfca93c4d75
4
- data.tar.gz: a14f988df6892020cc6428ac7442ffb5dc278948b6fcee9f9c5a851b3811c692
3
+ metadata.gz: 5f4b1010c1932dceaa3b47119e7355bd9429f191d64253b93b84a9738b8c42f5
4
+ data.tar.gz: ff7586b5e7648680184aa2dac1f1b5161ac149baba75a7c39c8e210de18d8682
5
5
  SHA512:
6
- metadata.gz: f0925f798a35fb7cfd37c0f4ac25df6ba912f92e0fe311b6719d0a92220ceef0825ec703cd61d3ba82f304182f1c1267e8006fbb93a48553e2a24217ee115559
7
- data.tar.gz: 07c63cc13717a79805789d04956020f07481b3e9f0ab619cb183e6a3743507e5c0133da38add93a86ea8f41f1cc2bab18a15d67c8ab63506db42415bffc3a7a1
6
+ metadata.gz: 32cf18f49d2b60db203fc9327cabeedc63ba18d1b1b9b3ec64f4e41b4e64a45bee67810bf28f67cb22e706b5c8a5ee7d574f74059684963dc5d946e90b9e8352
7
+ data.tar.gz: ccd044c4c5798c35e6bc1501bb4bf938a2f8dd4bca4797b63b8aaa1f4dfc865de3600012f311ea9b3ca20431b0939035dda6921e35085839bc22ffc4f9fb0c41
data/.version CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.4.0
@@ -9,3 +9,7 @@ end
9
9
  unless Object.respond_to?(:method_attr)
10
10
  require_relative './clean-annotations/method_attr'
11
11
  end
12
+
13
+ unless Object.respond_to?(:rescue_from)
14
+ require_relative './clean-annotations/rescue_from'
15
+ end
@@ -66,8 +66,8 @@ end
66
66
  # {
67
67
  # test: {
68
68
  # name: [
69
- # "Test method desc 1",
70
- # "Test method desc 2"
69
+ # ["Test method desc 1"],
70
+ # ["Test method desc 2"]
71
71
  # ],
72
72
  # param: [
73
73
  # {
@@ -0,0 +1,38 @@
1
+ module RescueFromError
2
+ extend self
3
+
4
+ RESCUES ||= {}
5
+
6
+ def included base
7
+ def base.rescue_from what, &block
8
+ raise ArgumemtError.new('Unsupported') if what.is_a?(Symbol) && what != :all
9
+
10
+ key = [self, what].join('-')
11
+ RESCUES[key] = block
12
+ end
13
+ end
14
+
15
+ def resolve_rescue_from
16
+ begin
17
+ yield
18
+ rescue => error
19
+ for klass in self.class.ancestors
20
+ key = [klass, error.class].join('-')
21
+
22
+ if block = RESCUES[key]
23
+ return instance_exec(error, &block)
24
+ end
25
+ end
26
+
27
+ for klass in self.class.ancestors
28
+ key = [klass, :all].join('-')
29
+
30
+ if block = RESCUES[key]
31
+ return instance_exec(error, &block)
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ private
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clean-annotations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-16 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Define annotatable attribute names and assign them to methods or classes,
14
14
  add callbacks to non-Rails classes. Void of dependencies.
@@ -22,6 +22,7 @@ files:
22
22
  - "./lib/clean-annotations/class_attribute.rb"
23
23
  - "./lib/clean-annotations/class_callbacks.rb"
24
24
  - "./lib/clean-annotations/method_attr.rb"
25
+ - "./lib/clean-annotations/rescue_from.rb"
25
26
  homepage: https://github.com/dux/clean-annotations
26
27
  licenses:
27
28
  - MIT