Commit c77f281ce37faf071b1de6fd71ab7b9dd8b118a5

Heavy duty refactoring of RemoteDebugger code. It was an absolute scatter brained mess and really needed some cleaning up

Commit diff

Commands/App server in terminal window.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>bundleUUID</key>
8 <string>255629A2-F227-467B-91B3-21D145908E78</string>
9 <key>command</key>
10 <string>#!/usr/bin/env ruby
11require 'rubygems'
12require 'appscript'
13include Appscript
14term = app("Terminal")
15term.activate
16term.do_script "cd #{ENV['TM_PROJECT_DIRECTORY']} &amp;&amp; script/server; exit"</string>
17 <key>input</key>
18 <string>none</string>
19 <key>name</key>
20 <string>App server in terminal window</string>
21 <key>output</key>
22 <string>showAsTooltip</string>
23 <key>uuid</key>
24 <string>E5691206-A639-4536-989C-F227B9AB14B0</string>
25</dict>
26</plist>
toggle raw diff

Commands/Debug - App server in terminal window.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/ruby_amp.rb"
10
11project_directory = ENV['TM_PROJECT_DIRECTORY']
12rails_script_server = File.join(project_directory, "script/server")
13
14# Try and be smart about which one to start up (merb or rails)
15file_to_load = File.exists?( rails_script_server ) ? rails_script_server : (ENV['MERB_PATH'] || `which merb`)
16
17run_file = RubyAMP::RemoteDebugger.prepare_debug_wrapper &lt;&lt;-EOF
18 load #{file_to_load.inspect}
19EOF
20
21RubyAMP::Launcher.open_debug_process_in_terminal(run_file)
22sleep 0.25
23RubyAMP::Launcher.open_controller_terminal</string>
24 <key>input</key>
25 <string>selection</string>
26 <key>name</key>
27 <string>Debug - App server in terminal window</string>
28 <key>output</key>
29 <string>showAsTooltip</string>
30 <key>uuid</key>
31 <string>52CB8CE8-550B-4871-9852-86A1A0567FB7</string>
32</dict>
33</plist>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as YAML.tmCommand

 
77 <key>command</key>
88 <string>#!/usr/bin/env ruby
99
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11d = RubyAMP::RemoteDebugger.new
12exit unless d.connected?
1113
12i = RDebugInspect.new
13
14IO.popen('pbcopy', 'w'){ |pb| pb.puts( i.inspect_as_yaml )};
15
16puts "Copied value of #{i.what} to clipboard"</string>
14what = RubyAMP::Inspect.get_selection
15RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :yaml))
16puts "Copied value of #{what} to clipboard"</string>
1717 <key>input</key>
1818 <string>document</string>
1919 <key>keyEquivalent</key>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as pretty print.tmCommand

 
77 <key>command</key>
88 <string>#!/usr/bin/env ruby
99
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11d = RubyAMP::RemoteDebugger.new
12exit unless d.connected?
1113
12i = RDebugInspect.new
13
14IO.popen('pbcopy', 'w'){ |pb| pb.puts( i.inspect_as_pp )};
15
16puts "Copied value of #{i.what} to clipboard"</string>
14what = RubyAMP::Inspect.get_selection
15RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :pp))
16puts "Copied value of #{what} to clipboard"</string>
1717 <key>input</key>
1818 <string>document</string>
1919 <key>keyEquivalent</key>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as string.tmCommand

 
77 <key>command</key>
88 <string>#!/usr/bin/env ruby
99
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11d = RubyAMP::RemoteDebugger.new
12exit unless d.connected?
1113
12i = RDebugInspect.new
13
14IO.popen('pbcopy', 'w'){ |pb| pb &lt;&lt; ( i.inspect_as_string )};
15
16puts "Copied value of #{i.what} to clipboard"
17</string>
14what = RubyAMP::Inspect.get_selection
15RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :string))
16puts "Copied value of #{what} to clipboard"</string>
1817 <key>input</key>
1918 <string>document</string>
2019 <key>keyEquivalent</key>
toggle raw diff

