Class: Jekyll::Compose::FileEditor

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-compose/file_editor.rb

Class Method Summary collapse

Class Method Details

.auto_open?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/jekyll-compose/file_editor.rb', line 31

def auto_open?
  jekyll_compose_config && jekyll_compose_config['auto_open']
end

.jekyll_compose_configObject



35
36
37
# File 'lib/jekyll-compose/file_editor.rb', line 35

def jekyll_compose_config
  @jekyll_compose_config ||= Jekyll.configuration['jekyll_compose']
end

.open_editor(filepath) ⇒ Object



18
19
20
# File 'lib/jekyll-compose/file_editor.rb', line 18

def open_editor(filepath)
  run_editor(post_editor, File.expand_path(filepath)) if post_editor
end

.post_editorObject



26
27
28
29
# File 'lib/jekyll-compose/file_editor.rb', line 26

def post_editor
  return unless auto_open?
  ENV['JEKYLL_EDITOR'] || ENV['EDITOR']
end

.run_editor(editor_name, filepath) ⇒ Object



22
23
24
# File 'lib/jekyll-compose/file_editor.rb', line 22

def run_editor(editor_name, filepath)
  system("#{editor_name} #{filepath}")
end