jekyll-data 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +0 -2
- data/lib/jekyll-data.rb +17 -14
- data/lib/jekyll-data/reader.rb +3 -3
- data/lib/jekyll-data/theme_configuration.rb +1 -1
- data/lib/jekyll-data/theme_data_reader.rb +5 -1
- data/lib/jekyll-data/themed_site_drop.rb +2 -3
- data/lib/jekyll-data/version.rb +3 -1
- data/lib/jekyll/build_options.rb +6 -4
- data/lib/jekyll/data_path.rb +3 -1
- data/lib/jekyll/theme_drop.rb +5 -6
- metadata +14 -15
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 | 
            -
             | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: 95e3f9216da63cda9e38c9affb6abd7670f39a29918adc7c7e11ee8f2be2053f
         | 
| 4 | 
            +
              data.tar.gz: 60732d8194aa06c2bf12ce37d05beeb097e49a537409c4324cd0bb2aeb945398
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: cc79ac198e020303b2a880f32baa681f61d838ccb241f359e1524eb9e5cd0e0ee0a0d5143359e063a87f9fb19b7d8c47fd1485c8ae9360570927f1aaebc9c672
         | 
| 7 | 
            +
              data.tar.gz: 4011a6f4bf630320827a6545ccd472d9c593af8bf10ecdf856a8f3d07edab07dd6edc10aff7f00630a6307b77a91931b836caa5ad751397aadc2699d5daaed44
         | 
    
        data/README.md
    CHANGED
    
    | @@ -29,8 +29,6 @@ end | |
| 29 29 |  | 
| 30 30 | 
             
            ## Usage
         | 
| 31 31 |  | 
| 32 | 
            -
            **Note:** *This plugin will only run in conjunction with a gem-based Jekyll-theme.*
         | 
| 33 | 
            -
             | 
| 34 32 | 
             
            As long as the plugin-gem has been installed properly, and is included in the Gemfile's `:jekyll_plugins` group, data files supported by Jekyll and present in the `_data` directory at the root of your theme-gem will be read. Their contents will be added to the site's internal data hash, provided, an identical data hash doesn't already exist at the site-source.
         | 
| 35 33 |  | 
| 36 34 | 
             
            If the theme-gem also includes a `_config.yml` at its root, then it will be read as well. The resulting config hash will be mixed into the site's existing config hash, filling in where the *keys* are not already defined. In other words, the config file at `source` will override corresponding identical keys in a `_config.yml` within the theme-gem which would in turn override corresponding `DEFAULTS` from Jekyll:
         | 
    
        data/lib/jekyll-data.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require "jekyll"
         | 
| 2 4 | 
             
            require "jekyll-data/version"
         | 
| 3 5 |  | 
| @@ -14,22 +16,19 @@ require_relative "jekyll/data_path" | |
| 14 16 | 
             
            require_relative "jekyll/theme_drop"
         | 
| 15 17 |  | 
| 16 18 | 
             
            # ----------------------------------------------------------------------------
         | 
| 17 | 
            -
            # Modify the current site instance if it uses a gem-based theme | 
| 18 | 
            -
            # plugin disabled.
         | 
| 19 | 
            +
            # Modify the current site instance only if it uses a gem-based theme.
         | 
| 19 20 | 
             
            #
         | 
| 20 21 | 
             
            # if a '_config.yml' is present at the root of theme-gem, it is evaluated and
         | 
| 21 22 | 
             
            # the extracted hash data is incorprated into the site's config hash.
         | 
| 23 | 
            +
            #
         | 
| 24 | 
            +
            # *Jekyll 4.0 has this feature incorporated in its core.*
         | 
| 22 25 | 
             
            # ----------------------------------------------------------------------------
         | 
| 23 | 
            -
            Jekyll:: | 
| 24 | 
            -
               | 
| 25 | 
            -
                 | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
                 | 
| 29 | 
            -
                  "JekyllData:",
         | 
| 30 | 
            -
                  "Error! This plugin only works with gem-based jekyll-themes. " \
         | 
| 31 | 
            -
                  "Please disable this plugin to proceed."
         | 
| 32 | 
            -
                )
         | 
| 26 | 
            +
            unless Jekyll::VERSION.start_with?("4")
         | 
| 27 | 
            +
              Jekyll::Hooks.register :site, :after_reset do |site|
         | 
| 28 | 
            +
                if site.theme
         | 
| 29 | 
            +
                  file = site.in_theme_dir("_config.yml")
         | 
| 30 | 
            +
                  JekyllData::ThemeConfiguration.reconfigure(site) if File.exist?(file)
         | 
| 31 | 
            +
                end
         | 
| 33 32 | 
             
              end
         | 
| 34 33 | 
             
            end
         | 
| 35 34 |  | 
| @@ -39,11 +38,15 @@ end | |
| 39 38 | 
             
            #
         | 
| 40 39 | 
             
            # If a _config.yml exists at the root of the theme-gem, output its path.
         | 
| 41 40 | 
             
            # Placed here inorder to avoid outputting the path after every regeneration.
         | 
| 41 | 
            +
            #
         | 
