Sha256: 9992712a635258b1f2cd53f6537fa3cda216014edb9a6a86e721577d0bf5774d

Contents?: true

Size: 1.24 KB

Versions: 11

Compression:

Stored size: 1.24 KB

Contents

module Debugger
  class Edit < Command # :nodoc:
    self.allow_in_control = true
    def regexp
      /^\s* ed(?:it)? (?:\s+(.*))?$/ix
    end
    
    def execute
      if not @match[1] or @match[1].strip.empty?
        unless @state.context
          errmsg "We are not in a state that has an associated file.\n"
          return 
        end
        file = @state.file
        line_number = @state.line
      elsif @pos_match = /([^:]+)[:]([0-9]+)/.match(@match[1])
        file, line_number = @pos_match.captures
      else
        errmsg "Invalid file/line number specification: #{@match[1]}\n"
        return
      end
      editor = ENV['EDITOR'] || '/bin/ex'
      if File.readable?(file)
        system("#{editor} +#{line_number} \"#{file}\"")
        msg "Warning: return code was #{$?.exitstatus}" if $?.exitstatus != 0
      else
        errmsg "File \"#{file}\" is not readable.\n"
      end
    end
    
    class << self
      def help_command
        'edit'
      end

      def help(cmd)
        %{
          Edit specified file.

With no argument, edits file containing most recent line listed.
Editing targets can also be specified in this:
  FILE:LINENUM, to edit at that line in that file,
        }
      end
    end
  end


end # module Debugger

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
ruby-debug-0.11.0 cli/ruby-debug/commands/edit.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/ruby-debug-0.10.6/cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.6 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc9 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc8 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc7 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc5 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc4 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc3 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc2 cli/ruby-debug/commands/edit.rb
ruby-debug-0.10.5.rc1 cli/ruby-debug/commands/edit.rb