Module: Fratterhorn

Defined in:
lib/fratterhorn.rb,
lib/fratterhorn/parse.rb,
lib/fratterhorn/version.rb

Defined Under Namespace

Classes: Error

Constant Summary collapse

FRONTMATTER_PATTERN =
%r[^---+\n*$(.*\n)*^---+\n$]
VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.parse(text, option: {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fratterhorn/parse.rb', line 8

def self.parse(text, option: {})
  @text = text
  @option = option
  @raw_frontmatter = ''

  @raw_frontmatter = get_frontmatter
  @frontmatter = YAML.safe_load(@raw_frontmatter).transform_keys!(&:to_sym)
  guess_value_type if @option.dig(:guess)

  @frontmatter
end