pry-exception_explorer 0.1.0pre1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ pry-exception_explorer
2
+ ===========
3
+
4
+ (C) John Mair (banisterfiend) 2011
5
+
6
+ FIXME: _tagline_
7
+
8
+ FIXME: _description goes here_
9
+
10
+ * Install the [gem](https://rubygems.org/gems/pry-exception_explorer): `gem install pry-exception_explorer`
11
+ * Read the [documentation](http://rdoc.info/github/banister/pry-exception_explorer/master/file/README.md)
12
+ * See the [source code](http://github.com/banister/pry-exception_explorer)
13
+
14
+ Example: Example description
15
+ --------
16
+
17
+ Example preamble
18
+
19
+ puts "example code"
20
+
21
+ Features and limitations
22
+ -------------------------
23
+
24
+ Feature List Preamble
25
+
26
+ Contact
27
+ -------
28
+
29
+ Problems or questions contact me at [github](http://github.com/banister)
30
+
31
+
32
+ License
33
+ -------
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2011 John Mair (banisterfiend)
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining
40
+ a copy of this software and associated documentation files (the
41
+ 'Software'), to deal in the Software without restriction, including
42
+ without limitation the rights to use, copy, modify, merge, publish,
43
+ distribute, sublicense, and/or sell copies of the Software, and to
44
+ permit persons to whom the Software is furnished to do so, subject to
45
+ the following conditions:
46
+
47
+ The above copyright notice and this permission notice shall be
48
+ included in all copies or substantial portions of the Software.
49
+
50
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
51
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
53
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
54
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
55
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
56
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,76 @@
1
+ $:.unshift 'lib'
2
+
3
+ dlext = Config::CONFIG['DLEXT']
4
+ direc = File.dirname(__FILE__)
5
+
6
+ PROJECT_NAME = "pry-exception_explorer"
7
+
8
+ require 'rake/clean'
9
+ require 'rake/gempackagetask'
10
+ require "#{PROJECT_NAME}/version"
11
+
12
+ CLOBBER.include("**/*~", "**/*#*", "**/*.log")
13
+ CLEAN.include("**/*#*", "**/*#*.*", "**/*_flymake*.*", "**/*_flymake",
14
+ "**/*.rbc", "**/.#*.*")
15
+
16
+ def apply_spec_defaults(s)
17
+ s.name = PROJECT_NAME
18
+ s.summary = "FIX ME"
19
+ s.version = PryExceptionExplorer::VERSION
20
+ s.date = Time.now.strftime '%Y-%m-%d'
21
+ s.author = "John Mair (banisterfiend)"
22
+ s.email = 'jrmair@gmail.com'
23
+ s.description = s.summary
24
+ s.require_path = 'lib'
25
+ s.homepage = "https://github.com/banister/pry-exception_explorer"
26
+ s.add_dependency('pry-stack_explorer')
27
+ s.files = Dir["lib/**/*.rb", "test/*.rb", "CHANGELOG", "README.md", "Rakefile"]
28
+ end
29
+
30
+ desc "run pry with plugin enabled"
31
+ task :pry do
32
+ exec("pry -I#{direc}/lib/ -r #{direc}/lib/#{PROJECT_NAME}")
33
+ end
34
+
35
+ desc "reinstall gem"
36
+ task :reinstall => :gems do
37
+ sh "gem uninstall pry-exception_explorer"
38
+ sh "gem install #{direc}/pkg/pry-exception_explorer-#{PryExceptionExplorer::VERSION}.gem"
39
+ end
40
+
41
+ desc "run tests"
42
+ task :test do
43
+ sh "bacon -Itest -rubygems -a"
44
+ end
45
+
46
+ namespace :ruby do
47
+ spec = Gem::Specification.new do |s|
48
+ apply_spec_defaults(s)
49
+ s.platform = Gem::Platform::RUBY
50
+ end
51
+
52
+ Rake::GemPackageTask.new(spec) do |pkg|
53
+ pkg.need_zip = false
54
+ pkg.need_tar = false
55
+ end
56
+ end
57
+
58
+ desc "shorthand for :gems task"
59
+ task :gem => :gems
60
+
61
+ desc "build all platform gems at once"
62
+ task :gems => [:clean, :rmgems, "ruby:gem"]
63
+
64
+ desc "remove all platform gems"
65
+ task :rmgems => ["ruby:clobber_package"]
66
+
67
+ desc "build and push latest gems"
68
+ task :pushgems => :gems do
69
+ chdir("#{File.dirname(__FILE__)}/pkg") do
70
+ Dir["*.gem"].each do |gemfile|
71
+ sh "gem push #{gemfile}"
72
+ end
73
+ end
74
+ end
75
+
76
+
@@ -0,0 +1,68 @@
1
+ # pry-exception_explorer.rb
2
+ # (C) John Mair (banisterfiend); MIT license
3
+
4
+ require 'pry-stack_explorer'
5
+ require "pry-exception_explorer/version"
6
+ require "pry"
7
+
8
+ if RUBY_VERSION =~ /1.9/
9
+ require 'continuation'
10
+ end
11
+
12
+ class Exception
13
+ NoContinuation = Class.new(StandardError)
14
+
15
+ attr_accessor :continuation
16
+ attr_accessor :exception_call_stack
17
+
18
+ def continue
19
+ raise NoContinuation unless continuation.respond_to?(:call)
20
+ continuation.call
21
+ end
22
+ end
23
+
24
+ class Object
25
+ def raise(exception = RuntimeError, string = nil, array = caller)
26
+ if exception.is_a?(String)
27
+ string = exception
28
+ exception = RuntimeError
29
+ end
30
+
31
+ ex = exception.exception(string)
32
+ ex.set_backtrace(array)
33
+ ex.exception_call_stack = binding.callers.tap(&:shift)
34
+
35
+ callcc do |cc|
36
+ ex.continuation = cc
37
+ super(ex)
38
+ end
39
+ end
40
+ end
41
+
42
+ PryExceptionExplorer::Commands = Pry::CommandSet.new do
43
+
44
+ command "enter-exception", "Enter the context of the last exception" do
45
+ PryStackExplorer.push_and_create_frame_manager(_pry_.last_exception.exception_call_stack, _pry_)
46
+ PryStackExplorer.frame_manager(_pry_).user[:exception] = _pry_.last_exception
47
+ PryStackExplorer.frame_manager(_pry_).refresh_frame
48
+ end
49
+
50
+ command "exit-exception", "Leave the context of the current exception." do
51
+ PryStackExplorer.pop_frame_manager(_pry_)
52
+ PryStackExplorer.frame_manager(_pry_).refresh_frame
53
+ end
54
+
55
+ command "continue-exception", "Attempt to continue the current exception." do
56
+ ex = PryStackExplorer.frame_manager(_pry_).user[:exception]
57
+
58
+ if ex && ex.continuation
59
+ PryStackExplorer.pop_frame_manager(_pry_)
60
+ ex.continue
61
+ else
62
+ output.puts "No exception to continue!"
63
+ end
64
+ end
65
+
66
+ end
67
+
68
+ Pry.config.commands.import PryExceptionExplorer::Commands
@@ -0,0 +1,13 @@
1
+ Pry::CLI.add_options do
2
+
3
+ on :w, :wrap, "Run the script wrapped by the exception explorer", true do |file|
4
+ require 'pry-exception_explorer/exception_wrap'
5
+
6
+ PryExceptionExplorer.wrap do
7
+ require file
8
+ end
9
+
10
+ exit
11
+ end
12
+
13
+ end
@@ -0,0 +1,17 @@
1
+ require 'pry_stack_explorer'
2
+
3
+ Pry.config.hooks.delete_hook(:when_started, :save_caller_bindings)
4
+
5
+ module PryExceptionExplorer
6
+ def self.wrap
7
+ yield
8
+ rescue Exception => ex
9
+ Pry.config.hooks.add_hook(:when_started, :setup_exception_context) do |binding_stack, _pry_|
10
+ binding_stack.replace([ex.exception_call_stack.first])
11
+ PryStackExplorer.push_and_create_frame_manager(ex.exception_call_stack, _pry_)
12
+ PryStackExplorer.frame_manager(_pry_).user[:exception] = ex
13
+ end
14
+
15
+ pry
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module PryExceptionExplorer
2
+ VERSION = "0.1.0pre1"
3
+ end
data/test/test.rb ADDED
@@ -0,0 +1,12 @@
1
+ direc = File.dirname(__FILE__)
2
+
3
+ require 'rubygems'
4
+ require "#{direc}/../lib/pry-exception_explorer"
5
+ require 'bacon'
6
+
7
+ puts "Testing pry-exception_explorer version #{PryExceptionExplorer::VERSION}..."
8
+ puts "Ruby version: #{RUBY_VERSION}"
9
+
10
+ describe PryExceptionExplorer do
11
+ end
12
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pry-exception_explorer
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 5
5
+ version: 0.1.0pre1
6
+ platform: ruby
7
+ authors:
8
+ - John Mair (banisterfiend)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-12-15 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: pry-stack_explorer
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: FIX ME
27
+ email: jrmair@gmail.com
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files: []
33
+
34
+ files:
35
+ - lib/pry-exception_explorer/cli.rb
36
+ - lib/pry-exception_explorer/exception_wrap.rb
37
+ - lib/pry-exception_explorer/version.rb
38
+ - lib/pry-exception_explorer.rb
39
+ - test/test.rb
40
+ - CHANGELOG
41
+ - README.md
42
+ - Rakefile
43
+ homepage: https://github.com/banister/pry-exception_explorer
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options: []
48
+
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">"
61
+ - !ruby/object:Gem::Version
62
+ version: 1.3.1
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.8.11
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: FIX ME
70
+ test_files: []
71
+