Commands/Debug - Current File.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/ruby_amp.rb"
10RubyAMP::Launcher.open_controller_terminal
11
12ARGV &lt;&lt; "-s"
13ARGV &lt;&lt; RubyAMP::RemoteDebugger.prepare_debug_wrapper("load #{ENV['TM_FILEPATH'].to_s.inspect}")
14
15require 'rubygems'
16require 'ruby-debug'
17load 'rdebug'</string>
18 <key>fallbackInput</key>
19 <string>line</string>
20 <key>input</key>
21 <string>selection</string>
22 <key>keyEquivalent</key>
23 <string>@d</string>
24 <key>name</key>
25 <string>Debug - Run current file</string>
26 <key>output</key>
27 <string>showAsHTML</string>
28 <key>scope</key>
29 <string>source.ruby</string>
30 <key>uuid</key>
31 <string>61FE0786-CB5F-4E8F-8DFD-03C0128CDE50</string>
32</dict>
33</plist>
toggle raw diff

Commands/Debug - Delete All Breakpoints.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11
12d = RubyAMP::RemoteDebugger.new
13
14count_breakpoints = d.evaluate("Debugger.breakpoints.length", :control)
15if count_breakpoints == 0
16 puts "There are no breakpoints set"
17 exit
18end
19
20d.evaluate("Debugger.breakpoints.map{ |b| b.id }.each { |b_id| Debugger.remove_breakpoint(b_id) }", :control)
21
22new_count_breakpoints = d.evaluate("Debugger.breakpoints.length", :control)
23if new_count_breakpoints == 0
24 puts "Deleted all #{count_breakpoints} breakpoint(s)"
25else
26 puts "Error deleting breakpoints."
27end</string>
28 <key>fallbackInput</key>
29 <string>line</string>
30 <key>input</key>
31 <string>selection</string>
32 <key>keyEquivalent</key>
33 <string>^@b</string>
34 <key>name</key>
35 <string>Debug - Delete All Breakpoints</string>
36 <key>output</key>
37 <string>showAsTooltip</string>
38 <key>uuid</key>
39 <string>5193D698-4392-494D-946B-7D9BF1B7C9CA</string>
40</dict>
41</plist>
toggle raw diff

Commands/Debug - Inspect with pretty print.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11d = RubyAMP::RemoteDebugger.new
12exit unless d.connected?
13
14what = RubyAMP::Inspect.get_selection
15
16puts "#{what} = \n#{d.inspect(what, :pp)}"
17</string>
18 <key>fallbackInput</key>
19 <string>word</string>
20 <key>input</key>
21 <string>document</string>
22 <key>keyEquivalent</key>
23 <string>^i</string>
24 <key>name</key>
25 <string>Debug - Inspect with pretty print</string>
26 <key>output</key>
27 <string>showAsTooltip</string>
28 <key>uuid</key>
29 <string>1236EAB2-B06B-4969-ABEC-6121A0873A14</string>
30</dict>
31</plist>
toggle raw diff

Commands/Debug - Quit Debugger.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11d = RubyAMP::RemoteDebugger.new
12exit unless d.connected?
13
14d.command("quit")
15puts "Debugger Quit"</string>
16 <key>fallbackInput</key>
17 <string>line</string>
18 <key>input</key>
19 <string>selection</string>
20 <key>keyEquivalent</key>
21 <string>^\</string>
22 <key>name</key>
23 <string>Debug - Quit Debugger</string>
24 <key>output</key>
25 <string>showAsTooltip</string>
26 <key>uuid</key>
27 <string>EE3408D4-BDCB-45BA-BED6-C0A4A9E0EC09</string>
28</dict>
29</plist>
toggle raw diff

Commands/Debug - RSpec Examples.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/rspec_debugger.rb"
10
11debug_rspec(:file)</string>
12 <key>fallbackInput</key>
13 <string>line</string>
14 <key>input</key>
15 <string>selection</string>
16 <key>keyEquivalent</key>
17 <string>@d</string>
18 <key>name</key>
19 <string>Debug - RSpec Examples</string>
20 <key>output</key>
21 <string>showAsHTML</string>
22 <key>scope</key>
23 <string>source.ruby.rspec</string>
24 <key>uuid</key>
25 <string>95931CFC-B32A-46A6-9214-CA33D2880981</string>
26</dict>
27</plist>
toggle raw diff

