Sha256: a6dacf5623b05e162c89ad47af6f279884ddb15df0c7a9e2d7bffc57aa99093a

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require "jekyll"
require_relative "readers/old-data-reader"
require_relative "readers/data-reader"

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

    def initialize(site)
      @site = site
    end

    def read_data(dir = "_data")
      # DataReader doesn't exist in old versions of Jekyll
      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 = "")
      # PostReader doesn't exist in old versions of Jekyll
      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 = "")
      # PostReader doesn't exist in old versions of Jekyll
      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

20 entries across 20 versions & 1 rubygems

Version Path
cloudcannon-jekyll-2.3.4 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.3.3 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.3.2 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.3.1 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.3.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.2.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.1.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.0.2 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.0.1 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-0.5.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-2.0.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.6.1 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-0.4.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.6.0 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.5.7 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.5.6 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.5.5 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-0.3.4 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-1.5.4 lib/cloudcannon-jekyll/reader.rb
cloudcannon-jekyll-0.3.3 lib/cloudcannon-jekyll/reader.rb