ripl-debug 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems' unless Object.const_defined?(:Gem)
3
+ require File.dirname(__FILE__) + "/lib/ripl/debug"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ripl-debug"
7
+ s.version = Ripl::Debug::VERSION
8
+ s.authors = ["Gabriel Horner"]
9
+ s.email = "gabriel.horner@gmail.com"
10
+ s.homepage = "http://github.com/cldwalker/ripl-debug"
11
+ s.summary = "A ripl plugin that automatically passes a failed eval to ruby-debug"
12
+ s.description = "This ripl plugin automatically starts the debugger whenever an evaled input throws an exception. The debugger is started at the source of the exception."
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.rubyforge_project = 'tagaholic'
15
+ s.executables = ['ripl-debug']
16
+ s.add_dependency 'ripl', '>= 0.2.7'
17
+ s.add_dependency 'ruby-debug'
18
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
19
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
20
+ s.license = 'MIT'
21
+ end
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,2 @@
1
+ == 0.1.0
2
+ * Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT LICENSE
2
+
3
+ Copyright (c) 2010 Gabriel Horner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ == Description
2
+ This ripl plugin automatically starts the debugger whenever an evaled input throws an exception.
3
+ The debugger is started at the source of the exception.
4
+
5
+ == Install
6
+ Install the gem with:
7
+
8
+ sudo gem install ripl-debug
9
+
10
+ == Usage
11
+
12
+ To debug some suspect code
13
+
14
+ $ ripl debug -rsome/buggy/code
15
+
16
+ This plugin can be turned off in the console at any time with:
17
+
18
+ >> Ripl.config[:debug] = false
19
+
20
+ == Limitations
21
+ * Doesn't currently work for multi-line evaluation
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rake'
2
+ require 'fileutils'
3
+
4
+ def gemspec
5
+ @gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
6
+ end
7
+
8
+ desc "Build the gem"
9
+ task :gem=>:gemspec do
10
+ sh "gem build .gemspec"
11
+ FileUtils.mkdir_p 'pkg'
12
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
13
+ end
14
+
15
+ desc "Install the gem locally"
16
+ task :install => :gem do
17
+ sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
18
+ end
19
+
20
+ desc "Generate the gemspec"
21
+ task :generate do
22
+ puts gemspec.to_ruby
23
+ end
24
+
25
+ desc "Validate the gemspec"
26
+ task :gemspec do
27
+ gemspec.validate
28
+ end
29
+
30
+ desc 'Run tests'
31
+ task :test do |t|
32
+ sh 'bacon -q -Ilib -I. test/*_test.rb'
33
+ end
34
+
35
+ task :default => :test
data/bin/ripl-debug ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'ripl'
4
+ require 'ripl/debug'
5
+ Ripl.start
data/deps.rip ADDED
@@ -0,0 +1,2 @@
1
+ ripl >=0.2.7
2
+ ruby-debug >=0
data/lib/ripl/debug.rb ADDED
@@ -0,0 +1,40 @@
1
+ require 'ripl'
2
+
3
+ module Ripl
4
+ module Debug
5
+ VERSION = '0.1.0'
6
+
7
+ def before_loop
8
+ super
9
+ require 'ruby-debug'
10
+ Debugger.run_init_script(StringIO.new)
11
+ end
12
+
13
+ def loop_eval(input)
14
+ if config[:debug]
15
+ # move local variables outside of with_post_mortem
16
+ input = (set_var_string = input.to_s[/^\s*\w+\s*=\s+/]) ?
17
+ "#{set_var_string} with_post_mortem { #{input.sub(set_var_string, '')} }" :
18
+ "with_post_mortem { #{input} }"
19
+ end
20
+ super(input)
21
+ end
22
+
23
+ module Commands
24
+ # from http://simple-and-basic.com/2009/02/catching-and-examining-exceptions-in-a-irb-session.html
25
+ def with_post_mortem
26
+ Debugger.start
27
+ result = nil
28
+ Debugger.post_mortem do
29
+ result = yield
30
+ end
31
+ Debugger.stop
32
+ result
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ Ripl::Shell.send :include, Ripl::Debug
39
+ Ripl::Commands.send :include, Ripl::Debug::Commands
40
+ Ripl.config[:debug] = true
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ripl-debug
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Gabriel Horner
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-04 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: ripl
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 7
34
+ version: 0.2.7
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: ruby-debug
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ description: This ripl plugin automatically starts the debugger whenever an evaled input throws an exception. The debugger is started at the source of the exception.
52
+ email: gabriel.horner@gmail.com
53
+ executables:
54
+ - ripl-debug
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - README.rdoc
59
+ - LICENSE.txt
60
+ files:
61
+ - lib/ripl/debug.rb
62
+ - bin/ripl-debug
63
+ - LICENSE.txt
64
+ - CHANGELOG.rdoc
65
+ - README.rdoc
66
+ - deps.rip
67
+ - Rakefile
68
+ - .gemspec
69
+ has_rdoc: true
70
+ homepage: http://github.com/cldwalker/ripl-debug
71
+ licenses:
72
+ - MIT
73
+ post_install_message:
74
+ rdoc_options: []
75
+
76
+ require_paths:
77
+ - lib
78
+ required_ruby_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 23
93
+ segments:
94
+ - 1
95
+ - 3
96
+ - 6
97
+ version: 1.3.6
98
+ requirements: []
99
+
100
+ rubyforge_project: tagaholic
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: A ripl plugin that automatically passes a failed eval to ruby-debug
105
+ test_files: []
106
+