Sha256: 5fe9fb21eb261a9a55de540633e277594e5075bd2ff38f772c51d53cf9db8afa

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

module Jekyll
  class DraftReader
    attr_reader :site, :unfiltered_content
    def initialize(site)
      @site = site
      @unfiltered_content = Array.new
    end

    # Read all the files in <source>/<dir>/_drafts and create a new Draft
    # object with each one.
    #
    # dir - The String relative path of the directory to read.
    #
    # Returns nothing.
    def read(dir)
      @unfiltered_content = read_content(dir, '_drafts')
      @unfiltered_content.select{ |draft| site.publisher.publish?(draft) }
    end

    # Read all the content files from <source>/<dir>/magic_dir
    #   and return them with the type klass.
    #
    # dir - The String relative path of the directory to read.
    # magic_dir - The String relative directory to <dir>,
    #   looks for content here.
    # klass - The return type of the content.
    #
    # Returns klass type of content files
    def read_content(dir, magic_dir)
      @site.reader.get_entries(dir, magic_dir).map do |entry|
        Draft.new(site, site.source, dir, entry) if Draft.valid?(entry)
      end.reject do |entry|
        entry.nil?
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jekyll-3.0.0.pre.beta10 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta9 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta8 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta7 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta6 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta5 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta4 lib/jekyll/readers/draft_reader.rb
jekyll-3.0.0.pre.beta3 lib/jekyll/readers/draft_reader.rb