Class: Plugins::ProjectPlugin

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

Instance Attribute Summary

Attributes inherited from Plugin

#name, #options

Instance Method Summary collapse

Methods inherited from Plugin

#==, #shortcuts

Constructor Details

#initialize(dependencies = []) ⇒ ProjectPlugin

Returns a new instance of ProjectPlugin.



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

def initialize(dependencies = [])
  super("projects", [
      Options::Option.builder
          .with_name("p", "project")
          .with_description("Create an entry for a project in the journal")
          .valued
          .with_action(lambda { |project| create_project(project) })
          .build,
  ])

  @template_renderer = dependencies[:template_renderer]
end

Instance Method Details

#create_project(project_name) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/bujo/plugins/project_plugin.rb', line 29

def create_project(project_name)
  puts "Creating an entry for project #{project_name} in the journal"
  rendered_template = @template_renderer.render("project/template.adoc", {
      :project_name => project_name
  })
  project_source_path = Configuration::Structure.source_path("projects/#{Utils::NameUtils.computerize(project_name)}.adoc")
  Utils::Files.write(project_source_path, rendered_template)
end

#directoryObject



25
26
27
# File 'lib/bujo/plugins/project_plugin.rb', line 25

def directory
  "projects"
end