| 42 | 
            +
            # *Jekyll 4.0 detects a theme-configuration natively.*
         | 
| 42 43 | 
             
            # ---------------------------------------------------------------------------
         | 
| 43 44 | 
             
            Jekyll::Hooks.register :site, :after_init do |site|
         | 
| 44 45 | 
             
              if site.theme
         | 
| 45 | 
            -
                 | 
| 46 | 
            -
             | 
| 46 | 
            +
                unless Jekyll::VERSION.start_with?("4")
         | 
| 47 | 
            +
                  file = site.in_theme_dir("_config.yml")
         | 
| 48 | 
            +
                  Jekyll.logger.info "Theme Config file:", file if File.exist?(file)
         | 
| 49 | 
            +
                end
         | 
| 47 50 | 
             
                site.reader = JekyllData::Reader.new(site)
         | 
| 48 51 | 
             
              end
         | 
| 49 52 | 
             
            end
         | 
    
        data/lib/jekyll-data/reader.rb
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            require "csv"
         | 
| 3 4 |  | 
| 4 5 | 
             
            module JekyllData
         | 
| @@ -6,8 +7,7 @@ module JekyllData | |
| 6 7 | 
             
                def initialize(site)
         | 
| 7 8 | 
             
                  @site = site
         | 
| 8 9 | 
             
                  @theme = site.theme
         | 
| 9 | 
            -
                  @theme_data_files = Dir[File.join(site.theme. | 
| 10 | 
            -
                    site.config["data_dir"], "**", "*.{yaml,yml,json,csv}")]
         | 
| 10 | 
            +
                  @theme_data_files = Dir[File.join(site.theme.data_path, "**", "*.{yaml,yml,json,csv,tsv}")]
         | 
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                # Read data files within theme-gem.
         | 
| @@ -1,6 +1,9 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module JekyllData
         | 
| 2 4 | 
             
              class ThemeDataReader < Jekyll::DataReader
         | 
| 3 5 | 
             
                attr_reader :site, :content
         | 
| 6 | 
            +
             | 
| 4 7 | 
             
                def initialize(site)
         | 
| 5 8 | 
             
                  @site = site
         | 
| 6 9 | 
             
                  @content = {}
         | 
| @@ -9,6 +12,7 @@ module JekyllData | |
| 9 12 |  | 
| 10 13 | 
             
                def read(dir)
         | 
| 11 14 | 
             
                  return unless site.theme && site.theme.data_path
         | 
| 15 | 
            +
             | 
| 12 16 | 
             
                  base = site.in_theme_dir(dir)
         | 
| 13 17 | 
             
                  read_data_to(base, @content)
         | 
| 14 18 | 
             
                  @content
         | 
| @@ -18,7 +22,7 @@ module JekyllData | |
| 18 22 | 
             
                  return unless File.directory?(dir) && !@entry_filter.symlink?(dir)
         | 
| 19 23 |  | 
| 20 24 | 
             
                  entries = Dir.chdir(dir) do
         | 
| 21 | 
            -
                    Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
         | 
| 25 | 
            +
                    Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) }
         | 
| 22 26 | 
             
                  end
         | 
| 23 27 |  | 
| 24 28 | 
             
                  entries.each do |entry|
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module JekyllData
         | 
| 4 4 | 
             
              class ThemedSiteDrop < Jekyll::Drops::SiteDrop
         | 
| @@ -9,7 +9,6 @@ module JekyllData | |
| 9 9 | 
             
                def_delegator  :@obj, :site_data, :data
         | 
| 10 10 | 
             
                def_delegators :@obj, :theme
         | 
| 11 11 |  | 
| 12 | 
            -
                private
         | 
| 13 | 
            -
                def_delegator :@obj, :config, :fallback_data
         | 
| 12 | 
            +
                private def_delegator :@obj, :config, :fallback_data
         | 
| 14 13 | 
             
              end
         | 
| 15 14 | 
             
            end
         | 
    
        data/lib/jekyll-data/version.rb
    CHANGED
    
    
    
        data/lib/jekyll/build_options.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module Jekyll
         | 
| 2 4 | 
             
              class Command
         | 
| 3 5 | 
             
                class << self
         | 
| @@ -7,10 +9,10 @@ module Jekyll | |
| 7 9 | 
             
                  #
         | 
| 8 10 | 
             
                  alias_method :original_build_options, :add_build_options
         | 
