Class: Cue::Command::Utils::Editor

Inherits:
Object
  • Object
show all
Defined in:
lib/cue/command/utils/editor.rb

Instance Method Summary collapse

Instance Method Details

#basenameObject



7
8
9
# File 'lib/cue/command/utils/editor.rb', line 7

def basename
  'cue'
end

#commandObject



11
12
13
# File 'lib/cue/command/utils/editor.rb', line 11

def command
  ENV['EDITOR'] || default_editor
end

#dirObject



24
25
26
# File 'lib/cue/command/utils/editor.rb', line 24

def dir
  '/tmp'
end

#pathObject



28
29
30
# File 'lib/cue/command/utils/editor.rb', line 28

def path
  @path ||= File.expand_path(Dir::Tmpname::make_tmpname(basename, nil), dir)
end

#readObject



15
16
17
18
19
20
21
22
# File 'lib/cue/command/utils/editor.rb', line 15

def read
  Process.wait(spawn([command, path].join(' ')))
  content = File.read(path)
  
  File.delete(path)
  
  content
end