Class: Plugins::CollectionPlugin
- Defined in:
- lib/bujo/plugins/collection_plugin.rb
Instance Attribute Summary
Attributes inherited from Plugin
Instance Method Summary collapse
- #create_collection(collection_name) ⇒ Object
- #directory ⇒ Object
-
#initialize(dependencies = []) ⇒ CollectionPlugin
constructor
A new instance of CollectionPlugin.
Methods inherited from Plugin
Constructor Details
#initialize(dependencies = []) ⇒ CollectionPlugin
Returns a new instance of CollectionPlugin.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bujo/plugins/collection_plugin.rb', line 12 def initialize(dependencies = []) super("collections", [ Options::Option.builder .with_name("c", "collection") .with_description("Create an entry for a collection in the journal") .valued .with_action(lambda { |collection| create_collection(collection) }) .build, ]) @template_renderer = dependencies[:template_renderer] end |
Instance Method Details
#create_collection(collection_name) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/bujo/plugins/collection_plugin.rb', line 29 def create_collection(collection_name) puts "Creating an entry for collection #{collection_name} in the journal" rendered_template = @template_renderer.render("collection/template.adoc", { :collection_name => collection_name }) collection_source_path = Configuration::Structure.source_path("collections/#{Utils::NameUtils.computerize(collection_name)}.adoc") Utils::Files.write(collection_source_path, rendered_template) end |
#directory ⇒ Object
25 26 27 |
# File 'lib/bujo/plugins/collection_plugin.rb', line 25 def directory "collections" end |