class Lookbook::FrontmatterExtractor
def call
def call frontmatter = extract_frontmatter(content) rest = strip_frontmatter(content) [frontmatter, rest] end
def extract_frontmatter(text)
def extract_frontmatter(text) matches = text.match(FRONTMATTER_REGEX) matches ? YAML.safe_load(matches[0]).deep_symbolize_keys : {} end
def initialize(content)
def initialize(content) @content = content.to_s end
def strip_frontmatter(text)
def strip_frontmatter(text) text.gsub(FRONTMATTER_REGEX, "").strip end