Sha256: cb533ea91eef5e5ef6c83cd084714ca1e24b588bb9f556e3598cd36a32c89944

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

require "jekyll"

begin
  require_relative "readers/data-reader"
rescue NameError
  require_relative "readers/old-data-reader"
end

module CloudCannonJekyll
  # Wraps read functions into one class
  class Reader
    attr_reader :site

    def initialize(site)
      @site = site
    end

    def read_data(dir = "_data")
      CloudCannonJekyll::DataReader.new(@site).read(dir)
    rescue NameError # DataReader doesn't exist in old versions of Jekyll
      CloudCannonJekyll::OldDataReader.new(@site).read(dir)
    end

    def read_drafts(dir = "")
      Jekyll::PostReader.new(@site).read_drafts(dir)
    rescue NameError # PostReader doesn't exist in old versions of Jekyll
      @site.read_content(dir, "_drafts", Jekyll::Draft)
    end

    def read_posts(dir = "")
      Jekyll::PostReader.new(@site).read_posts(dir)
    rescue NameError # PostReader doesn't exist in old versions of Jekyll
      @site.read_content(dir, "_posts", Jekyll::Post)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cloudcannon-jekyll-0.3.2 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.5.3 lib/cloudcannon-jekyll/reader.rb