Module: Exedit

Extended by:
DotConfigure
Defined in:
lib/exedit/exedit.rb,
lib/exedit/editor.rb,
lib/exedit/command.rb,
lib/exedit/version.rb

Overview

Exedit main module

Defined Under Namespace

Classes: Command, Editor

Constant Summary collapse

VERSION =
'0.0.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.editorObject

Returns the value of attribute editor.



10
11
12
# File 'lib/exedit/exedit.rb', line 10

def editor
  @editor
end

Class Method Details

.available_editorsObject

All editors available on the current system



23
24
25
26
27
28
29
# File 'lib/exedit/exedit.rb', line 23

def available_editors
  if !defined? @options
    base_editors.select { |_editor, command| Command.which(command.split(' ')[0]) }
  else
    options.editors.select { |_editor, command| Command.which(command.split(' ')[0]) }
  end
end

.edit(content, editor: nil, command: nil) ⇒ Object

Edits the given content in a tempfile



18
19
20
# File 'lib/exedit/exedit.rb', line 18

def edit(content, editor: nil, command: nil)
  Editor.new(edit_command(editor, command), content: content).open
end

.open(file = nil, editor: nil, command: nil) ⇒ Object

Opens a file (defaults to a tempfile which will be deleted) for editing in the external editor



13
14
15
# File 'lib/exedit/exedit.rb', line 13

def open(file = nil, editor: nil, command: nil)
  Editor.new(edit_command(editor, command), file).open
end