pry-rescue 0.9.1.martin → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +37 -38
- data/bin/rescue +5 -0
- data/lib/pry-rescue/core_ext.rb +1 -1
- data/lib/pry-rescue/rails.rb +14 -0
- data/lib/pry-rescue.rb +7 -1
- data/pry-rescue.gemspec +1 -1
- data/spec/core_ext_spec.rb +19 -0
- metadata +92 -96
data/README.md
CHANGED
@@ -11,6 +11,19 @@ instead of `ruby`:
|
|
11
11
|
rescue <script.rb> [arguments..]
|
12
12
|
```
|
13
13
|
|
14
|
+
If you're using Rails, you should add `pry-rescue` to the development section of your
|
15
|
+
Gemspec and then run rails server using rescue:
|
16
|
+
|
17
|
+
```
|
18
|
+
rescue rails server
|
19
|
+
```
|
20
|
+
|
21
|
+
If you're using `bundle exec` the rescue should go after the exec:
|
22
|
+
|
23
|
+
```
|
24
|
+
bundle exec rescue rails server
|
25
|
+
```
|
26
|
+
|
14
27
|
If you're using Rack, you should use the middleware instead (though be careful to only
|
15
28
|
include it in development!)
|
16
29
|
```
|
@@ -49,6 +62,19 @@ from examples/example.rb:7:in `rescue in test'
|
|
49
62
|
[1] pry(main)>
|
50
63
|
```
|
51
64
|
|
65
|
+
Finally. If you're doing your own exception handling, you can ask pry to open on an exception that you've caught.
|
66
|
+
For this to work you must be inside a Pry::rescue{ } block.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
def test
|
70
|
+
raise "foo"
|
71
|
+
rescue => e
|
72
|
+
Pry::rescued(e)
|
73
|
+
end
|
74
|
+
|
75
|
+
Pry::rescue{ test }
|
76
|
+
```
|
77
|
+
|
52
78
|
cd-cause
|
53
79
|
========
|
54
80
|
|
@@ -93,51 +119,24 @@ From: examples/example.rb @ line 4 Object#test:
|
|
93
119
|
foo
|
94
120
|
```
|
95
121
|
|
96
|
-
Pry::rescued
|
97
|
-
============
|
98
|
-
|
99
|
-
If your exception handling needs are truly complicated then you can pass explicitly
|
100
|
-
rescued exceptions into Pry::rescue:
|
101
|
-
|
102
|
-
```ruby
|
103
|
-
def test
|
104
|
-
raise "foo"
|
105
|
-
end
|
106
|
-
|
107
|
-
def safely_test
|
108
|
-
test
|
109
|
-
rescue => e
|
110
|
-
Pry::rescued e
|
111
|
-
end
|
112
|
-
|
113
|
-
Pry::rescue do
|
114
|
-
safely_test
|
115
|
-
end
|
116
|
-
```
|
117
|
-
|
118
|
-
This lets you open a Pry session as part of your normal exception handling. N.B.
|
119
|
-
`Pry::rescued` must always be called from somewhere within a `Pry::rescue`, and the
|
120
|
-
exception object you pass to it must have actually been raised!
|
121
|
-
|
122
122
|
pry-stack explorer
|
123
123
|
==================
|
124
124
|
|
125
125
|
If you're running rubinius, or ruby-1.9, then you can use `pry-rescue` alongside
|
126
|
-
`pry-
|
126
|
+
`pry-stack\_explorer`. This gives you the ability to move `up` or `down` the stack so that
|
127
127
|
you can get a better idea of why your function ended up in a bad state. Run
|
128
128
|
[example2.rb](https://github.com/ConradIrwin/pry-rescue/blob/master/examples/example2.rb) to get a feel for what this is like.
|
129
129
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
*
|
134
|
-
*
|
135
|
-
*
|
136
|
-
*
|
137
|
-
*
|
138
|
-
* jruby
|
139
|
-
*
|
140
|
-
* rubinius (-Xversion=18, -Xversion=19) — some low-level exceptions are missed (e.g. ZeroDivisionError when doing `1 / 0`)
|
130
|
+
Known bugs
|
131
|
+
==========
|
132
|
+
|
133
|
+
* ruby 2.0, 1.9.3, 1.9.2 – no known bugs
|
134
|
+
* ruby 1.9.1 — not supported
|
135
|
+
* ruby 1.8.7 — occasional incorrect values for self
|
136
|
+
* ree 1.8.7 — no known bugs
|
137
|
+
* jruby 1.7 (1.8 mode and 1.9 mode) — no known bugs
|
138
|
+
* jruby 1.6 (1.8 mode and 1.9 mode) — incorrect value for self in NoMethodErrors
|
139
|
+
* rbx (1.8 mode and 1.9 mode) – does not catch some low-level errors (e.g. ZeroDivisionError)
|
141
140
|
|
142
141
|
Meta-fu
|
143
142
|
=======
|
data/bin/rescue
CHANGED
data/lib/pry-rescue/core_ext.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'pry-rescue'
|
2
|
+
class PryRescue
|
3
|
+
# A railtie that inserts PryRescue::Rack at the correct point in the
|
4
|
+
# middleware chain.
|
5
|
+
#
|
6
|
+
# Just adding 'use PryRescue::Rack' inside your rails app will add
|
7
|
+
# the middleware above the rails exception handling middleware,
|
8
|
+
# and so it will not work.
|
9
|
+
class Railtie < ::Rails::Railtie
|
10
|
+
initializer "pry_rescue" do |app|
|
11
|
+
app.config.middleware.use PryRescue::Rack
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/pry-rescue.rb
CHANGED
@@ -6,6 +6,10 @@ require File.expand_path('../pry-rescue/core_ext', __FILE__)
|
|
6
6
|
require File.expand_path('../pry-rescue/commands', __FILE__)
|
7
7
|
require File.expand_path('../pry-rescue/rack', __FILE__)
|
8
8
|
|
9
|
+
if ENV['PRY_RESCUE_RAILS']
|
10
|
+
require File.expand_path('../pry-rescue/rails', __FILE__)
|
11
|
+
end
|
12
|
+
|
9
13
|
begin
|
10
14
|
require 'pry-stack_explorer'
|
11
15
|
rescue LoadError
|
@@ -89,7 +93,9 @@ class PryRescue
|
|
89
93
|
# @param [String] file the absolute path
|
90
94
|
# @return [Boolean]
|
91
95
|
def user_path?(file)
|
92
|
-
!file.start_with?(RbConfig::CONFIG['libdir'])
|
96
|
+
!file.start_with?(RbConfig::CONFIG['libdir']) &&
|
97
|
+
!Gem::Specification.any?{ |gem| file.start_with?(gem.full_gem_path) } &&
|
98
|
+
!(file == '<internal:prelude>')
|
93
99
|
end
|
94
100
|
|
95
101
|
# Remove bindings that are part of Interception/Pry.rescue's internal
|
data/pry-rescue.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'pry-rescue'
|
3
|
-
s.version = '0.9.1
|
3
|
+
s.version = '0.9.1'
|
4
4
|
s.summary = 'Open a pry session on any unhandled exceptions'
|
5
5
|
s.description = 'Allows you to wrap code in Pry::rescue{ } to open a pry session at any unhandled exceptions'
|
6
6
|
s.homepage = 'https://github.com/ConradIrwin/pry-rescue'
|
data/spec/core_ext_spec.rb
CHANGED
@@ -73,6 +73,25 @@ describe 'Pry.rescue' do
|
|
73
73
|
end
|
74
74
|
end.should raise_error /first_occurance/
|
75
75
|
end
|
76
|
+
|
77
|
+
it "should not catch SystemExit" do
|
78
|
+
PryRescue.should_not_receive(:enter_exception_context)
|
79
|
+
|
80
|
+
lambda do
|
81
|
+
Pry::rescue do
|
82
|
+
exit
|
83
|
+
end
|
84
|
+
end.should raise_error SystemExit
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should not catch Ctrl+C' do
|
88
|
+
PryRescue.should_not_receive(:enter_exception_context)
|
89
|
+
lambda do
|
90
|
+
Pry::rescue do
|
91
|
+
raise Interrupt, "ctrl+c (fake)"
|
92
|
+
end
|
93
|
+
end.should raise_error Interrupt
|
94
|
+
end
|
76
95
|
end
|
77
96
|
|
78
97
|
describe "Pry.rescued" do
|
metadata
CHANGED
@@ -1,109 +1,97 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-rescue
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 9
|
8
|
+
- 1
|
9
|
+
version: 0.9.1
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Conrad Irwin
|
9
13
|
- banisterfiend
|
10
14
|
- epitron
|
11
15
|
autorequire:
|
12
16
|
bindir: bin
|
13
17
|
cert_chain: []
|
14
|
-
|
15
|
-
|
16
|
-
|
18
|
+
|
19
|
+
date: 2012-09-30 00:00:00 -07:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
17
23
|
name: pry
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
21
|
-
- - ! '>='
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '0'
|
24
|
-
type: :runtime
|
25
24
|
prerelease: false
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
name: interception
|
34
|
-
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
|
-
requirements:
|
37
|
-
- - ! '>='
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0.3'
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
40
32
|
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: interception
|
41
36
|
prerelease: false
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
-
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 3
|
44
|
+
version: "0.3"
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
49
48
|
name: rspec
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ! '>='
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
|
-
type: :development
|
57
49
|
prerelease: false
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
name: yard
|
66
|
-
requirement: !ruby/object:Gem::Requirement
|
67
|
-
none: false
|
68
|
-
requirements:
|
69
|
-
- - ! '>='
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version: '0'
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
72
57
|
type: :development
|
58
|
+
version_requirements: *id003
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: yard
|
73
61
|
prerelease: false
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
name: redcarpet
|
82
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
|
-
requirements:
|
85
|
-
- - ! '>='
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: '0'
|
62
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
88
69
|
type: :development
|
70
|
+
version_requirements: *id004
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: redcarpet
|
89
73
|
prerelease: false
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
74
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
version: "0"
|
81
|
+
type: :development
|
82
|
+
version_requirements: *id005
|
83
|
+
description: Allows you to wrap code in Pry::rescue{ } to open a pry session at any unhandled exceptions
|
84
|
+
email:
|
99
85
|
- conrad.irwin@gmail.com
|
100
86
|
- jrmair@gmail.com
|
101
87
|
- chris@ill-logic.com
|
102
|
-
executables:
|
88
|
+
executables:
|
103
89
|
- rescue
|
104
90
|
extensions: []
|
91
|
+
|
105
92
|
extra_rdoc_files: []
|
106
|
-
|
93
|
+
|
94
|
+
files:
|
107
95
|
- .gitignore
|
108
96
|
- Gemfile
|
109
97
|
- LICENSE.MIT
|
@@ -118,6 +106,7 @@ files:
|
|
118
106
|
- lib/pry-rescue/commands.rb
|
119
107
|
- lib/pry-rescue/core_ext.rb
|
120
108
|
- lib/pry-rescue/rack.rb
|
109
|
+
- lib/pry-rescue/rails.rb
|
121
110
|
- lib/pry/rescue.rb
|
122
111
|
- pry-rescue.gemspec
|
123
112
|
- spec/commands_spec.rb
|
@@ -130,28 +119,35 @@ files:
|
|
130
119
|
- spec/fixtures/super.rb
|
131
120
|
- spec/fixtures/uri.rb
|
132
121
|
- spec/pry_rescue_spec.rb
|
122
|
+
has_rdoc: true
|
133
123
|
homepage: https://github.com/ConradIrwin/pry-rescue
|
134
124
|
licenses: []
|
125
|
+
|
135
126
|
post_install_message:
|
136
127
|
rdoc_options: []
|
137
|
-
|
128
|
+
|
129
|
+
require_paths:
|
138
130
|
- lib
|
139
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
requirements:
|
148
|
-
- -
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
segments:
|
136
|
+
- 0
|
137
|
+
version: "0"
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
version: "0"
|
151
145
|
requirements: []
|
146
|
+
|
152
147
|
rubyforge_project:
|
153
|
-
rubygems_version: 1.
|
148
|
+
rubygems_version: 1.3.6
|
154
149
|
signing_key:
|
155
150
|
specification_version: 3
|
156
151
|
summary: Open a pry session on any unhandled exceptions
|
157
152
|
test_files: []
|
153
|
+
|