Sha256: b20b28d198c46272f9bc137f07e82a6630881a8c1bf736b8849ae79c8132cfc9

Contents?: true

Size: 1.16 KB

Versions: 39

Compression:

Stored size: 1.16 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'] || 'ex'
      if File.readable?(file)
        system("#{editor} +#{line_number} #{file}")
      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

39 entries across 39 versions & 10 rubygems

Version Path
candlepin-api-0.4.0 bundle/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/edit.rb
debugger2-1.0.0.beta2 lib/ruby-debug/commands/edit.rb
debugger2-1.0.0.beta1 lib/ruby-debug/commands/edit.rb
needy_debugger-1.4.0 lib/ruby-debug/commands/edit.rb
debugger-1.4.0 lib/ruby-debug/commands/edit.rb
debugger-1.3.3 lib/ruby-debug/commands/edit.rb
debugger-1.3.2 lib/ruby-debug/commands/edit.rb
debugger-1.3.1 lib/ruby-debug/commands/edit.rb
debugger-1.3.0 lib/ruby-debug/commands/edit.rb
debugger-1.2.4 lib/ruby-debug/commands/edit.rb
debugger-1.2.3 lib/ruby-debug/commands/edit.rb
debugger-1.2.2 lib/ruby-debug/commands/edit.rb
debugger-1.2.1 lib/ruby-debug/commands/edit.rb
debugger-1.2.0 lib/ruby-debug/commands/edit.rb
debugger-1.1.4 lib/ruby-debug/commands/edit.rb
debugger-1.1.3 lib/ruby-debug/commands/edit.rb
debugger-1.1.2 lib/ruby-debug/commands/edit.rb
debugger-1.1.1 lib/ruby-debug/commands/edit.rb
debugger-1.1.0 lib/ruby-debug/commands/edit.rb
debugger-1.0.1 lib/ruby-debug/commands/edit.rb