pry-rescue 1.3.1 → 1.4.0

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
  SHA1:
3
- metadata.gz: aec329b9d216dafb0012eaf46168f6457135a5a0
4
- data.tar.gz: 1b66f5750440d7eb15000ae6c61fb5983b642f69
3
+ metadata.gz: 008a4a4f62d94f4b5cf467c311f520979131feae
4
+ data.tar.gz: 79f4cd04eb646a813ce15b4eea2adbd72b00b81c
5
5
  SHA512:
6
- metadata.gz: adbd9e19cea95c2cad6909cf44259b3c75ba393a87ce713c60c0a73722fcf7fad6855166960c740b665b4d02454bcbafa4f418f722c95a334da7b7b7434a6207
7
- data.tar.gz: 05db0a2e1bba186da0ce8d511c87a89dd97e4f4b7a4fbcbab9bf2abb6eaa0a3f2edbf9912c7d57ca4cc6588dfb7c9ebbe96c2c8c9a9e960d395bcd9d198a4a7b
6
+ metadata.gz: c5a9cc31ce909e9e79bc5fe46700337cbaf236147f78e058ae74452290d2c27b5a9b09fda7a251d36f9a4d51decc10d88bacc14867d50ea94c7902696f6f5940
7
+ data.tar.gz: 5f309de666004631feba445d965e9aed2b2d8e3bcd1e7663531c88dd3f1fcf00b57fa07c72ac98131d061f4c0a6492de33109f7058faa25803a32f09776e0850
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
4
  - 1.9.3
4
5
  - 2.0.0
5
6
  - 2.1.0
6
- - rbx-19mode
7
+ - rbx
data/bin/rescue CHANGED
@@ -4,7 +4,7 @@ USAGE = %{
4
4
  rescue (pry-rescue wrapper)
5
5
 
6
6
  Usage:
7
- rescue [--peek] <script.rb> [arguments...]
7
+ rescue [-i] <script.rb> [arguments...]
8
8
 
9
9
  What it does:
10
10
  Runs <script.rb>, and if an uncaught exception is raised,
@@ -13,16 +13,23 @@ What it does:
13
13
 
14
14
  You can then poke around to figure out why your code broke!
15
15
 
16
- If --peek is specified, then you can hit <Ctrl+C> to interrupt
17
- your program and open a pry session at any time you need.
16
+ If -i is specified, then rescue will open a REPL whether or
17
+ not there was an exception. Specifying -i will also wrap
18
+ Kernel.at_exit and run exit callbacks before launching the
19
+ REPL if the script succeeds. This is useful for minitest and
20
+ other testing frameworks.
18
21
 
19
22
  See the README (http://bitly.com/pry-rescue) for more.
20
23
  }
24
+
25
+ ensure_repl = false
26
+
21
27
  case ARGV[0]
22
28
  when '-h', '--help'
23
29
  puts USAGE
24
30
  exit
25
- when '--'
31
+ when '-i'
32
+ ensure_repl = true
26
33
  ARGV.shift
27
34
  when /\A-/
28
35
  puts USAGE
@@ -39,7 +46,7 @@ if script = ARGV.shift
39
46
  $0 = File.expand_path(script)
40
47
  if File.exists? script
41
48
  require File.expand_path('../../lib/pry-rescue.rb', __FILE__)
42
- PryRescue.load $0
49
+ PryRescue.load $0, ensure_repl
43
50
  else
44
51
  $stderr.puts "Error: #{script.inspect} not found."
45
52
  end
data/lib/pry-rescue.rb CHANGED
@@ -38,10 +38,12 @@ end
38
38
  # @see {Pry::rescue}
39
39
  class PryRescue
40
40
  class << self
41
+ attr_accessor :any_exception_captured
41
42
 
42
43
  # Start a Pry session in the context of the exception.
43
44
  # @param [Exception] exception The exception raised
44
45
  def enter_exception_context(exception)
46
+ @any_exception_captured = true
45
47
  @exception_context_depth ||= 0
46
48
  @exception_context_depth += 1
47
49
 
@@ -66,8 +68,15 @@ class PryRescue
66
68
 
67
69
  # Load a script wrapped in Pry::rescue{ }
68
70
  # @param [String] script The name of the script
69
- def load(script)
70
- Pry::rescue{ Kernel.load script }
71
+ def load(script, ensure_repl = false)
72
+ require File.expand_path('../pry-rescue/kernel_exit_hooks.rb', __FILE__) if ensure_repl
73
+ Pry::rescue do
74
+ begin
75
+ TOPLEVEL_BINDING.eval File.read(script), script, 1
76
+ rescue SyntaxError => exception
77
+ puts "#{exception}\n"
78
+ end
79
+ end
71
80
  end
72
81
 
73
82
  # Is the user currently inside pry rescue?
@@ -0,0 +1,20 @@
1
+ class << PryRescue
2
+ def exit_callbacks
3
+ @exit_callbacks ||= []
4
+ end
5
+
6
+ def run_exit_callbacks
7
+ Pry::rescue do
8
+ exit_callbacks.dup.each(&:call)
9
+ end
10
+ TOPLEVEL_BINDING.pry unless any_exception_captured
11
+ end
12
+ end
13
+
14
+ Kernel.at_exit { PryRescue.run_exit_callbacks }
15
+
16
+ module Kernel
17
+ def at_exit(&block)
18
+ PryRescue.exit_callbacks.push block
19
+ end
20
+ end
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 = '1.3.1'
3
+ s.version = '1.4.0'
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'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-rescue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conrad Irwin
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-01-22 00:00:00.000000000 Z
13
+ date: 2014-02-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pry
@@ -157,6 +157,7 @@ files:
157
157
  - lib/pry-rescue/cli.rb
158
158
  - lib/pry-rescue/commands.rb
159
159
  - lib/pry-rescue/core_ext.rb
160
+ - lib/pry-rescue/kernel_exit_hooks.rb
160
161
  - lib/pry-rescue/minitest.rb
161
162
  - lib/pry-rescue/peek.rb
162
163
  - lib/pry-rescue/peek/exit.rb