Commands/Debug - Run current file in terminal window.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/ruby_amp.rb"
10
11run_file = RubyAMP::RemoteDebugger.prepare_debug_wrapper &lt;&lt;-EOF
12 require #{ENV['TM_FILEPATH'].to_s.inspect}
13EOF
14RubyAMP::Launcher.open_debug_process_in_terminal(run_file)
15sleep 0.25
16RubyAMP::Launcher.open_controller_terminal
17</string>
18 <key>input</key>
19 <string>selection</string>
20 <key>name</key>
21 <string>Debug - Run current file in terminal window</string>
22 <key>output</key>
23 <string>showAsTooltip</string>
24 <key>scope</key>
25 <string>source.ruby</string>
26 <key>uuid</key>
27 <string>63EE6C97-8064-466C-B981-B4430CDB1A40</string>
28</dict>
29</plist>
toggle raw diff

Commands/Debug - Set Breakpoint at Current Line.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11
12d = RubyAMP::RemoteDebugger.new
13exit unless d.connected?
14
15result = d.evaluate &lt;&lt;-EOF, :control
16 bp = Debugger.add_breakpoint #{ENV['TM_FILEPATH'].to_s.inspect}, #{ENV['TM_LINE_NUMBER']}
17 if bp
18 "Set breakpoint at \#{bp.source}:\#{bp.pos}"
19 else
20 "Failed to set breakpoint."
21 end
22EOF
23
24puts result
25</string>
26 <key>fallbackInput</key>
27 <string>line</string>
28 <key>input</key>
29 <string>selection</string>
30 <key>keyEquivalent</key>
31 <string>^b</string>
32 <key>name</key>
33 <string>Debug - Set Breakpoint at Current Line</string>
34 <key>output</key>
35 <string>showAsTooltip</string>
36 <key>uuid</key>
37 <string>0ECC400E-11C0-4668-936B-25153FDC41BC</string>
38</dict>
39</plist>
toggle raw diff

Commands/Debug - Show Breakpoints Menu.tmCommand

 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>beforeRunningCommand</key>
6 <string>nop</string>
7 <key>command</key>
8 <string>#!/usr/bin/env ruby
9
10 def short_path(path, paths_to_display = 2)
11 path.split("/")[(-1 - paths_to_display)..(-1)] * "/"
12 end
13
14require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
15require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_tm_helpers.rb"
16require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
17
18d = RubyAMP::RemoteDebugger.new
19breakpoints = d.evaluate("Debugger.breakpoints.map{|b| {:source =&gt; b.source, :line =&gt; b.pos} }", :control)
20
21if breakpoints.empty?
22 puts "No breakpoints"
23 exit_show_tool_tip
24end
25
26b_index = TextMate::UI.menu(breakpoints.map{|b| "#{b[:source]}:#{b[:line]}"})
27
28exit_discard if b_index.nil?
29
30breakpoint = breakpoints[b_index]
31tm_open(breakpoint[:source], :line =&gt; breakpoint[:line])</string>
32 <key>input</key>
33 <string>none</string>
34 <key>keyEquivalent</key>
35 <string>^@b</string>
36 <key>name</key>
37 <string>Debug - Show Breakpoints</string>
38 <key>output</key>
39 <string>showAsTooltip</string>
40 <key>uuid</key>
41 <string>1E57B267-C3EC-4F67-84DE-3781D43DC88B</string>
42</dict>
43</plist>
toggle raw diff

Commands/Debug Experiment RSpec.tmCommand

 
0<?xml version="1.0" encoding="UTF-8"?>
1<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2<plist version="1.0">
3<dict>
4 <key>beforeRunningCommand</key>
5 <string>nop</string>
6 <key>command</key>
7 <string>#!/usr/bin/env ruby
8require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/rdebug_helpers.rb"
9
10debug_rspec(:file)</string>
11 <key>fallbackInput</key>
12 <string>line</string>
13 <key>input</key>
14 <string>selection</string>
15 <key>keyEquivalent</key>
16 <string>@d</string>
17 <key>name</key>
18 <string>Debug - RSpec Examples</string>
19 <key>output</key>
20 <string>showAsHTML</string>
21 <key>scope</key>
22 <string>source.ruby.rspec</string>
23 <key>uuid</key>
24 <string>95931CFC-B32A-46A6-9214-CA33D2880981</string>
25</dict>
26</plist>
toggle raw diff