| 9 11 |  | 
| 10 | 
            -
                  def add_build_options( | 
| 11 | 
            -
                    original_build_options( | 
| 12 | 
            -
                     | 
| 13 | 
            -
             | 
| 12 | 
            +
                  def add_build_options(cmd)
         | 
| 13 | 
            +
                    original_build_options(cmd)
         | 
| 14 | 
            +
                    cmd.option "show-data", "--show-data",
         | 
| 15 | 
            +
                               "Print merged site-data hash when used with --verbose."
         | 
| 14 16 | 
             
                  end
         | 
| 15 17 | 
             
                end
         | 
| 16 18 | 
             
              end
         | 
    
        data/lib/jekyll/data_path.rb
    CHANGED
    
    
    
        data/lib/jekyll/theme_drop.rb
    CHANGED
    
    | @@ -1,19 +1,18 @@ | |
| 1 | 
            -
            #  | 
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Jekyll
         | 
| 4 4 | 
             
              module Drops
         | 
| 5 5 | 
             
                class UnifiedPayloadDrop < Drop
         | 
| 6 | 
            -
                  def site
         | 
| 7 | 
            -
                    @site_drop ||= JekyllData::ThemedSiteDrop.new(@obj)
         | 
| 8 | 
            -
                  end
         | 
| 9 | 
            -
             | 
| 10 6 | 
             
                  # Register a namespace to easily call subkeys under <theme-name> key
         | 
| 11 7 | 
             
                  # in the _config.yml within a theme-gem via its bundled templates.
         | 
| 12 8 | 
             
                  #   e.g. with this drop, theme-specific variables usually called like
         | 
| 13 9 | 
             
                  #        {{ site.minima.date_format }} can be shortened to simply
         | 
| 14 10 | 
             
                  #        {{ theme.date_format }}.
         | 
| 15 11 | 
             
                  def theme
         | 
| 16 | 
            -
                    @theme_drop ||=  | 
| 12 | 
            +
                    @theme_drop ||= begin
         | 
| 13 | 
            +
                      config = site.send(:fallback_data)
         | 
| 14 | 
            +
                      config[config["theme"]]
         | 
| 15 | 
            +
                    end
         | 
| 17 16 | 
             
                  end
         | 
| 18 17 | 
             
                end
         | 
| 19 18 | 
             
              end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,36 +1,39 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: jekyll-data
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ashwin Maroli
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2019-09-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: jekyll
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - " | 
| 17 | 
            +
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 19 | 
             
                    version: '3.3'
         | 
| 20 | 
            +
                - - "<"
         | 
| 21 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 22 | 
            +
                    version: 5.0.0
         | 
| 20 23 | 
             
              type: :runtime
         | 
| 21 24 | 
             
              prerelease: false
         | 
| 22 25 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 26 | 
             
                requirements:
         | 
| 24 | 
            -
                - - " | 
| 27 | 
            +
                - - ">="
         | 
| 25 28 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 29 | 
             
                    version: '3.3'
         | 
| 30 | 
            +
                - - "<"
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: 5.0.0
         | 
| 27 33 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 34 | 
             
              name: bundler
         | 
| 29 35 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 36 | 
             
                requirements:
         | 
| 31 | 
            -
                - - "~>"
         | 
| 32 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: '1.14'
         | 
| 34 37 | 
             
                - - ">="
         | 
| 35 38 | 
             
                  - !ruby/object:Gem::Version
         | 
| 36 39 | 
             
                    version: 1.14.3
         | 
| @@ -38,9 +41,6 @@ dependencies: | |
| 38 41 | 
             
              prerelease: false
         | 
| 39 42 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 40 43 | 
             
                requirements:
         | 
| 41 | 
            -
                - - "~>"
         | 
| 42 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            -
                    version: '1.14'
         | 
| 44 44 | 
             
                - - ">="
         | 
| 45 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 46 46 | 
             
                    version: 1.14.3
         | 
| @@ -87,19 +87,19 @@ dependencies: | |
| 87 87 | 
             
                  - !ruby/object:Gem::Version
         | 
| 88 88 | 
             
                    version: '10.0'
         | 
| 89 89 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 90 | 
            -
              name: rubocop
         | 
| 90 | 
            +
              name: rubocop-jekyll
         | 
| 91 91 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 92 92 | 
             
                requirements:
         | 
| 93 93 | 
             
                - - "~>"
         | 
| 94 94 | 
             
                  - !ruby/object:Gem::Version
         | 
| 95 | 
            -
                    version: 0. | 
| 95 | 
            +
                    version: 0.10.0
         | 
| 96 96 | 
             
              type: :development
         | 
| 97 97 | 
             
              prerelease: false
         | 
| 98 98 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 99 99 | 
             
                requirements:
         | 
| 100 100 | 
             
                - - "~>"
         | 
| 101 101 | 
             
                  - !ruby/object:Gem::Version
         | 
| 102 | 
            -
                    version: 0. | 
| 102 | 
            +
                    version: 0.10.0
         | 
| 103 103 | 
             
            description: 
         | 
| 104 104 | 
             
            email:
         | 
| 105 105 | 
             
            - ashmaroli@gmail.com
         | 
| @@ -138,8 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 138 138 | 
             
                - !ruby/object:Gem::Version
         | 
| 139 139 | 
             
                  version: '0'
         | 
| 140 140 | 
             
            requirements: []
         | 
| 141 | 
            -
             | 
| 142 | 
            -
            rubygems_version: 2.6.10
         | 
| 141 | 
            +
            rubygems_version: 3.0.6
         | 
| 143 142 | 
             
            signing_key: 
         | 
| 144 143 | 
             
            specification_version: 4
         | 
| 145 144 | 
             
            summary: A plugin to read '_config.yml' and data files within Jekyll theme-gems
         |