Sha256: 96dbab379b5c12d6017c4d4d158cdc3d8149c8b04ccf0c80a679aaeb9717494a

Contents?: true

Size: 383 Bytes

Versions: 3

Compression:

Stored size: 383 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)

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

          yaml.update({ 'body' => content })
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gram-0.3.0 lib/gram/blog/parser.rb
gram-0.2.0 lib/gram/blog/parser.rb
gram-0.1.0 lib/gram/blog/parser.rb