Class: Plugins::ProjectPlugin
- Defined in:
- lib/bujo/plugins/project_plugin.rb
Instance Attribute Summary
Attributes inherited from Plugin
Instance Method Summary collapse
- #create_project(project_name) ⇒ Object
- #directory ⇒ Object
-
#initialize(dependencies = []) ⇒ ProjectPlugin
constructor
A new instance of ProjectPlugin.
Methods inherited from Plugin
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 |
#directory ⇒ Object
25 26 27 |
# File 'lib/bujo/plugins/project_plugin.rb', line 25 def directory "projects" end |