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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cabef00090223f45e2914553387ecb3e2209d989e5600290cc6143dcb12782f
4
- data.tar.gz: 5501a68962a4349b0fa918eae099207d5ceb40369dc91de67aaba1f5d31f0df0
3
+ metadata.gz: 7ccb825b2e6aef0a18c6335e827cb8f59b1dd65b9c5c63e6b91f4eee74a9219c
4
+ data.tar.gz: 5cd06d2244151bda2da052a6a170f24366b01f75f298129523718bed1957cd6d
5
5
  SHA512:
6
- metadata.gz: e378a3e420892fe16a45baafb6360dafe4a6c89b08d4858115b8c5aa24886fb25193e0184f52acaf02cc42cb7594127a2ba62b85966fc23c6ed5d5eb21766789
7
- data.tar.gz: b4a28b101878884b5741154c223004f5a6cddb85c13c98941aeb895fd804187a68a57846075ed0684531e24f5bb50e8ba708c1af3972e8d68d51d2c21617c0e9
6
+ metadata.gz: 48b7cd786832b8dfeeea6724f64482129907789f3c774e22c7824c15626804e74c107b6c262285b272c3a96f35db5c579dd8c9e9b24145b68d2ef7ea8aa03124
7
+ data.tar.gz: 4a44996cd79b7b488545cf6806a82f512c445b60a38b8628cfc555e68c774433d19ad4a1a509dcc3bde050c43111873e5a0072925449060c064a1f4013021979
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  *.swp
11
11
  *.gem
12
+ .tool-versions
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
@@ -120,7 +120,7 @@ module BindingOfCallers
120
120
  end
121
121
 
122
122
  def binding_self
123
- _binding.eval "instance_eval('self')"
123
+ _binding.receiver
124
124
  end
125
125
 
126
126
  def all_lv
@@ -5,9 +5,10 @@ module BindingOfCallers
5
5
 
6
6
  include Reveal
7
7
 
8
+ attr_reader :_binding
9
+
8
10
  def initialize _binding
9
11
  @_binding = _binding
10
12
  end
11
-
12
13
  end
13
14
  end
@@ -1,3 +1,3 @@
1
1
  module BindingOfCallers
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -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 < frame_count
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.0
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: 2021-02-16 00:00:00.000000000 Z
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.2.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