binding_of_callers 0.2.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +3 -0
- data/lib/binding_of_callers/reveal.rb +1 -1
- data/lib/binding_of_callers/revealed.rb +2 -1
- data/lib/binding_of_callers/version.rb +1 -1
- data/lib/binding_of_callers.rb +14 -8
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ccb825b2e6aef0a18c6335e827cb8f59b1dd65b9c5c63e6b91f4eee74a9219c
|
4
|
+
data.tar.gz: 5cd06d2244151bda2da052a6a170f24366b01f75f298129523718bed1957cd6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48b7cd786832b8dfeeea6724f64482129907789f3c774e22c7824c15626804e74c107b6c262285b272c3a96f35db5c579dd8c9e9b24145b68d2ef7ea8aa03124
|
7
|
+
data.tar.gz: 4a44996cd79b7b488545cf6806a82f512c445b60a38b8628cfc555e68c774433d19ad4a1a509dcc3bde050c43111873e5a0072925449060c064a1f4013021979
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -23,6 +23,9 @@ Or install it yourself as:
|
|
23
23
|
```ruby
|
24
24
|
binding.of_callers # => an array of wrapped binding of callers
|
25
25
|
binding.of_callers! # => an array of extended binding of callers
|
26
|
+
|
27
|
+
binding.partial_callers(4) # => get closest four frames
|
28
|
+
binding.partial_callers(-2) # => get frames excluding the bottom two
|
26
29
|
```
|
27
30
|
|
28
31
|
### Inspect and modify a binding
|
data/lib/binding_of_callers.rb
CHANGED
@@ -4,28 +4,34 @@ require 'binding_of_caller'
|
|
4
4
|
|
5
5
|
class Binding
|
6
6
|
|
7
|
-
def of_callers
|
8
|
-
enhance do |bi|
|
7
|
+
def of_callers(fc = frame_count)
|
8
|
+
enhance(fc) do |bi|
|
9
9
|
BindingOfCallers::Revealed.new bi
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
def of_callers!
|
14
|
-
enhance do |bi|
|
13
|
+
def of_callers!(fc = frame_count)
|
14
|
+
enhance(fc) do |bi|
|
15
15
|
bi.extend BindingOfCallers::Reveal
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def partial_callers(limit)
|
20
|
+
_callers = callers
|
21
|
+
limit = _callers.size + limit if limit < 0
|
22
|
+
_callers[1, limit].map!{ |c| BindingOfCallers::Revealed.new(c) }
|
23
|
+
end
|
24
|
+
|
19
25
|
private
|
20
26
|
|
21
|
-
def enhance &enhance
|
22
|
-
collected.map(&enhance)
|
27
|
+
def enhance(fc, &enhance)
|
28
|
+
collected(fc).map(&enhance)
|
23
29
|
end
|
24
30
|
|
25
|
-
def collected
|
31
|
+
def collected(fc)
|
26
32
|
n = 3
|
27
33
|
bis = []
|
28
|
-
while n <
|
34
|
+
while n < fc
|
29
35
|
bis << of_caller(n)
|
30
36
|
n = n.succ
|
31
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binding_of_callers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
123
|
requirements: []
|
124
|
-
rubygems_version: 3.
|
124
|
+
rubygems_version: 3.1.6
|
125
125
|
signing_key:
|
126
126
|
specification_version: 4
|
127
127
|
summary: a wrapper of binding_of_caller, for easy use
|