ruby-debug-completion 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,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'rubygems' unless Object.const_defined?(:Gem)
3
+ require File.dirname(__FILE__) + "/lib/ruby-debug/completion"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ruby-debug-completion"
7
+ s.version = Debugger::Completion::VERSION
8
+ s.authors = ["Gabriel Horner"]
9
+ s.email = "gabriel.horner@gmail.com"
10
+ s.homepage = "http://github.com/cldwalker/ruby-debug-completion"
11
+ s.summary = "Mission: autocomplete ruby-debug"
12
+ s.description = "Provides ruby-debug command and subcommand completion with a completion system more powerful than irb's, compliments of bond."
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+ s.rubyforge_project = 'tagaholic'
15
+ s.add_dependency 'bond', '>= 0.2.2'
16
+ s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
17
+ s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
18
+ s.license = 'MIT'
19
+ 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,107 @@
1
+ == Description
2
+
3
+ Provides ruby-debug command and subcommand completion with a completion system
4
+ more powerful than irb's, compliments of {bond}[http://github.com/cldwalker/bond].
5
+
6
+ == Install
7
+
8
+ Install the gem with:
9
+
10
+ sudo gem install ruby-debug-completion
11
+
12
+ == Setup
13
+
14
+ Add this after your `require 'ruby-debug'` line:
15
+
16
+ require 'ruby-debug/completion'
17
+
18
+ Or if you like to debug with one-liners:
19
+
20
+ require 'ruby-debug/completion'; debugger
21
+
22
+ Or if using rdebug:
23
+
24
+ rdebug -r ruby-debug/completion FILE
25
+
26
+ == Usage
27
+
28
+ In a ruby program gone far far astray:
29
+
30
+ (rdb:1) [TAB]
31
+ backtrace delete enable help next quit show trace
32
+ break disable eval info p reload source undisplay
33
+ catch display exit irb pp restart step up
34
+ condition down finish list ps save thread var
35
+ continue edit frame method putl set tmate where
36
+
37
+ Note: This default completion also autocompletes instance variables and local variables in the
38
+ current debugger binding.
39
+
40
+ What info does ruby-debug provide?
41
+
42
+ (rdb:1) info [TAB]
43
+ args display global_variables locals thread
44
+ breakpoints file instance_variables program threads
45
+ catch files line stack variables
46
+
47
+ (rdb: 1) info d[TAB]
48
+ (rdb: 1) info display
49
+
50
+ What settings can I change?
51
+
52
+ (rdb:1) set [TAB]
53
+ annotate autolist forcestep linetrace width
54
+ args basename fullpath linetrace+
55
+ autoeval callstyle history listsize
56
+ autoirb debuggertesting keep-frame-bindings trace
57
+
58
+ (rdb:1) set d[TAB]
59
+ (rdb:1) set debuggertesting
60
+
61
+ Since I have autoeval on, can I autocomplete as if I were in irb?
62
+
63
+ (rdb:1) com[TAB]
64
+ (rdb:1) completion_toggle
65
+
66
+ (rdb:1) [TAB]
67
+ Display all 347 possibilities? (y or n)
68
+
69
+ (rdb:1) De[TAB]
70
+ (rdb:1) Debugger
71
+ (rdb:1) Debugger.[TAB]
72
+ Display all 137 possibilities? (y or n)
73
+
74
+ (rdb:1) require 'ab[TAB]
75
+ (rdb:1) require 'abbrev.rb'
76
+
77
+ Huh? Argument autocompletion?
78
+ See {bond}[http://github.com/cldwalker/bond] for all that you can autocomplete.
79
+
80
+ Can I go back to basic ruby-debug completion?
81
+
82
+ # Invoke completion_toggle again
83
+ (rdb:1) ct # alias for completion_toggle
84
+ (rdb:1) [TAB]
85
+ backtrace delete enable help next quit show trace
86
+ break disable eval info p reload source undisplay
87
+ catch display exit irb pp restart step up
88
+ condition down finish list ps save thread var
89
+ continue edit frame method putl set tmate where
90
+
91
+ Please, can I just quit quickly without a prompt?
92
+
93
+ (rdb:1) q [TAB]
94
+ (rdb:1) q unconditionally
95
+
96
+ == Limitations
97
+
98
+ This gem doesn't have ruby-debug as a dependency since ruby-debug is split across two gems
99
+ (ruby-debug and ruby-debug19), dependent on ruby versions. This gem will work with either one.
100
+
101
+ == Todo
102
+
103
+ * Completion of local variable methods
104
+
105
+ == Bugs/Issues
106
+
107
+ Please report them {on github}[http://github.com/cldwalker/ruby-debug-completion/issues].
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/deps.rip ADDED
@@ -0,0 +1 @@
1
+ bond >=0.2.2
@@ -0,0 +1,76 @@
1
+ require 'ruby-debug'
2
+ require 'bond'
3
+
4
+ module Debugger
5
+ module Completion
6
+ extend self
7
+ VERSION = '0.1.0'
8
+ COMMANDS = [ "backtrace", "break", "catch", "condition", "continue",
9
+ "delete", "disable", "display", "down", "edit", "enable", "eval", "exit",
10
+ "finish", "frame", "help", "info", "irb", "list", "method", "next",
11
+ "p", "pp", "ps", "putl", "quit", "reload", "restart", "save", "set",
12
+ "show", "source", "step", "thread", "tmate", "trace", "undisplay",
13
+ "up", "var", "where"
14
+ ]
15
+ COMMANDS << ['jump'] if RUBY_VERSION >= '1.9'
16
+
17
+ def start
18
+ Bond.start(:default_mission=>lambda {|e| Debugger::Completion.default_action }) do
19
+ complete(:methods=>%w{catch cat}) { objects_of(Class).select {|e| e < StandardError } }
20
+ complete(:methods=>%w{disable enable}) { %w{breakpoints display} }
21
+ complete(:methods=>['help', 'h']) { Debugger::Completion.commands }
22
+ complete(:method=>'info') { %w{args breakpoints catch display file files} +
23
+ %w{global_variables instance_variables line locals program stack thread} +
24
+ %w{threads variables}
25
+ }
26
+ complete(:methods=>%w{set show}) { %w{annotate args autoeval autolist autoirb} +
27
+ %w{basename callstyle debuggertesting forcestep fullpath history} +
28
+ %w{keep-frame-bindings linetrace+ linetrace listsize trace width}
29
+ }
30
+ complete(:methods=>%w{quit exit q}) { %w{unconditionally} }
31
+ complete(:methods=>%w{save source}, :action=>:files)
32
+ complete(:methods=>%w{thread th}) { %w{list stop resume switch current} }
33
+ complete(:methods=>%w{trace tr}) { %w{on off var} }
34
+ complete(:methods=>%w{var v}) { %w{class const global instance local} }
35
+ end
36
+ end
37
+
38
+ def commands; COMMANDS; end
39
+
40
+ def default_action
41
+ completions = commands + ['completion_toggle']
42
+ if @irb_completion
43
+ eval_string = "methods | private_methods | local_variables | " +
44
+ "self.class.constants | instance_variables"
45
+ completions += debugger_eval(eval_string) | Object.constants |
46
+ Bond::DefaultMission::ReservedWords
47
+ else
48
+ completions += debugger_eval("local_variables | instance_variables")
49
+ end
50
+ completions
51
+ end
52
+
53
+ def debugger_eval(string)
54
+ bdg = (cmd = first_object(Debugger::Command)) ? cmd.send(:get_binding) : TOPLEVEL_BINDING
55
+ eval string, bdg
56
+ end
57
+
58
+ def first_object(klass)
59
+ ObjectSpace.each_object(klass) {|e| return e }
60
+ end
61
+
62
+ def toggle_irb_completion
63
+ @irb_completion = !@irb_completion
64
+ end
65
+
66
+ module Command
67
+ def completion_toggle
68
+ Completion.toggle_irb_completion
69
+ end
70
+ alias_method :ct, :completion_toggle
71
+ end
72
+ end
73
+ end
74
+
75
+ Object.send :include, Debugger::Completion::Command
76
+ Debugger::Completion.start
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-debug-completion
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-09-20 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: bond
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 19
30
+ segments:
31
+ - 0
32
+ - 2
33
+ - 2
34
+ version: 0.2.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Provides ruby-debug command and subcommand completion with a completion system more powerful than irb's, compliments of bond.
38
+ email: gabriel.horner@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.rdoc
45
+ - LICENSE.txt
46
+ files:
47
+ - lib/ruby-debug/completion.rb
48
+ - LICENSE.txt
49
+ - CHANGELOG.rdoc
50
+ - README.rdoc
51
+ - deps.rip
52
+ - Rakefile
53
+ - .gemspec
54
+ has_rdoc: true
55
+ homepage: http://github.com/cldwalker/ruby-debug-completion
56
+ licenses:
57
+ - MIT
58
+ post_install_message:
59
+ rdoc_options: []
60
+
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ hash: 3
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 23
78
+ segments:
79
+ - 1
80
+ - 3
81
+ - 6
82
+ version: 1.3.6
83
+ requirements: []
84
+
85
+ rubyforge_project: tagaholic
86
+ rubygems_version: 1.3.7
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: "Mission: autocomplete ruby-debug"
90
+ test_files: []
91
+