dexc 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/dexc.rb +43 -2
  3. data/lib/dexc/version.rb +1 -1
  4. metadata +9 -19
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 22ffadb2a8fd9aeabe0d5582aafe1231bcdb24b8
4
+ data.tar.gz: aa1f0adb35679ae4a24b4e17de3b3bec224a058a
5
+ SHA512:
6
+ metadata.gz: 5e77c775cac363ccb8f6b8d10b375e7e6d95c15f6112d0a5f1d369e8f6227b1d719649c5d0884ed8c692f5febfcb3c34f2c1303894e669419c574c8a09819a2b
7
+ data.tar.gz: 42c204ebb02bdc796217d8b38608f39214e83236aa398dd96d212ee41a83c9ba7b680cf7bf2c0aebacd7d91dd3d1a4b384c20b4f8b93dc7469103b8a06ce7dbf
@@ -2,6 +2,8 @@
2
2
  #
3
3
  # Copyright (C) 2013 Kazuki Tsujimoto, All rights reserved.
4
4
 
5
+ raise LoadError, "TracePoint is undefined. Use Ruby 2.0.0 or later." unless defined? TracePoint
6
+
5
7
  require 'dexc/version'
6
8
 
7
9
  module Dexc
@@ -27,6 +29,38 @@ module Dexc
27
29
  RaiseEvent = Struct.new(:event, :raised_exception)
28
30
  ReturnEvent = Struct.new(:event, :lineno, :path, :defined_class, :method_id, :return_value)
29
31
 
32
+ # See MiniTest::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
33
+ # to know why SystemExit is used
34
+ class ExceptionWrapper < SystemExit
35
+ attr_reader :wrapped_exception
36
+
37
+ def initialize(wrapped_exception)
38
+ super(nil)
39
+ @wrapped_exception = wrapped_exception
40
+ end
41
+ end
42
+
43
+ module MiniTestPassThroughException
44
+ def run_test(*)
45
+ super
46
+ rescue => e
47
+ raise ExceptionWrapper, e
48
+ end
49
+ end
50
+
51
+ class ::Object
52
+ prepend Module.new {
53
+ def require(path)
54
+ super
55
+ if path == 'minitest/unit'
56
+ MiniTest::Unit::TestCase.class_eval do
57
+ prepend MiniTestPassThroughException
58
+ end
59
+ end
60
+ end
61
+ }
62
+ end
63
+
30
64
  def start
31
65
  events = RingBuffer.new(30)
32
66
 
@@ -42,6 +76,9 @@ module Dexc
42
76
 
43
77
  at_exit do
44
78
  exc = $!
79
+ if exc.kind_of?(ExceptionWrapper)
80
+ exc = exc.wrapped_exception
81
+ end
45
82
  tp.disable
46
83
  b = exc.instance_variable_get(EXC_BINDING_VAR)
47
84
  if exc.kind_of?(StandardError) and b
@@ -62,13 +99,17 @@ module Dexc
62
99
 
63
100
  begin
64
101
  require 'pry'
102
+ Pry.config.hooks.add_hook(:when_started, :dexc_init_ex) do |_, _, pry|
103
+ pry.last_exception = exc
104
+ pry.backtrace = (exc.backtrace || [])
105
+ end
65
106
  b.pry
66
107
  rescue LoadError
67
108
  require 'irb'
68
- IRB::Irb.module_eval do
109
+ IRB::Irb.class_eval do
69
110
  alias_method :eval_input_orig, :eval_input
70
111
  define_method(:eval_input) do
71
- IRB::Irb.module_eval { alias_method :eval_input, :eval_input_orig }
112
+ IRB::Irb.class_eval { alias_method :eval_input, :eval_input_orig }
72
113
  require 'irb/ext/multi-irb'
73
114
  IRB.irb(nil, b)
74
115
  end
@@ -1,3 +1,3 @@
1
1
  module Dexc
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dexc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kazuki Tsujimoto
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-09 00:00:00.000000000 Z
11
+ date: 2013-08-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  description: Automatically start the REPL and show trace on an exception to debug.
@@ -47,6 +44,7 @@ files:
47
44
  - test/test_dexc.rb
48
45
  homepage: https://github.com/k-tsj/dexc
49
46
  licenses: []
47
+ metadata: {}
50
48
  post_install_message:
51
49
  rdoc_options:
52
50
  - --main
@@ -54,27 +52,19 @@ rdoc_options:
54
52
  require_paths:
55
53
  - lib
56
54
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
55
  requirements:
59
- - - ! '>='
56
+ - - '>='
60
57
  - !ruby/object:Gem::Version
61
58
  version: '0'
62
- segments:
63
- - 0
64
- hash: 2613877154168346120
65
59
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
60
  requirements:
68
- - - ! '>='
61
+ - - '>='
69
62
  - !ruby/object:Gem::Version
70
63
  version: '0'
71
- segments:
72
- - 0
73
- hash: 2613877154168346120
74
64
  requirements: []
75
65
  rubyforge_project:
76
- rubygems_version: 1.8.23
66
+ rubygems_version: 2.0.3
77
67
  signing_key:
78
- specification_version: 3
68
+ specification_version: 4
79
69
  summary: A library that helps you to debug an exception
80
70
  test_files: []