bindex 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30c71c3e8372b14f944f36e0d4bbbbeef20afa73
4
- data.tar.gz: d01dd1e87366ad5eabdc415890c0c8efee3bb5dc
3
+ metadata.gz: 8f3058f9c6ca15bbd05c8857a4c13b931c10855c
4
+ data.tar.gz: b0dc1e2b67f95cd838f427a11c03608161c03cd6
5
5
  SHA512:
6
- metadata.gz: 38aa516e2594f473fcc7cdc4e412240d01a29da7866ca043fff5f1119bf7e70b54f04e7545b9225995a34934dab9c8a52579a27292e46a4a7c6d0a2d885a8db4
7
- data.tar.gz: 8307b1fe43ca21e3bbd83dee6a69818d1c3a7f3fbccf7951d8861d13a5aae3bae6d1b353412f42a54cedaaf9fd61470ea887e4efe5c049adb7b5e75f69399507
6
+ metadata.gz: 3be4c3659396f2e68c9c3526bc5bd9c8e69325babb902d7bc4e0977bcf3c4b842e8c11a54af00169b926135672e28f836a4b41c88bfaa16b870ca010e41a47f2
7
+ data.tar.gz: f0a5337d9a0b35729f44b2d162e1c1e7028f147eaacfd270c10592e0ef8fd2d6f7bf7cf6ad1ef0e233c46b8379707cc06a2074956f6a74ab24b7f3dac1b34d3b
@@ -19,13 +19,18 @@ module Bindex
19
19
 
20
20
  # Filters internal Rubinius locations.
21
21
  #
22
- # The reason for this is that some methods, like ::Kernel.raise, are
23
- # implemented in Ruby for Rubinius. Therefore, we will get a binding for
24
- # them as well.
22
+ # There are a couple of reasons why we wanna filter out the locations.
25
23
  #
26
- # To align the current_bindings implementation with the CRuby one, where
27
- # the first binding will usually be binding of caller, we can use this
28
- # object to clean bindings for internal Rubinius methods.
24
+ # * ::Kernel.raise, is implemented in Ruby for Rubinius. We don't wanna
25
+ # have the frame for it to align with the CRuby and JRuby implementations.
26
+ #
27
+ # * For internal methods location variables can be nil. We can't create a
28
+ # bindings for them.
29
+ #
30
+ # * Bindings from the current file are considered internal and ignored.
31
+ #
32
+ # We do that all that so we can align the bindings with the backtraces
33
+ # entries.
29
34
  class InternalLocationFilter
30
35
  def initialize(locations)
31
36
  @locations = locations
@@ -33,7 +38,9 @@ module Bindex
33
38
 
34
39
  def filter
35
40
  @locations.reject do |location|
36
- location.file.start_with?('kernel/') || location.file == __FILE__
41
+ location.file.start_with?('kernel/delta/kernel.rb') ||
42
+ location.file == __FILE__ ||
43
+ location.variables.nil?
37
44
  end
38
45
  end
39
46
  end
@@ -50,7 +57,10 @@ end
50
57
  raise_exception = instance_method(:raise_exception)
51
58
 
52
59
  define_method(:raise_exception) do |exc|
53
- exc.instance_variable_set(:@bindings, Bindex::Rubinius.current_bindings)
60
+ if exc.bindings.empty?
61
+ exc.instance_variable_set(:@bindings, Bindex::Rubinius.current_bindings)
62
+ end
63
+
54
64
  raise_exception.bind(self).call(exc)
55
65
  end
56
66
  end
@@ -1,3 +1,3 @@
1
1
  module Bindex
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -25,6 +25,12 @@ class ExceptionTest < BaseTest
25
25
  assert_equal 11, exc.bindings.first.eval('__LINE__')
26
26
  end
27
27
 
28
+ test "re-raising doesn't lose bindings information" do
29
+ exc = ReraisedFixture.new.call
30
+
31
+ assert_equal 3, exc.bindings.first.eval('__LINE__')
32
+ end
33
+
28
34
  test 'bindings is_empty_when_exception_is_still_not_raised' do
29
35
  exc = RuntimeError.new
30
36
 
@@ -0,0 +1,19 @@
1
+ class ReraisedFixture
2
+ def call
3
+ reraise_an_error
4
+ rescue => exc
5
+ exc
6
+ end
7
+
8
+ private
9
+
10
+ def raise_an_error_in_eval
11
+ method_that_raises
12
+ rescue => exc
13
+ raise exc
14
+ end
15
+
16
+ def method_that_raises
17
+ raise
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bindex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genadi Samokovarov
@@ -236,6 +236,7 @@ files:
236
236
  - test/fixtures/custom_error_fixture.rb
237
237
  - test/fixtures/eval_nested_fixture.rb
238
238
  - test/fixtures/flat_fixture.rb
239
+ - test/fixtures/reraised_fixture.rb
239
240
  - test/test_helper.rb
240
241
  homepage: https://github.com/gsamokovarov/bindex
241
242
  licenses:
@@ -267,4 +268,5 @@ test_files:
267
268
  - test/fixtures/custom_error_fixture.rb
268
269
  - test/fixtures/eval_nested_fixture.rb
269
270
  - test/fixtures/flat_fixture.rb
271
+ - test/fixtures/reraised_fixture.rb
270
272
  - test/test_helper.rb