Class: Plugins::EditPlugin

Inherits:
Plugin
  • Object
show all
Defined in:
lib/bujo/plugins/edit_plugin.rb

Instance Attribute Summary

Attributes inherited from Plugin

#name, #options

Instance Method Summary collapse

Methods inherited from Plugin

#==, #directory, #shortcuts

Constructor Details

#initialize(dependencies = [], editor = nil) ⇒ EditPlugin

Returns a new instance of EditPlugin.



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bujo/plugins/edit_plugin.rb', line 12

def initialize(dependencies = [], editor = nil)
  super("edition", [
      Options::Option.builder
          .with_name("e", "edit")
          .with_description("Init the structure of the journal")
          .valued
          .with_action(lambda { |file| edit_entry(file) })
          .build
  ])

  # TODO C'mon, you're better than that
  @editor = editor.nil? ? Configuration::Configuration.load.editor : editor
end

Instance Method Details

#edit_entry(relative_path) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/bujo/plugins/edit_plugin.rb', line 26

def edit_entry(relative_path)
  puts "Editing entry..."
  @editor.call(relative_path)

  puts "Converting to HTML..."
  Utils::Converter.for(relative_path).convert
end