Class: Plans::List
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
Methods inherited from Command
#check_plans_pathname_exists, #initialize, #pathname, #plans_pathname, #raise_error, source_root
Constructor Details
This class inherits a constructor from Plans::Command
Instance Method Details
#do ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/plans/list.rb', line 7 def do plans_path = plans_pathname([:'plans-path']) check_plans_pathname_exists plans_path say 'Listing all available DOC_TYPEs...' say '' plans_path.each_child { |x| list_template(x) } say '' say 'Create a new document from a template with the command `plans new DOC_TYPE`' end |
#list_template(path_name) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/plans/list.rb', line 18 def list_template(path_name) # must be a Pathname return unless path_name.is_a? Pathname # must be a directory return unless path_name.directory? doc_type = path_name.basename say "DOC_TYPE: #{doc_type}" begin = YAML.load_file(path_name + 'template.yml') title = ['title'] || 'Title not found. Check template.yml.' description = ['description'] || 'Description not found. Check template.yml.' say " Title: #{title}" say " Description: #{description}" rescue Errno::ENOENT # File not found say 'No template.yml found in the template directory. Did you forget to add it?', :red end unless (path_name + 'README.md').file? say 'No README.md found in the template directory. Did you forget to add it?', :red end unless (path_name + 'reference.docx').file? say 'No reference.docx found in template directory. Did you forget to add it?', :red end end |