Sha256: 08f8933baf14cc29f3165bb98309df2c8b18203d8f02bc1903aecc0d5a13ff31

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

require "jekyll"

if !Jekyll::VERSION.start_with? "2."
  require_relative "readers/data-reader"
else
  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")
      if Jekyll::VERSION.start_with? "2."
        CloudCannonJekyll::OldDataReader.new(@site).read(dir)
      else
        CloudCannonJekyll::DataReader.new(@site).read(dir)
      end
    end

    def read_drafts(dir = "")
      if Jekyll::VERSION.start_with? "2."
        @site.read_content(dir, "_drafts", Jekyll::Draft)
      else
        Jekyll::PostReader.new(@site).read_drafts(dir)
      end
    end

    def read_posts(dir = "")
      if Jekyll::VERSION.start_with? "2."
        @site.read_content(dir, "_posts", Jekyll::Post)
      else
        Jekyll::PostReader.new(@site).read_posts(dir)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cloudcannon-jekyll-1.5.2 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-0.3.1 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-0.3.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.5.0 lib/cloudcannon-jekyll/reader.rb