Sha256: ecdd00bc7ca5b327fa5a166e219da44dc9409aad352f8c4ad27f5be8e3545540
Contents?: true
Size: 697 Bytes
Versions: 3
Compression:
Stored size: 697 Bytes
Contents
module Brief class Document module FrontMatter extend ActiveSupport::Concern def frontmatter @frontmatter || load_frontmatter end def frontmatter_line_count (@raw_frontmatter && @raw_frontmatter.lines.count) || 0 end protected def load_frontmatter if raw_content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m self.content = raw_content[(Regexp.last_match[1].size + Regexp.last_match[2].size)..-1] @frontmatter_line_count = Regexp.last_match[1].lines.size @raw_frontmatter = Regexp.last_match[1] @frontmatter = YAML.load(Regexp.last_match[1]).to_mash end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
brief-1.3.2 | lib/brief/document/front_matter.rb |
brief-1.3.1 | lib/brief/document/front_matter.rb |
brief-1.3.0 | lib/brief/document/front_matter.rb |