Commands/Debug Experiment.tmCommand

 
0<?xml version="1.0" encoding="UTF-8"?>
1<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2<plist version="1.0">
3<dict>
4 <key>beforeRunningCommand</key>
5 <string>nop</string>
6 <key>command</key>
7 <string>#!/usr/bin/env ruby
8require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/rdebug_helpers.rb"
9
10
11launch_dbg_controller
12
13init_debug_run_file("load #{ENV['TM_FILEPATH'].to_s.inspect}")
14
15ARGV &lt;&lt; "-s"
16ARGV &lt;&lt; RUN_FILE
17
18load 'rdebug'</string>
19 <key>fallbackInput</key>
20 <string>line</string>
21 <key>input</key>
22 <string>selection</string>
23 <key>keyEquivalent</key>
24 <string>@d</string>
25 <key>name</key>
26 <string>Debug - Run current file</string>
27 <key>output</key>
28 <string>showAsHTML</string>
29 <key>scope</key>
30 <string>source.ruby</string>
31 <key>uuid</key>
32 <string>61FE0786-CB5F-4E8F-8DFD-03C0128CDE50</string>
33</dict>
34</plist>
toggle raw diff

Commands/Delete All Breakpoints.tmCommand

 
0<?xml version="1.0" encoding="UTF-8"?>
1<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2<plist version="1.0">
3<dict>
4 <key>beforeRunningCommand</key>
5 <string>nop</string>
6 <key>command</key>
7 <string>#!/usr/bin/env ruby
8
9require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_cmd.rb"
10
11
12dcmd = DebuggerCmd.new
13count_breakpoints = eval(dcmd.remote_eval_control_binding("Debugger.breakpoints.length"))
14if count_breakpoints == 0
15 puts "There are no breakpoints set"
16 exit
17end
18
19dcmd.remote_eval_control_binding("Debugger.breakpoints.map{ |b| b.id }.each { |b_id| Debugger.remove_breakpoint(b_id) }")
20
21new_count_breakpoints = eval(dcmd.remote_eval_control_binding("Debugger.breakpoints.length"))
22if new_count_breakpoints == 0
23 puts "Deleted all #{count_breakpoints} breakpoint(s)"
24else
25 puts "Error deleting breakpoints."
26end</string>
27 <key>fallbackInput</key>
28 <string>line</string>
29 <key>input</key>
30 <string>selection</string>
31 <key>keyEquivalent</key>
32 <string>^@b</string>
33 <key>name</key>
34 <string>Debug - Delete All Breakpoints</string>
35 <key>output</key>
36 <string>showAsTooltip</string>
37 <key>uuid</key>
38 <string>5193D698-4392-494D-946B-7D9BF1B7C9CA</string>
39</dict>
40</plist>
toggle raw diff

Commands/Inspect.tmCommand

 
0<?xml version="1.0" encoding="UTF-8"?>
1<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2<plist version="1.0">
3<dict>
4 <key>beforeRunningCommand</key>
5 <string>nop</string>
6 <key>command</key>
7 <string>#!/usr/bin/env ruby
8
9require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_inspect_helpers.rb"
10
11i = RDebugInspect.new
12
13puts "#{i.what} = \n#{i.inspect_as_pp}"
14</string>
15 <key>fallbackInput</key>
16 <string>word</string>
17 <key>input</key>
18 <string>document</string>
19 <key>keyEquivalent</key>
20 <string>^i</string>
21 <key>name</key>
22 <string>Debug - Inspect with pretty print</string>
23 <key>output</key>
24 <string>showAsTooltip</string>
25 <key>uuid</key>
26 <string>1236EAB2-B06B-4969-ABEC-6121A0873A14</string>
27</dict>
28</plist>
toggle raw diff

Commands/Interrupt.tmCommand

 
77 <key>command</key>
88 <string>#!/usr/bin/env ruby
99
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/rdebug_cmd.rb"
10require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
11d = RubyAMP::RemoteDebugger.new
12exit unless d.connected?
1113
12cmd = "i"
13msg = 'Application interrupted.'
14
15dcmd = DebuggerCmd.new
16dcmd.send_command(cmd, msg)</string>
14puts d.command("interrupt")
15</string>
1716 <key>fallbackInput</key>
1817 <string>line</string>
1918