Sha256: b6e30d9d95f7b23dfda668147ce8c012b20c0a167f471234deab72b7cfeca425

Contents?: true

Size: 643 Bytes

Versions: 5

Compression:

Stored size: 643 Bytes

Contents

module Writefully
  class Content
    attr_reader :index, :path
    attr_accessor :body

    def initialize(index)
      @index = index
      @path = File.join(Writefully.options[:content], index[:site], index[:resource], index[:slug])
    end

    def body
      Dir.chdir(path) { File.open(Dir['README.*'].first).read }
    end

    def meta
      YAML.load(File.read(File.join(path, "meta.yml"))).merge({ "position" => position })
    end

    def details
      Hashie::Mash.new(meta["details"])
    end

    def slug
      index[:slug].split(/\d-/).last
    end

    def position
      index[:slug].match(/\d/).to_s.to_i
    end
  end
end 

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
writefully-0.4.4 lib/writefully/content.rb
writefully-0.4.2 lib/writefully/content.rb
writefully-0.4.1 lib/writefully/content.rb
writefully-0.4.0 lib/writefully/content.rb
writefully-0.3.6 lib/writefully/content.rb