class RubyEdit::Commands::Edit

Public Class Methods

new(options) click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 13
def initialize(options)
  @grep       = RubyEdit::Grep.new(options)
  @sourcefile = RubyEdit::SourceFile.new
  @editor     = RubyEdit::Editor.new
  @output     = $stdout
  @errors     = $stderr
end

Public Instance Methods

execute() click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 21
def execute
  return unless grep_search
  populate_sourcefile
  edit_file
  apply_changes if apply_changes?
  delete_sourcefile
end

Private Instance Methods

apply_changes() click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 47
def apply_changes
  RubyEdit::Writer.new.write
end
apply_changes?() click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 43
def apply_changes?
  RubyEdit::ApplyPrompt.new.continue?
end
delete_sourcefile() click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 51
def delete_sourcefile
  @sourcefile.delete
end
edit_file() click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 39
def edit_file
  @editor.edit_sourcefile
end
populate_sourcefile() click to toggle source
# File lib/ruby_edit/commands/edit.rb, line 35
def populate_sourcefile
  @sourcefile.populate(@grep.result.out)
end