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
Constant Summary collapse
- VERSION =
'0.0.2'
Class Attribute Summary collapse
-
.editor ⇒ Object
Returns the value of attribute editor.
Class Method Summary collapse
-
.available_editors ⇒ Object
All editors available on the current system.
-
.edit(content, editor: nil, command: nil) ⇒ Object
Edits the given content in a tempfile.
-
.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.
Class Attribute Details
.editor ⇒ Object
Returns the value of attribute editor.
10 11 12 |
# File 'lib/exedit/exedit.rb', line 10 def editor @editor end |
Class Method Details
.available_editors ⇒ Object
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 .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 |