Class: LowLoad::MarkdownAdapter

Inherits:
Adapter
  • Object
show all
Defined in:
lib/adapters/markdown_adapter.rb

Constant Summary collapse

EXTENSIONS =
['md', 'rd', 'markdown', 'raindown']

Instance Method Summary collapse

Methods inherited from Adapter

#evaluate, #preload

Instance Method Details

#metadata(file_path:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/adapters/markdown_adapter.rb', line 11

def (file_path:)
  meta_lines = []
  yaml_lines = []

  File.foreach(file_path).with_index do |line, index|
    if line.strip == '---'
      meta_lines << index + 1
      break if meta_lines.count > 1
    else
      yaml_lines << line
    end
  end

  YAML.safe_load(yaml_lines.join, symbolize_names: true)
end