Sha256: 3e5781d4b7f662ee9e92872dd63a4d61e4a567fa0ba19276d76a6afb14e97651

Contents?: true

Size: 467 Bytes

Versions: 1

Compression:

Stored size: 467 Bytes

Contents

require 'yaml'

module Gram
  module Blog
    module Parser
      class << self

        def parse(file)
          raw_content = File.read(file)
          headers = raw_content.match(/---(.*)---/m)
          yaml = YAML.load($1.strip)

          title = yaml["title"]
          tagline = yaml["tagline"]

          content = raw_content.gsub(/---.*---/m, '').strip

          { title: title, tagline: tagline, body: content }
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gram-0.0.1 lib/gram/blog/parser.rb