Sha256: cb5bc9afb6efc94675b8b0ca64380507edec0e503491e5fd310b8d0a231a0e09

Contents?: true

Size: 1.08 KB

Versions: 18

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

require 'jekyll'
require_relative 'old-data-reader'
require_relative '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

18 entries across 18 versions & 1 rubygems

Version Path
cloudcannon-jekyll-4.1.0 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.7 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.6 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.5 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.4 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.3 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.2 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.1 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-4.0.0 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.2.4 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.2.3 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.2.2 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.2.1 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.2.0 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.1.0 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.0.2 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.0.1 lib/cloudcannon-jekyll/readers/reader.rb
cloudcannon-jekyll-3.0.0 lib/cloudcannon-jekyll/readers/reader.rb