Class: Jekyll::Compose::FileEditor

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.compose_configObject (readonly) Also known as: jekyll_compose_config

Returns the value of attribute compose_config.



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

def compose_config
  @compose_config
end

Class Method Details

.auto_open?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/jekyll-compose/file_editor.rb', line 40

def auto_open?
  compose_config["auto_open"]
end

.bootstrap(config) ⇒ Object



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

def bootstrap(config)
  @compose_config = config["jekyll_compose"] || {}
end

.open_editor(filepath) ⇒ Object



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

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

.post_editorObject



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

def post_editor
  return unless auto_open?

  ENV["JEKYLL_EDITOR"] || ENV["VISUAL"] || ENV["EDITOR"]
end

.run_editor(editor_name, filepath) ⇒ Object



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

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