Class: MarkdownRecord::Indexer
- Inherits:
-
Object
- Object
- MarkdownRecord::Indexer
- Defined in:
- lib/markdown_record/rendering/indexer.rb
Instance Method Summary collapse
Instance Method Details
#index(subdirectory: "") ⇒ Object
4 5 6 7 8 9 |
# File 'lib/markdown_record/rendering/indexer.rb', line 4 def index(subdirectory: "") content_path = ::MarkdownRecord.config.content_root.join(subdirectory) index = {} recursive_index(content_path, index) index end |
#recursive_index(parent_dir_path, index) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/markdown_record/rendering/indexer.rb', line 11 def recursive_index(parent_dir_path, index) parent_root = Dir.new(parent_dir_path) parent_root.children.each do |child| pathname = Pathname.new("#{parent_dir_path}/#{child}") if pathname.directory? index[child] = {} recursive_index(pathname, index[child]) else index[child] = File.read(pathname) if (pathname.extname == ".md" || pathname.to_s =~ /\.md\.erb$/) end end end |