Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: mark-moseley/ruby-debug-ide
base: master
...
head fork: MarcWeber/ruby-debug-ide
compare: json
  • 1 commit
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 22, 2012
Marc Weber MarcWeber implement json protocol with \n separation for Vim plugin client at g…
…ithub.com/MarcWeber/vim-addon-ruby-debug-ide
ced70e7
10 bin/rdebug-ide
View
@@ -5,8 +5,14 @@ require 'optparse'
require "ostruct"
if RUBY_VERSION < "1.9"
require 'ruby-debug-ide'
+
+ # TODO: think about lazily loading xml_printer/json_printer
+ require 'ruby-debug/xml_printer'
+ require 'ruby-debug/json_printer'
else
require_relative '../lib/ruby-debug-ide'
+ require_relative '../lib/ruby-debug/xml_printer'
+ require_relative '../lib/ruby-debug/json_printer'
end
$stdout.sync=true
@@ -17,7 +23,8 @@ options = OpenStruct.new(
'load_mode' => false,
'port' => 1234,
'stop' => false,
- 'tracing' => false
+ 'tracing' => false,
+ 'printerClass'=> Debugger::XmlPrinter
)
opts = OptionParser.new do |opts|
@@ -33,6 +40,7 @@ EOB
opts.on('--stop', 'stop when the script is loaded') {options.stop = true}
opts.on("-x", "--trace", "turn on line tracing") {options.tracing = true}
opts.on("-l", "--load-mode", "load mode (experimental)") {options.load_mode = true}
+ opts.on("-J", "--json", "class name for printing messages") {|s| options.printerClass = Debugger::JsonPrinter }
opts.on("-d", "--debug", "Debug self - prints information for debugging ruby-debug itself") do
Debugger.cli_debug = true
end
15 lib/ruby-debug-ide.rb
View
@@ -4,11 +4,9 @@
require 'thread'
require 'ruby-debug-base'
if RUBY_VERSION < "1.9"
- require 'ruby-debug/xml_printer'
require 'ruby-debug/processor'
require 'ruby-debug/event_processor'
else
- require_relative 'ruby-debug/xml_printer'
require_relative 'ruby-debug/processor'
require_relative 'ruby-debug/event_processor'
end
@@ -101,13 +99,13 @@ def interrupt_last
end
end
- def start_server(host = nil, port = 1234)
+ def start_server(host = nil, port = 1234, printerClass)
start
- start_control(host, port)
+ start_control(host, port, printerClass || "XmlPrinter")
end
def debug_program(options)
- start_server(options.host, options.port)
+ start_server(options.host, options.port, options.printerClass)
raise "Control thread did not start (#{@control_thread}}" unless @control_thread && @control_thread.alive?
@@ -133,7 +131,7 @@ def run_prog_script
end
end
- def start_control(host, port)
+ def start_control(host, port, printerClass)
return if @control_thread
@control_thread = DebugThread.new do
begin
@@ -145,8 +143,9 @@ def start_control(host, port)
while (session = server.accept)
begin
interface = RemoteInterface.new(session)
- @event_processor = EventProcessor.new(interface)
- ControlCommandProcessor.new(interface).process_commands
+ printer = printerClass.new(interface)
+ @event_processor = EventProcessor.new(interface, printer)
+ ControlCommandProcessor.new(interface, printer).process_commands
rescue StandardError, ScriptError => ex
$stderr.printf "Exception in DebugThread loop: #{ex}\n"
exit 1
4 lib/ruby-debug/event_processor.rb
View
@@ -9,8 +9,8 @@ class EventProcessor
attr_accessor :line, :file, :context
- def initialize(interface)
- @printer = XmlPrinter.new(interface)
+ def initialize(interface, printer)
+ @printer = printer
@line = nil
@file = nil
@last_breakpoint = nil
4 lib/ruby-debug/processor.rb
View
@@ -9,9 +9,9 @@
module Debugger
class ControlCommandProcessor # :nodoc:
- def initialize(interface)
+ def initialize(interface, printer)
@interface = interface
- @printer = XmlPrinter.new(@interface)
+ @printer = printer
end
def print(*args)

No commit comments for this range

Something went wrong with that request. Please try again.