Sha256: c3215ec35eb5c89b742c65626e19b15e76d1f9378bd6b2ec4ae490e6f6ffd1c3

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

require 'hackety_hack/lessons/version'
require 'hackety_hack/lessons/rails/engine' if defined?(Rails)

require 'metadown'

module HacketyHack
  module Lessons
    extend self

    FILE_LIST = Dir["#{File.dirname(__FILE__)}/../../content/*.md"]

    def titles
      all.collect{|data| data.metadata["title"]}
    end

    def slugs
      all.collect{|data| data.metadata["slug"]}
    end

    def find_by_title(title)
      all.find{|data| data.metadata["title"] == title}
    end

    def find_by_slug(slug)
      all.find{|data| data.metadata["slug"] == slug}
    end

    def all
      FILE_LIST.collect{|file| Metadown.render(File.read(file, :encoding => "utf-8")) }
    end

    def static_directory
      "#{File.dirname(__FILE__)}/../../static"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hackety_hack-lessons-1.1.2 lib/hackety_hack/lessons.rb
hackety_hack-lessons-1.1.1 lib/hackety_hack/lessons.rb