pax_global_header00006660000000000000000000000064140032104760014507gustar00rootroot0000000000000052 comment=12ca2f6e9e5126166eaca75492a6ad5783854f09 jekyll-data-1.1.1/000077500000000000000000000000001400321047600137105ustar00rootroot00000000000000jekyll-data-1.1.1/.gitignore000066400000000000000000000002401400321047600156740ustar00rootroot00000000000000*.gem /.bundle/ /.yardoc /Gemfile.lock /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ .jekyll-metadata .ruby-version .jekyll-cache .sass-cache test/dest jekyll-data-1.1.1/.rubocop.yml000066400000000000000000000017071400321047600161670ustar00rootroot00000000000000require: rubocop-jekyll inherit_gem: rubocop-jekyll: '.rubocop.yml' AllCops: Exclude: - script/**/* - vendor/**/* - tmp/**/* Layout/ArrayAlignment: Exclude: - 'features/support/helpers.rb' Layout/ParameterAlignment: Exclude: - 'features/support/formatter.rb' Layout/LineLength: Exclude: - ./**/*.gemspec - ./**/Gemfile - !ruby/regexp /features\/.*.rb/ Naming/MemoizedInstanceVariableName: Exclude: - 'lib/jekyll/theme_drop.rb' - 'test/fixtures/another-test-plugin/lib/another-test-plugin.rb' - 'test/fixtures/test-plugin/lib/test-plugin.rb' Style/ClassAndModuleChildren: Exclude: - 'test/helper.rb' Style/SafeNavigation: Exclude: - 'lib/jekyll-data/theme_data_reader.rb' Style/SingleLineMethods: Exclude: - 'features/support/helpers.rb' Style/TrailingCommaInArrayLiteral: Exclude: - 'test/helper.rb' Style/TrailingCommaInHashLiteral: Exclude: - 'features/support/formatter.rb' jekyll-data-1.1.1/.travis.yml000066400000000000000000000006341400321047600160240ustar00rootroot00000000000000script: script/cibuild cache: bundler language: ruby rvm: - &ruby1 2.7.1 - &ruby2 2.5.8 - &jruby jruby-9.2.14.0 matrix: include: - rvm: *ruby1 env: TEST_SUITE=fmt - rvm: *ruby1 env: TEST_SUITE=test-site exclude: - rvm: *jruby env: TEST_SUITE=cucumber env: matrix: - TEST_SUITE=test - TEST_SUITE=cucumber before_install: - gem update --system --no-document jekyll-data-1.1.1/CHANGELOG.md000066400000000000000000000141551400321047600155270ustar00rootroot00000000000000### 1.1.1 / 2021-01-24 #### Bug Fixes * Don't fail if the theme doesn't have a data dir. **[[`#36`][]]** by [@fauno][] * Fix incompatibility with Jekyll 4.2. **[[`#38`][]]** by [@fauno][] [`#36`]: https://github.com/ashmaroli/jekyll-data/pull/36 [`#38`]: https://github.com/ashmaroli/jekyll-data/pull/38 [@fauno]: https://github.com/fauno #### Development Improvements * Bump development dependencies and tested Ruby versions #### Documentation * Use "successivo" as it's more widely used. **[[`#37`][]]** by [@Samplasion][] [`#37`]: https://github.com/ashmaroli/jekyll-data/pull/37 [@Samplasion]: https://github.com/Samplasion ### 1.1.0 / 2019-09-09 #### Minor Enhancements * Don't abort if the site doesn't use a gem-based theme. **[[`#25`][]]** * Replace `File.dirname(__FILE__)` with `__dir__`. **[[`#26`][], [`e3694c8`][]]** * Use frozen String literals. **[[`#27`][]]** * Add support for Jekyll 4.0. **[[`#30`][], [`#32`][]]** * Add support to read TSV files **[[`1c0b048`][]]** [`#25`]: https://github.com/ashmaroli/jekyll-data/pull/25 [`#26`]: https://github.com/ashmaroli/jekyll-data/pull/26 [`#27`]: https://github.com/ashmaroli/jekyll-data/pull/27 [`#30`]: https://github.com/ashmaroli/jekyll-data/pull/30 [`#32`]: https://github.com/ashmaroli/jekyll-data/pull/32 [`e3694c8`]: https://github.com/ashmaroli/jekyll-data/commit/e3694c8c8bc2c064f549a7ecacad65b1bf7db7e0 [`1c0b048`]: https://github.com/ashmaroli/jekyll-data/commit/1c0b048f7c1d8146b0808fee5263b7b06b1fa6de #### Bug Fixes * Base theme-drop on fallback-data. **[[`#29`][]]** * Properly designate `Jekyll::Drops::SiteDrop#fallback_data` as a `private` method. **[[`bb0447b`][]]** * Memoize Jekyll::Theme#data_path. **[[`7feb5d6`][]]** [`#29`]: https://github.com/ashmaroli/jekyll-data/pull/29 [`bb0447b`]: https://github.com/ashmaroli/jekyll-data/commit/bb0447b242c36f2277c07b45a37b053b56aa8d37 [`7feb5d6`]: https://github.com/ashmaroli/jekyll-data/commit/7feb5d6921e0bcadbed7841d7e0d76c2b141c468 #### Development Improvements * Update Travis configuration. **[[`#31`][]]** * Use `rubocop-jekyll` to enforce Jekyll's style-guide **[[`20c0550`][]]** [`#31`]: https://github.com/ashmaroli/jekyll-data/pull/31 [`20c0550`]: https://github.com/ashmaroli/jekyll-data/commit/20c0550bcb2dacf8a202522bd576fe3aebbfb8a0 ### 1.0.0 / 2017-02-15 #### Major Enhancements * `{{ theme.myvariable }}` now points to `site..myvariable` instead of `site.data..myvariable`. **[[`#08`][]]** * extracting a theme-gem's config hash and incorporating it into the site's internal config hash is handled by a new `ThemeConfiguration` class. **[[`#09`][], [`#11`][]]** * All new classes are now loaded under `JekyllData` module. The `Jekyll` namespace will only contain patches to the original `Jekyll` module or its classes. **[[`#15`][], [`#22`][]]** [`#08`]: https://github.com/ashmaroli/jekyll-data/pull/8 [`#09`]: https://github.com/ashmaroli/jekyll-data/pull/9 [`#11`]: https://github.com/ashmaroli/jekyll-data/pull/11 [`#15`]: https://github.com/ashmaroli/jekyll-data/pull/15 [`#22`]: https://github.com/ashmaroli/jekyll-data/pull/22 #### Minor Enhancements * A new switch `--show-data` has been added to Jekyll's build-options as a supplement to existing `--verbose` switch. **[[`#13`][], [`#18`][], [`#20`][]]** * Debug data output from `--show-data` is now at a fixed width and wraps nicely to the next line. **[[`#17`][], [`#19`][]]** [`#13`]: https://github.com/ashmaroli/jekyll-data/pull/13 [`#17`]: https://github.com/ashmaroli/jekyll-data/pull/17 [`#18`]: https://github.com/ashmaroli/jekyll-data/pull/18 [`#19`]: https://github.com/ashmaroli/jekyll-data/pull/19 [`#20`]: https://github.com/ashmaroli/jekyll-data/pull/20 #### Bug Fixes * A theme-gem's config hash is now incorporated via the `after-reset` hook to enable Jekyll `require` the necessary plugins listed in the theme-gem's config file. **[[`#12`][]]** [`#12`]: https://github.com/ashmaroli/jekyll-data/pull/12 #### Development Improvements * Improved test-suite. **[[`#14`][], [`#16`][]]** * Added cucumber `features` and a script for build assessment. * Added a couple of dummy plugins to test loading of plugins listed in a theme-gem's config file. * Included testing with Ruby 2.4.0. * Document the main gems used for testing via `gemspec`. Upgrade Bundler to v1.14.3 and above. **[[`#23`][]]** [`#14`]: https://github.com/ashmaroli/jekyll-data/pull/14 [`#16`]: https://github.com/ashmaroli/jekyll-data/pull/16 [`#23`]: https://github.com/ashmaroli/jekyll-data/pull/23 #### Documentation * Update and improve documentation. **[[`#10`][]]** * Added this `CHANGELOG.md`. **[[`#24`][]]** [`#10`]: https://github.com/ashmaroli/jekyll-data/pull/10 [`#24`]: https://github.com/ashmaroli/jekyll-data/pull/24 -- ### 0.4.0 / 2016-12-14 #### Minor Improvements * Read a `_config.yml` within theme-gems, extract and merge the hash with the site's original config hash. **[[`#06`][]]** * Abort build process when the `theme` key has not been configured or has been commented out. [`#06`]: https://github.com/ashmaroli/jekyll-data/pull/6 #### Documentation * Update README to document recent developments * Fix typos within comments in `.rb` file. -- ### 0.3.0 / 2016-11-21 #### Minor Improvements * Validate theme configuration (`_data/.yml`) and its override. **[[`#05`][]]** #### Development Improvements * Add Continuous Integration with Travis CI. **[[`#03`][]]** * Add and update files to run Minitest. **[[`#04`][]]** [`#03`]: https://github.com/ashmaroli/jekyll-data/pull/3 [`#04`]: https://github.com/ashmaroli/jekyll-data/pull/4 [`#05`]: https://github.com/ashmaroli/jekyll-data/pull/5 -- ### 0.2.1 / 2016-10-21 * Alter methods for debugging. **[[`#02`][]]** * Clarify plugin's actions in README. [`#02`]: https://github.com/ashmaroli/jekyll-data/pull/2 -- ### 0.2.0 / 2016-10-18 * Flesh out README with proper installation & usage instructions. * Refactor private debugging methods. **[[`#01`][]]** * Add Gem-Version badge to README. [`#01`]: https://github.com/ashmaroli/jekyll-data/pull/1 -- ### Initial Release / 2016-10-16 [YANKED] jekyll-data-1.1.1/Gemfile000066400000000000000000000011041400321047600151770ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] group :test do gem "activesupport", "~> 4.2" if RUBY_VERSION < "2.2.2" gem "another-test-plugin", :path => File.expand_path("test/fixtures/another-test-plugin", __dir__) gem "minitest-profile" gem "minitest-reporters" gem "rspec" gem "rspec-mocks" gem "shoulda" gem "test-plugin", :path => File.expand_path("test/fixtures/test-plugin", __dir__) gem "test-theme", :path => File.expand_path("test/fixtures/test-theme", __dir__) end jekyll-data-1.1.1/LICENSE.txt000066400000000000000000000021141400321047600155310ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2016-2017 Ashwin Maroli & Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jekyll-data-1.1.1/README.md000066400000000000000000000145211400321047600151720ustar00rootroot00000000000000# JekyllData [![Gem Version](https://img.shields.io/gem/v/jekyll-data.svg)](https://rubygems.org/gems/jekyll-data) [![Build Status](https://img.shields.io/travis/ashmaroli/jekyll-data/master.svg?label=Build%20Status)][travis] [travis]: https://travis-ci.org/ashmaroli/jekyll-data Introducing a plugin that reads data files within **jekyll theme-gems** and adds the resulting hash to the site's internal data hash. If a **`_config.yml`** is present at the root of the theme-gem, it will be evaluated and the extracted hash data will be incorporated into the site's existing config hash. ## Installation Simply add the plugin to your site's Gemfile and config file like every other jekyll plugin gem: ```ruby # Gemfile group :jekyll_plugins do gem "jekyll-data" end ``` ..and run bundle install > **Note: If the plugin has been marked as a `runtime_dependency` by the theme-gem's author it will be installed automatically with the theme-gem. Yet, it is recommended that the plugin be added to `:jekyll_plugins` group in the Gemfile rather than the `gems:` array in the config file while building or serving the site to avoid 'overriding' the `gems:` array data that may have been read-in from the theme-gem.** ## Usage 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. 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: **DEFAULTS** < **_config.yml in theme-gem** < **_config.yml at source** < **Override configs via command-line**. ### Theme Configuration Jekyll themes (built prior to `Jekyll 3.2`) usually ship with configuration settings defined in the config file, which are then used within the theme's template files directly under the `site` namespace (e.g. `{{ site.myvariable }}`). This is not possible with theme-gems as a config file and data files within gems are not natively read (as of Jekyll 3.3), and hence require end-users to inspect a *demo* or *example* directory to source those files. This plugin provides a solution to that hurdle: JekyllData now reads the config file (at present only `_config.yml`) present within the theme-gem and uses the data to modify the site's config hash. This allows the theme-gem to continue using `{{ site.myvariable }}` within its templates and work out-of-the-box as intended, with minimal user intervention. **Note: the plugins required by the theme may be listed under the `gems:` array and will be automatically `required` by Jekyll while building/serving, provided that the user doesn't have a different `gems:` array in the config file at source. Hence it is recommended to add all other plugins ( including `jekyll-data` ) via the Gemfile's `:jekyll_plugins` group.** #### The `theme` namespace From `v1.0`, JekyllData no longer supports reading theme configuration provided as a `[theme-name].***` file within the `_data` directory and instead the `theme` namespace points to a certain key in the bundled `_config.yml`. For `{{ theme.variable }}` to work, the config file should nest all such key-value pairs under the `[theme-name]` key, as outlined in the example below for a theme-gem called `solitude`: ```yaml # /_config.yml # the settings below have been used in this theme's templates via the `theme` # namespace. e.g. `{{ theme.recent_posts.style }}` instead of using the more # verbose `{{ site.solitude.recent_posts.style }}` though both are functionally # the same. # solitude: sidebar : true # enter 'false' to enable horizontal navbar instead. theme_variant : Charcoal # choose from 'Ocean', 'Grass', 'Charcoal' recent_posts : style : list # choose from 'list' and 'grid'. quantity : '4' # either '4' or '6' ``` ### Data files Data files may be used to supplement theme templates (e.g. locales and translated UI text) and can be named as desired. - Organize related small data files in sub-directories. (or) - Declare all related data as mapped data blocks within a single file. To illustrate with an example, consider a `locales.yml` that has mappings for `en:`, `fr:`, `it:`. ```yaml # /_data/locales.yml en: previous : previous next : next fr: previous : précédent next : prochain it: previous : precedente next : successivo ``` the Hash from above would be identical to one had the gem been shipped with a `_data/locales` directory containing individual files for each language data. ### Overriding Data Files To override data shipped with a theme-gem, simply have an identical hash at the site-source. Irrespective of whether the theme-gem ships with consolidated data files of related entities, or sub-directories containing individual files, the data can be overridden with a single file or with multiple files. For example, if a theme-gem contains the above sample `locales.yml`, then to override the `fr:` key-data simply have either of the following: - a **`_data/locales/fr.yml`** with identical subkey(s). - a **`_data/locales.yml`** with **`fr:`** with identical subkey(s). -- > **Note** - having an **empty** `_data/locales.yml` at `source` directory will override the **entire `["data"]["locales"]` payload** from the theme-gem as **`false`**. - having an **empty** `_data/locales/fr.yml` at `source` directory will override the **enire `["data"]["locales"]["fr"]` payload** from the theme-gem as **`false`** ## Contributing Bug reports and pull requests are welcome at the [GitHub Repo](https://github.com/ashmaroli/jekyll-data). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT). jekyll-data-1.1.1/Rakefile000066400000000000000000000002661400321047600153610ustar00rootroot00000000000000# frozen_string_literal: true require "rake" require "rake/testtask" Rake::TestTask.new do |t| t.libs << "test" t.test_files = FileList["test/test*.rb"] t.verbose = true end jekyll-data-1.1.1/features/000077500000000000000000000000001400321047600155265ustar00rootroot00000000000000jekyll-data-1.1.1/features/step_definitions.rb000066400000000000000000000102001400321047600214120ustar00rootroot00000000000000# frozen_string_literal: true Before do FileUtils.rm_rf(Paths.test_dir) if Paths.test_dir.exist? FileUtils.mkdir_p(Paths.test_dir) unless Paths.test_dir.directory? Dir.chdir(Paths.test_dir) end # After do FileUtils.rm_rf(Paths.test_dir) if Paths.test_dir.exist? Paths.output_file.delete if Paths.output_file.exist? Paths.status_file.delete if Paths.status_file.exist? Dir.chdir(Paths.test_dir.parent) end # Given(%r!^I have an? "(.*)" file that contains "(.*)"$!) do |file, text| File.write(file, text) end # Given(%r!^I have an? "(.*)" file with content:$!) do |file, text| File.write(file, text) end # Given(%r!^I have an? (.*) directory$!) do |dir| FileUtils.mkdir_p(dir) unless File.directory?(dir) end # Given(%r!^I have a configuration file with "(.*)" set to "(.*)"$!) do |key, value| config = \ if source_dir.join("_config.yml").exist? SafeYAML.load_file(source_dir.join("_config.yml")) else {} end config[key] = YAML.safe_load(value) File.write("_config.yml", YAML.dump(config)) end # Given(%r!^I have a configuration file with:$!) do |table| table.hashes.each do |row| step %(I have a configuration file with "#{row["key"]}" set to "#{row["value"]}") end end # Given(%r!^I have a configuration file with "([^\"]*)" set to:$!) do |key, table| File.open("_config.yml", "w") do |f| f.write("#{key}:\n") table.hashes.each do |row| f.write("- #{row["value"]}\n") end end end # Given(%r!^I have a valid Gemfile$!) do File.write("Gemfile", <<~DATA) gem "test-theme", path: File.expand_path( "../../test/fixtures/test-theme", __dir__ ) group :jekyll_plugins do gem "jekyll-data", path: File.expand_path("../../", __dir__) # any other plugins end DATA end # Given(%r!^I have a Gemfile with plugins?:$!) do |table| step %(I have a valid Gemfile) table.hashes.each do |row| step %(I have a Gemfile with "#{row["name"]}" plugin set to "#{row["path"]}") end end # Given(%r!^I have a Gemfile with (.*) plugin set to (.*)$!) do |name, path| content = File.read("Gemfile") File.write( "Gemfile", content.gsub( "# any other plugins", "gem #{name}, path: File.expand_path(#{path}, __dir__)\n # any other plugins" ) ) end # When(%r!^I run jekyll(.*)$!) do |args| run_jekyll(args) warn "\n#{jekyll_run_output}\n" if args.include?("--verbose") || ENV["DEBUG"] end # When(%r!^I run bundle(.*)$!) do |args| ENV["BUNDLE_GEMFILE"] = Paths.test_dir.join("Gemfile").to_s run_bundle(args) warn "\n#{jekyll_run_output}\n" if args.include?("--verbose") || ENV["DEBUG"] end # When(%r!^I change "(.*)" to contain "(.*)"$!) do |file, text| File.open(file, "a") do |f| f.write(text) end end # When(%r!^I delete the file "(.*)"$!) do |file| File.delete(file) end # Then(%r!^the (.*) directory should +(not )?exist$!) do |dir, negative| if negative.nil? expect(Pathname.new(dir)).to exist else expect(Pathname.new(dir)).to_not exist end end # Then(%r!^I should (not )?see "(.*)" in "(.*)"$!) do |negative, text, file| step %(the "#{file}" file should exist) regexp = Regexp.new(text, Regexp::MULTILINE) if negative.nil? || negative.empty? expect(file_contents(file)).to match regexp else expect(file_contents(file)).not_to match regexp end end # Then(%r!^I should see exactly "(.*)" in "(.*)"$!) do |text, file| step %(the "#{file}" file should exist) expect(file_contents(file).strip).to eq text end # Then(%r!^the "(.*)" file should +(not )?exist$!) do |file, negative| if negative.nil? expect(Pathname.new(file)).to exist else expect(Pathname.new(file)).to_not exist end end # Then(%r!^I should (not )?see "(.*)" in the build output$!) do |negative, text| if negative.nil? || negative.empty? expect(jekyll_run_output).to match Regexp.new(text) else expect(jekyll_run_output).not_to match Regexp.new(text) end end # Then(%r!^I should get a zero exit(?:\-| )status$!) do step %(I should see "EXIT STATUS: 0" in the build output) end # Then(%r!^I should get a non-zero exit(?:\-| )status$!) do step %(I should not see "EXIT STATUS: 0" in the build output) end jekyll-data-1.1.1/features/support/000077500000000000000000000000001400321047600172425ustar00rootroot00000000000000jekyll-data-1.1.1/features/support/formatter.rb000066400000000000000000000113241400321047600215730ustar00rootroot00000000000000# frozen_string_literal: true require "fileutils" require "colorator" require "cucumber/formatter/console" require "cucumber/formatter/io" module Jekyll module Cucumber class Formatter attr_accessor :indent, :runtime include ::Cucumber::Formatter::Console include ::Cucumber::Formatter::Io include FileUtils CHARS = { :failed => "\u2718".red, :pending => "\u203D".yellow, :undefined => "\u2718".red, :passed => "\u2714".green, :skipped => "\u203D".blue, }.freeze # def initialize(runtime, path_or_io, options) @runtime = runtime @snippets_input = [] @io = ensure_io(path_or_io) @prefixes = options[:prefixes] || {} @delayed_messages = [] @options = options @exceptions = [] @indent = 0 @timings = {} end # def before_features(_features) print_profile_information end # def after_features(features) @io.puts print_worst_offenders print_summary(features) end # def before_feature(_feature) @exceptions = [] @indent = 0 end # def feature_element_timing_key(feature_element) "\"#{feature_element.name}\" (#{feature_element.location})" end # def before_feature_element(feature_element) @indent = 2 @scenario_indent = 2 @timings[feature_element_timing_key(feature_element)] = Time.now end # def after_feature_element(feature_element) @timings[feature_element_timing_key(feature_element)] = Time.now - @timings[feature_element_timing_key(feature_element)] @io.print " (#{@timings[feature_element_timing_key(feature_element)]}s)" end # def tag_name(tag_name); end def comment_line(comment_line); end def after_tags(tags); end # def before_background(_background) @scenario_indent = 2 @in_background = true @indent = 2 end # def after_background(_background) @in_background = nil end # def background_name(keyword, name, source_line, indent) print_feature_element_name( keyword, name, source_line, indent ) end # def scenario_name(keyword, name, source_line, indent) print_feature_element_name( keyword, name, source_line, indent ) end # def before_step(step) @current_step = step end # # rubocop:disable Metrics/ParameterLists def before_step_result(_keyword, _step_match, _multiline_arg, status, exception, \ _source_indent, background, _file_colon_line) @hide_this_step = false if exception if @exceptions.include?(exception) @hide_this_step = true return end @exceptions << exception end if status != :failed && @in_background ^ background @hide_this_step = true return end @status = status end # def step_name(_keyword, _step_match, status, _source_indent, _background, _file_colon_line) @io.print CHARS[status] @io.print " " end # rubocop:enable Metrics/ParameterLists # def exception(exception, status) return if @hide_this_step @io.puts print_exception(exception, status, @indent) @io.flush end # def after_test_step(test_step, result) collect_snippet_data( test_step, result ) end # def print_feature_element_name(feature_element) @io.print "\n#{feature_element.location} Scenario: #{feature_element.name} " @io.flush end # def cell_prefix(status) @prefixes[status] end # def print_worst_offenders @io.puts @io.puts "Worst offenders:" @timings.sort_by { |_f, t| -t }.take(10).each do |(f, t)| @io.puts " #{t}s for #{f}" end @io.puts end # def print_summary(features) @io.puts print_stats(features, @options) print_snippets(@options) print_passing_wip(@options) end end end end AfterConfiguration do |config| f = Jekyll::Cucumber::Formatter.new(nil, $stdout, {}) config.on_event :test_case_started do |event| f.print_feature_element_name(event.test_case) f.before_feature_element(event.test_case) end config.on_event :test_case_finished do |event| f.after_feature_element(event.test_case) end config.on_event :test_run_finished do f.print_worst_offenders end end jekyll-data-1.1.1/features/support/helpers.rb000066400000000000000000000054401400321047600212340ustar00rootroot00000000000000# frozen_string_literal: true require "fileutils" require "jekyll" require "open3" require "time" require "safe_yaml/load" class Paths SOURCE_DIR = Pathname.new(File.expand_path("../..", __dir__)) def self.test_dir; source_dir.join("tmp", "jekyll-data"); end def self.output_file; test_dir.join("jekyll_output.txt"); end def self.status_file; test_dir.join("jekyll_status.txt"); end def self.source_dir; SOURCE_DIR; end end def file_content_from_hash(input_hash) matter_hash = input_hash.reject { |k, _v| k == "content" } matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join matter.chomp! content = if input_hash["input"] && input_hash["filter"] "{{ #{input_hash["input"]} | #{input_hash["filter"]} }}" else input_hash["content"] end <<~RESULT --- #{matter} --- #{content} RESULT end def source_dir(*files) Paths.test_dir(*files) end def all_steps_to_path(path) source = source_dir dest = Pathname.new(path).expand_path paths = [] dest.ascend do |f| break if f == source paths.unshift f.to_s end paths end def jekyll_run_output Paths.output_file.read if Paths.output_file.file? end def jekyll_run_status Paths.status_file.read if Paths.status_file.file? end def run_bundle(args) run_in_shell("bundle", *args.strip.split(" ")) end def run_rubygem(args) run_in_shell("gem", *args.strip.split(" ")) end def run_jekyll(args) args = args.strip.split(" ") # Shellwords? process = run_in_shell("ruby", Paths.jekyll_bin.to_s, *args, "--trace") process.exitstatus.zero? end # rubocop:disable Metrics/AbcSize def run_in_shell(*args) i, o, e, p = Open3.popen3(*args) out = o.read.strip err = e.read.strip [i, o, e].each(&:close) File.write(Paths.status_file, p.value.exitstatus) File.open(Paths.output_file, "wb") do |f| f.print "$ " f.puts args.join(" ") f.puts out f.puts err f.puts "EXIT STATUS: #{p.value.exitstatus}" end p.value end # rubocop:enable Metrics/AbcSize def slug(title = nil) if !title Time.now.strftime("%s%9N") # nanoseconds since the Epoch else title.downcase.gsub(%r![^\w]!, " ").strip.gsub(%r!\s+!, "-") end end def location(folder, direction) if folder before = folder if direction == "in" after = folder if direction == "under" end [ before || ".", after || ".", ] end def file_contents(path) Pathname.new(path).read end def seconds_agnostic_datetime(datetime = Time.now) date, time, zone = datetime.to_s.split(" ") time = seconds_agnostic_time(time) [ Regexp.escape(date), "#{time}:\\d{2}", Regexp.escape(zone), ].join("\\ ") end def seconds_agnostic_time(time) time = time.strftime("%H:%M:%S") if time.is_a?(Time) hour, minutes, = time.split(":") "#{hour}:#{minutes}" end jekyll-data-1.1.1/features/theme_configuration.feature000066400000000000000000000056451400321047600231460ustar00rootroot00000000000000Feature: Configuring Gem-based Themes As a hacker who likes to share my expertise I want to be able to configure my gemified theme In order to make it easier for other Jekyllites to use my theme Scenario: A site not using a gem-based theme Given I have a configuration file with: | key | value | | exclude | [Gemfile, Gemfile.lock] | And I have a Gemfile with plugin: | name | path | | test-plugin | ../../test/fixtures/test-plugin | When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And the "_site/test-feed.xml" file should exist Scenario: Theme-gem has a config file with valid 'gems' array Given I have a configuration file with: | key | value | | theme | test-theme | | exclude | [Gemfile, Gemfile.lock] | And I have a Gemfile with plugin: | name | path | | test-plugin | ../../test/fixtures/test-plugin | When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And the "_site/test-feed.xml" file should exist Scenario: Overriding the 'gems' array in a config file within theme-gem Given I have a configuration file with: | key | value | | theme | test-theme | | gems | [jekyll-data, another-test-plugin] | | exclude | [Gemfile, Gemfile.lock] | And I have a Gemfile with plugin: | name | path | | another-test-plugin | ../../test/fixtures/another-test-plugin | When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And the "_site/test-sitemap.xml" file should exist And the "_site/test-feed.xml" file should not exist Scenario: Theme-gem has a config file with valid '' object Given I have a configuration file with: | key | value | | theme | test-theme | | gems | [jekyll-data] | | exclude | [Gemfile, Gemfile.lock] | And I have a valid Gemfile And I have a "page.md" file with content: """ --- --- theme-logo : ![theme-logo]({{ theme.logo }}) theme-variant : {{ theme.theme_variant }} """ When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And I should see "theme-logo : theme-logo" in "_site/page.html" And I should see "theme-variant : Charcoal" in "_site/page.html" jekyll-data-1.1.1/features/theme_data_reader.feature000066400000000000000000000077571400321047600225400ustar00rootroot00000000000000Feature: Reading Data files in Gem-based Themes As a hacker who likes to share my expertise I want to be able to include data files in my gemified theme In order to supplement the templates with default text-strings Scenario: A site not using a gem-based theme Given I have a configuration file with: | key | value | | exclude | [Gemfile, Gemfile.lock] | And I have a Gemfile with plugin: | name | path | | test-plugin | ../../test/fixtures/test-plugin | When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And the "_site/test-feed.xml" file should exist Scenario: Theme-gem has a data file to support i18n Given I have a configuration file with: | key | value | | lang | fr | | theme | test-theme | | gems | [jekyll-data] | | exclude | [Gemfile, Gemfile.lock] | And I have a "locales.md" file with content: """ --- --- {% assign ui = site.data.locales[site.lang] %} {% assign user = "John Smith" %} {{ ui.greeting }} {{ user }} {{ ui.prev }} {{ ui.next }} """ And I have a valid Gemfile When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And I should see "Bonjour, Bienvenue! John Smith" in "_site/locales.html" And I should see "précédent" in "_site/locales.html" And I should see "prochain" in "_site/locales.html" Scenario: Overriding a data file within theme-gem - Method I Given I have a configuration file with: | key | value | | lang | fr | | theme | test-theme | | gems | [jekyll-data] | | exclude | [Gemfile, Gemfile.lock] | And I have a "locales.md" file with content: """ --- --- {% assign ui = site.data.locales[site.lang] %} {% assign user = "John Smith" %} {{ ui.greeting }} {{ user }}! {{ ui.prev }} {{ ui.next }} """ And I have a _data directory And I have a "_data/locales.yml" file with content: """ fr: greeting: "Bonjour! Bienvenue" """ And I have a valid Gemfile When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And I should see "Bonjour! Bienvenue John Smith!" in "_site/locales.html" And I should see "précédent" in "_site/locales.html" And I should see "prochain" in "_site/locales.html" Scenario: Overriding a data file within theme-gem - Method II Given I have a configuration file with: | key | value | | lang | fr | | theme | test-theme | | gems | [jekyll-data] | | exclude | [Gemfile, Gemfile.lock] | And I have a "locales.md" file with content: """ --- --- {% assign ui = site.data.locales[site.lang] %} {% assign user = "John Smith" %} {{ ui.greeting }} {{ user }}! {{ ui.prev }} {{ ui.next }} """ And I have a _data/locales directory And I have a "_data/locales/fr.yml" file with content: """ greeting: "Bonjour! Bienvenue" """ And I have a valid Gemfile When I run bundle exec jekyll build Then I should get a zero exit status And the _site directory should exist And I should see "Bonjour! Bienvenue John Smith!" in "_site/locales.html" And I should see "précédent" in "_site/locales.html" And I should see "prochain" in "_site/locales.html" jekyll-data-1.1.1/jekyll-data.gemspec000066400000000000000000000021751400321047600174630ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "jekyll-data/version" Gem::Specification.new do |spec| spec.name = "jekyll-data" spec.version = JekyllData::VERSION spec.authors = ["Ashwin Maroli"] spec.email = ["ashmaroli@gmail.com"] spec.summary = "A plugin to read '_config.yml' and data files within Jekyll theme-gems" spec.homepage = "https://github.com/ashmaroli/jekyll-data" spec.license = "MIT" spec.metadata = { "allowed_push_host" => "https://rubygems.org" } spec.files = `git ls-files -z`.split("\x0").select do |f| f.match(%r!^(lib/|(LICENSE|README)((\.(txt|md|markdown)|$)))!i) end spec.require_paths = ["lib"] spec.add_runtime_dependency "jekyll", ">= 3.3", "< 5.0.0" spec.add_development_dependency "bundler", ">= 1.14.3" spec.add_development_dependency "cucumber", "~> 5.1.0" spec.add_development_dependency "minitest", "~> 5.0" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rubocop-jekyll", "~> 0.11.0" end jekyll-data-1.1.1/lib/000077500000000000000000000000001400321047600144565ustar00rootroot00000000000000jekyll-data-1.1.1/lib/jekyll-data.rb000066400000000000000000000036171400321047600172130ustar00rootroot00000000000000# frozen_string_literal: true require "jekyll" require "jekyll-data/version" module JekyllData autoload :Reader, "jekyll-data/reader" autoload :ThemedSiteDrop, "jekyll-data/themed_site_drop" autoload :ThemeDataReader, "jekyll-data/theme_data_reader" autoload :ThemeConfiguration, "jekyll-data/theme_configuration" end # Monkey-patches require_relative "jekyll/build_options" require_relative "jekyll/data_path" require_relative "jekyll/theme_drop" # ---------------------------------------------------------------------------- # Modify the current site instance only if it uses a gem-based theme. # # if a '_config.yml' is present at the root of theme-gem, it is evaluated and # the extracted hash data is incorprated into the site's config hash. # # *Jekyll 4.0 has this feature incorporated in its core.* # ---------------------------------------------------------------------------- unless Jekyll::VERSION.start_with?("4") Jekyll::Hooks.register :site, :after_reset do |site| if site.theme file = site.in_theme_dir("_config.yml") JekyllData::ThemeConfiguration.reconfigure(site) if File.exist?(file) end end end # --------------------------------------------------------------------------- # Replace Jekyll::Reader with a subclass JekyllData::Reader only if the # site uses a gem-based theme. # # If a _config.yml exists at the root of the theme-gem, output its path. # Placed here inorder to avoid outputting the path after every regeneration. # # *Jekyll 4.0 detects a theme-configuration natively.* # --------------------------------------------------------------------------- Jekyll::Hooks.register :site, :after_init do |site| if site.theme unless Jekyll::VERSION.start_with?("4") file = site.in_theme_dir("_config.yml") Jekyll.logger.info "Theme Config file:", file if File.exist?(file) end site.reader = JekyllData::Reader.new(site) end end jekyll-data-1.1.1/lib/jekyll-data/000077500000000000000000000000001400321047600166575ustar00rootroot00000000000000jekyll-data-1.1.1/lib/jekyll-data/reader.rb000066400000000000000000000140171400321047600204510ustar00rootroot00000000000000# frozen_string_literal: true require "csv" module JekyllData class Reader < Jekyll::Reader def initialize(site) @site = site @theme = site.theme if @theme.data_path @theme_data_files = Dir[File.join(@theme.data_path, "**", "*.{yaml,yml,json,csv,tsv}")] end end # Read data files within theme-gem. # # Returns nothing. def read super read_theme_data end # Read data files within a theme gem and add them to internal data # # Returns a hash appended with new data def read_theme_data if @theme.data_path # # show contents of "/_data/" dir being read while degugging. inspect_theme_data theme_data = ThemeDataReader.new(site).read(site.config["data_dir"]) @site.data = Jekyll::Utils.deep_merge_hashes(theme_data, @site.data) # # show contents of merged site.data hash while debugging with # additional --show-data switch. inspect_merged_hash if site.config["show-data"] && site.config["verbose"] end end private # Private: # (only while debugging) # # Print a list of data file(s) within the theme-gem def inspect_theme_data print_clear_line Jekyll.logger.debug "Reading:", "Theme Data Files..." @theme_data_files.each { |file| Jekyll.logger.debug "", file } print_clear_line Jekyll.logger.debug "Merging:", "Theme Data Hash..." unless site.config["show-data"] && site.config["verbose"] Jekyll.logger.debug "", "use --show-data with --verbose to output " \ "merged Data Hash.".cyan print_clear_line end end # Private: # (only while debugging) # # Print contents of the merged data hash def inspect_merged_hash Jekyll.logger.debug "Inspecting:", "Site Data >>" # the width of generated logger[message] @width = 50 @dashes = "-" * @width inspect_hash @site.data print_clear_line end # -------------------------------------------------------------------- # Private helper methods to inspect data hash and output contents # to logger at level debugging. # -------------------------------------------------------------------- # Dissect the (merged) site.data hash and print its contents # # - Print the key string(s) # - Individually analyse the hash[key] values and extract contents # to output. def inspect_hash(hash) hash.each do |key, value| print_key key if value.is_a? Hash inspect_inner_hash value elsif value.is_a? Array extract_hashes_and_print value else print_string value.to_s end end end # Analyse deeper hashes and extract contents to output def inspect_inner_hash(hash) hash.each do |key, value| if value.is_a? Array print_label key extract_hashes_and_print value elsif value.is_a? Hash print_subkey_and_value key, value else print_hash key, value end end end # If an array of strings, print. Otherwise assume as an # array of hashes (sequences) that needs further analysis. def extract_hashes_and_print(array) array.each do |entry| if entry.is_a? String print_list entry else inspect_inner_hash entry end end end # # -------------------------------------------------------------------- # Private methods for formatting log messages while debugging # -------------------------------------------------------------------- # Splits a string longer than the value of '@width' into smaller # strings and prints each line as a logger[message] # # string - the long string # # label - optional text to designate the printed lines. def print_long_string(string, label = "") strings = string.scan(%r!(.{1,#{@width}})(\s+|\W|\Z)!).map { |s| s.join.strip } first_line = strings.first.cyan label.empty? ? print_value(first_line) : print(label, first_line) strings[1..-1].each { |s| print_value s.cyan } end # Prints key as logger[topic] and value as [message] def print_hash(key, value) if value.length > @width print_long_string value, "#{key}:" else print "#{key}:", value.cyan end end def print_list(item) if item.length > @width print_long_string item, "-" else print "-", item.cyan end end def print_string(str) if str.length > @width print_long_string str else print_value str.inspect end end # Prints the site.data[key] in color def print_key(key) print_clear_line print "Data Key:", " #{key} ".center(@width, "=") print_clear_line end # Prints label, keys and values of mappings def print_subkey_and_value(key, value) print_label key value.each do |subkey, val| if val.is_a? Hash print_inner_subkey subkey inspect_inner_hash val elsif val.is_a? Array print_inner_subkey subkey extract_hashes_and_print val elsif val.is_a? String print_hash subkey, val end end end # Print only logger[message], [topic] = nil def print_value(value) if value.is_a? Array extract_hashes_and_print value else print "", value end end # Print only logger[topic] appended with a colon def print_label(key) print_value " #{key} ".center(@width, "-") end def print_inner_subkey(key) print "#{key}:", @dashes end def print_dashes print "", @dashes end def print_clear_line print "" end # Redefine Jekyll Loggers to have the [topic] indented by 30. # (rjust by just 29 to accomodate the additional whitespace added # by Jekyll) def print(topic, message = "") Jekyll.logger.debug topic.rjust(29), message end end end jekyll-data-1.1.1/lib/jekyll-data/theme_configuration.rb000066400000000000000000000040561400321047600232420ustar00rootroot00000000000000# frozen_string_literal: true module JekyllData class ThemeConfiguration < Jekyll::Configuration class << self # Public: Establish a new site.config hash by reading an optional config # file within the theme-gem and appending the resulting hash to # existing site.config filling in keys not already defined. # # site: current Jekyll::Site instance. # # Returns a config Hash to be used by an 'after_reset' hook. def reconfigure(site) default_hash = Jekyll::Configuration::DEFAULTS theme_config = ThemeConfiguration.new(site).read_theme_config # Merge with existing site.config and strip any remaining defaults config = Jekyll::Utils.deep_merge_hashes( theme_config, site.config ).reject { |key, value| value == default_hash[key] } # Merge DEFAULTS < _config.yml in theme-gem < config file(s) from source # and redefine site.config site.config = Jekyll::Configuration.from( Jekyll::Utils.deep_merge_hashes(theme_config, config) ) end end # def initialize(site) @site = site end # Public: Read the '_config.yml' file within the theme-gem. # Additionally validates that the extracted config data and the # the 'value' of ' key', when present, is a Hash. # # Returns a Configuration Hash def read_theme_config file = @site.in_theme_dir("_config.yml") theme_name = @site.theme.name config = safe_load_file(file) check_config_is_hash!(config, file) validate_config_hash config[theme_name] unless config[theme_name].nil? config end private # Validate the key's value to be accessed via the `theme` # namespace. def validate_config_hash(value) unless value.is_a? Hash Jekyll.logger.abort_with "JekyllData:", "Theme Configuration should be a " \ "Hash of key:value pairs or mappings. But got #{value.class} instead." end end end end jekyll-data-1.1.1/lib/jekyll-data/theme_data_reader.rb000066400000000000000000000017541400321047600226300ustar00rootroot00000000000000# frozen_string_literal: true module JekyllData class ThemeDataReader < Jekyll::DataReader attr_reader :site, :content def initialize(site) super @source_dir = site.in_theme_dir("/") end def read(dir) return unless site.theme && site.theme.data_path base = site.in_theme_dir(dir) read_data_to(base, @content) @content end def read_data_to(dir, data) return unless File.directory?(dir) && !@entry_filter.symlink?(dir) entries = Dir.chdir(dir) do Dir["*.{yaml,yml,json,csv,tsv}"] + Dir["*"].select { |fn| File.directory?(fn) } end entries.each do |entry| path = @site.in_theme_dir(dir, entry) next if @entry_filter.symlink?(path) if File.directory?(path) read_data_to(path, data[sanitize_filename(entry)] = {}) else key = sanitize_filename(File.basename(entry, ".*")) data[key] = read_data_file(path) end end end end end jekyll-data-1.1.1/lib/jekyll-data/themed_site_drop.rb000066400000000000000000000004361400321047600225250ustar00rootroot00000000000000# frozen_string_literal: true module JekyllData class ThemedSiteDrop < Jekyll::Drops::SiteDrop extend Forwardable mutable false def_delegator :@obj, :site_data, :data def_delegators :@obj, :theme private def_delegator :@obj, :config, :fallback_data end end jekyll-data-1.1.1/lib/jekyll-data/version.rb000066400000000000000000000001111400321047600206620ustar00rootroot00000000000000# frozen_string_literal: true module JekyllData VERSION = "1.1.1" end jekyll-data-1.1.1/lib/jekyll/000077500000000000000000000000001400321047600157505ustar00rootroot00000000000000jekyll-data-1.1.1/lib/jekyll/build_options.rb000066400000000000000000000007351400321047600211540ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll class Command class << self # # patch original method to inject a '--show-data' switch to display # merged data hash # alias_method :original_build_options, :add_build_options def add_build_options(cmd) original_build_options(cmd) cmd.option "show-data", "--show-data", "Print merged site-data hash when used with --verbose." end end end end jekyll-data-1.1.1/lib/jekyll/data_path.rb000066400000000000000000000002051400321047600202170ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll class Theme def data_path @data_path ||= path_for "_data" end end end jekyll-data-1.1.1/lib/jekyll/theme_drop.rb000066400000000000000000000011251400321047600204220ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module Drops class UnifiedPayloadDrop < Drop # Register a namespace to easily call subkeys under key # in the _config.yml within a theme-gem via its bundled templates. # e.g. with this drop, theme-specific variables usually called like # {{ site.minima.date_format }} can be shortened to simply # {{ theme.date_format }}. def theme @theme_drop ||= begin config = site.send(:fallback_data) config[config["theme"]] end end end end end jekyll-data-1.1.1/script/000077500000000000000000000000001400321047600152145ustar00rootroot00000000000000jekyll-data-1.1.1/script/bootstrap000077500000000000000000000000531400321047600171550ustar00rootroot00000000000000#!/usr/bin/env bash set -e bundle install jekyll-data-1.1.1/script/cibuild000077500000000000000000000003051400321047600165530ustar00rootroot00000000000000#!/usr/bin/env bash set -e if [[ -z "$TEST_SUITE" ]] then script/fmt script/test ci elif [[ -x "script/$TEST_SUITE" ]] then script/$TEST_SUITE else echo "Unknown test suite." exit 1 fi jekyll-data-1.1.1/script/cucumber000077500000000000000000000001221400321047600167420ustar00rootroot00000000000000#!/usr/bin/env bash time ruby -S bundle exec cucumber \ --format progress "$@" jekyll-data-1.1.1/script/fmt000077500000000000000000000001431400321047600157260ustar00rootroot00000000000000#!/usr/bin/env bash set -e echo "Rubocop $(bundle exec rubocop --version)" bundle exec rubocop -D jekyll-data-1.1.1/script/rubies000077500000000000000000000007361400321047600164410ustar00rootroot00000000000000#!/bin/bash # ----------------------------------------------------------------------------- # If you send us a ruby then we use that, if you do not then we test with # whatever we can detect, this way you can run both suites when you test out # your source, we expect full coverage now, not just MRI. # ----------------------------------------------------------------------------- rubies=() for r in ruby jruby; do if which "$r" > /dev/null 2>&1 then echo $r fi done jekyll-data-1.1.1/script/test000077500000000000000000000020021400321047600161130ustar00rootroot00000000000000#!/usr/bin/env bash set -e # Usage: # script/test # script/test [ruby|jruby] # script/test if [ -d test/dest ] then rm -r test/dest fi # ----------------------------------------------------------------------------- # If you send us a ruby then we use that, if you do not then we test with # whatever we can detect, this way you can run both suites when you test out # your source, we expect full coverage now, not just MRI. # ----------------------------------------------------------------------------- if [[ "$1" == "ci" ]] then rubies=( ruby ) shift elif [[ "$1" == "ruby" ]] || [[ "$1" == "jruby" ]] then rubies=( $1 ) shift else rubies=($(script/rubies)) fi for ruby in $rubies; do if [[ "$ruby" == "jruby" ]] then testopts="" else testopts="--profile" fi if [[ $# -lt 1 ]] then set -x time $ruby -S bundle exec \ rake TESTOPTS=$testopts test else set -x time $ruby -S bundle exec ruby -I test \ "$@" $testops fi done jekyll-data-1.1.1/script/test-site000077500000000000000000000017231400321047600170660ustar00rootroot00000000000000#!/usr/bin/env bash # Runs the `jekyll build` command with various switches and builds the default site as a sanity check set -e cd test/fixtures/test-site if ! jekyll -v then echo "" echo "Installing site dependencies" echo "----------------------------" BUNDLE_GEMFILE=Gemfile bundle install fi echo "" echo "Building the site with default options" echo "--------------------------------------" if BUNDLE_GEMFILE=Gemfile bundle exec jekyll build --trace then echo "" echo "Build Success." echo "" echo "Building the site with --verbose" echo "--------------------------------" BUNDLE_GEMFILE=Gemfile bundle exec jekyll build --verbose --trace echo "" echo "Build Success." echo "" echo "Building the site with --verbose and --show-data" echo "------------------------------------------------" BUNDLE_GEMFILE=Gemfile bundle exec jekyll build --verbose --show-data --trace exit 0 else echo "" echo "Error building site." exit 1 fi jekyll-data-1.1.1/test/000077500000000000000000000000001400321047600146675ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/000077500000000000000000000000001400321047600165405ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/another-test-plugin/000077500000000000000000000000001400321047600224515ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/another-test-plugin/another-test-plugin.gemspec000066400000000000000000000006061400321047600277310ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |s| s.name = "another-test-plugin" s.version = "0.1.0" s.licenses = ["MIT"] s.summary = "A plugin that creates an empty 'sitemap.xml' to test JekyllData Plugin" s.authors = ["JekyllData"] s.require_paths = ["lib"] end jekyll-data-1.1.1/test/fixtures/another-test-plugin/lib/000077500000000000000000000000001400321047600232175ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/another-test-plugin/lib/another-test-plugin.rb000066400000000000000000000006371400321047600274630ustar00rootroot00000000000000# frozen_string_literal: true require "jekyll" # code abstracted from the official 'jekyll-feed' plugin # at https://github.com/jekyll/jekyll-feed/ Jekyll::Hooks.register :site, :pre_render do |site| page = AnotherTestPlugin::NoFile.new(site, "", "", "test-sitemap.xml") site.pages << page end module AnotherTestPlugin class NoFile < Jekyll::Page def read_yaml(*) @data ||= {} end end end jekyll-data-1.1.1/test/fixtures/different_data_output.html000066400000000000000000000011621400321047600240050ustar00rootroot00000000000000

Hello There, Welcome!

This site has a _data directory at source root. It contains a locale subdirectory with a YAML file called mu.yml

previous next

jekyll-data-1.1.1/test/fixtures/no_data_config_output.html000066400000000000000000000010561400321047600240020ustar00rootroot00000000000000

Site Details

This site does not have a _data directory at source.

Is logo enabled? logo.png

Theme Variant: Charcoal

Show recent posts in a: list

Max no. of recent posts: 4

jekyll-data-1.1.1/test/fixtures/no_data_output.html000066400000000000000000000007021400321047600224520ustar00rootroot00000000000000

Hello There, Welcome!

This site does not have a _data directory at source.

previous next

jekyll-data-1.1.1/test/fixtures/same_data_output.html000066400000000000000000000011611400321047600227630ustar00rootroot00000000000000

Welcome to the Future!

This site has a _data directory at source root. It contains a locale subdirectory with a YAML file called en.yml

older newer

jekyll-data-1.1.1/test/fixtures/same_data_override.html000066400000000000000000000011611400321047600232420ustar00rootroot00000000000000

Welcome to the Future!

This site has a _data directory at source root. It contains a locale subdirectory with a YAML file called en.yml

older newer

jekyll-data-1.1.1/test/fixtures/test-plugin/000077500000000000000000000000001400321047600210135ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-plugin/lib/000077500000000000000000000000001400321047600215615ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-plugin/lib/test-plugin.rb000066400000000000000000000006161400321047600243640ustar00rootroot00000000000000# frozen_string_literal: true require "jekyll" # code abstracted from the official 'jekyll-feed' plugin # at https://github.com/jekyll/jekyll-feed/ Jekyll::Hooks.register :site, :pre_render do |site| page = TestPlugin::NoFile.new(site, "", "", "test-feed.xml") site.pages << page end module TestPlugin class NoFile < Jekyll::Page def read_yaml(*) @data ||= {} end end end jekyll-data-1.1.1/test/fixtures/test-plugin/test-plugin.gemspec000066400000000000000000000006121400321047600246320ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |s| s.name = "test-plugin" s.version = "0.1.0" s.licenses = ["MIT"] s.summary = "A plugin that creates an empty 'feed.xml' to test JekyllData Plugin" s.authors = ["JekyllData"] s.require_paths = ["lib"] end jekyll-data-1.1.1/test/fixtures/test-site/000077500000000000000000000000001400321047600204615ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-site/.gitignore000066400000000000000000000002221400321047600224450ustar00rootroot00000000000000/.bundle/ /.yardoc /_yardoc/ /coverage/ /doc/ /pkg/ /spec/reports/ /tmp/ /Gemfile.lock _site .jekyll-metadata .ruby-version .sass-cache test/dest jekyll-data-1.1.1/test/fixtures/test-site/Gemfile000066400000000000000000000022471400321047600217610ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gem "jekyll", ">= 3.3", "< 5.0.0" # use the local-versions of the gems for tests. # gem "test-plugin" is placed here to use the `:path` method to point to the local version. # # For real sites, there are following options: # # - If the theme-gem includes a '_config.yml' with the plugin listed under `gems:` # then: # - then there's no need to include the plugin in the Gemfile if (the plugin) # has been marked as a 'runtime_dependency'. # - otherwise, include it here, not necessarily under the ':jekyll_plugins' group # # - You'll have to include the plugin(s) either in your `_config.yml`, under 'gems:' # or in the Gemfile under ':jekyll_plugins' group gem "test-plugin", :path => File.expand_path("../test-plugin", __dir__) gem "test-theme", :path => File.expand_path("../test-theme", __dir__) # Recommended: all other plugins outside the theme's scope including 'jekyll-data' to be added under this group. group :jekyll_plugins do gem "another-test-plugin", :path => File.expand_path("../another-test-plugin", __dir__) gem "jekyll-data", :path => File.expand_path("../../../", __dir__) end jekyll-data-1.1.1/test/fixtures/test-site/_config.yml000066400000000000000000000011161400321047600226070ustar00rootroot00000000000000# Site settings title: Test Site email: your-email@domain.com description: > # This site is used to assess the 'jekyll-data' plugin. Notable change from the default config file generated by 'jekyll new' command is the absence of the 'gems:' array. The plugins required by this site's theme is handled by the 'config.yml' within the theme-gem. Additional plugins that may be required outside the theme's scope is added to the ':jekyll_plugins' group in the Gemfile. twitter_username: jekyllrb github_username: jekyll theme: test-theme exclude: - Gemfile - Gemfile.lock jekyll-data-1.1.1/test/fixtures/test-site/_posts/000077500000000000000000000000001400321047600217705ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-site/_posts/2017-01-01-welcome-to-jekyll.markdown000066400000000000000000000022641400321047600301260ustar00rootroot00000000000000--- layout: default title: "Welcome to Jekyll!" date: 2016-01-01 09:00:00 categories: jekyll update --- You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated. To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works. Jekyll also offers powerful support for code snippets: {% highlight ruby %} def print_hi(name) puts "Hi, #{name}" end print_hi('Tom') #=> prints 'Hi, Tom' to STDOUT. {% endhighlight %} Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk]. [jekyll-docs]: https://jekyllrb.com/docs/home [jekyll-gh]: https://github.com/jekyll/jekyll [jekyll-talk]: https://talk.jekyllrb.com/ jekyll-data-1.1.1/test/fixtures/test-site/index.md000066400000000000000000000003311400321047600221070ustar00rootroot00000000000000--- # You don't need to edit this file, it's empty on purpose. # Edit theme's home layout instead if you wanna make some changes # See: https://jekyllrb.com/docs/themes/#overriding-theme-defaults layout: default --- jekyll-data-1.1.1/test/fixtures/test-theme/000077500000000000000000000000001400321047600206175ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_config.yml000066400000000000000000000012751400321047600227530ustar00rootroot00000000000000title: Test Theme email: tester@domain.com # the '>' means to ignore newlines until "baseurl:" description: > Powered by a test-theme. This text has been inserted by your theme gem. Override by defining a "description:" key in the config file at source. baseurl: "" markdown: kramdown post_excerpts: enabled # "enabled" / "disabled" # Theme configurations test-theme: logo: logo.png # enter 'disable' to use `site.title` instead. sidebar: enabled # enter 'disable' to activate horizontal navbar. theme_variant: Charcoal # choose from 'Ocean', 'Grass', 'Charcoal' recent_posts: style: list # choose from 'list' and 'grid'. quantity: '4' # either '4' or '6' gems: - test-plugin jekyll-data-1.1.1/test/fixtures/test-theme/_data/000077500000000000000000000000001400321047600216675ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_data/blank.yml000066400000000000000000000002621400321047600235010ustar00rootroot00000000000000# No parsable data. Just a file with a lone comment string. Is this a data # file then?. This string is not accessible via `{{ site.data.blank }}` either. # Will output "false". jekyll-data-1.1.1/test/fixtures/test-theme/_data/config-hash.yml000066400000000000000000000016621400321047600246050ustar00rootroot00000000000000title: Test Hash email: tester@domain.com description: > This file is used to test the output of various hash types to the plugin's logger output. This particular folded (uses '>') block of text will showcase outputting long strings of text as wrapped to multiple lines of a set width. Another related block would be the 'non-folded' type (uses '|') and its lines are are new-line-aware. baseurl: "/blog" url: "" markdown: kramdown post_excerpts: enabled # Complex Hash object with nest hash-maps, lists and sequences. test-theme: logo: logo.png sidebar: enabled theme_variant: Charcoal recent_posts: style: list quantity: '4' plugins: - test-plugin - another-test-plugin navbar: - title: About Me page: about-me.html tooltip: Get to know me here. - title: Contact Us page: contact-us.html tooltip: Various ways to reach me. gems: - test-plugin - another-test-plugin jekyll-data-1.1.1/test/fixtures/test-theme/_data/locales/000077500000000000000000000000001400321047600233115ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_data/locales/en.yml000066400000000000000000000004751400321047600244440ustar00rootroot00000000000000greeting: "Hello There, Welcome!" prev: previous next: next long_strings: - THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG - THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG DOZING UNDER THE CANOPY - THEQUICKBROWNFOXJUMPSOVERTHELAZYDOGDOZINGUNDERTHECANOPY - THEQUICKBROWNFOX/JUMPSOVERTHELAZYDOG/DOZINGUNDERTHECANOPY jekyll-data-1.1.1/test/fixtures/test-theme/_data/locales/fr.yml000066400000000000000000000001011400321047600244330ustar00rootroot00000000000000greeting: "Bonjour, Bienvenue!" prev: précédent next: prochain jekyll-data-1.1.1/test/fixtures/test-theme/_data/navigation/000077500000000000000000000000001400321047600240265ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_data/navigation/footer-links.yml000066400000000000000000000001721400321047600271650ustar00rootroot00000000000000# Footer links - title: About url: /about/ - title: Contact Me url: /contact-me/ - title: Register url: /register/ jekyll-data-1.1.1/test/fixtures/test-theme/_data/navigation/topnav.yml000066400000000000000000000002701400321047600260570ustar00rootroot00000000000000# Menu navigation links - title: Home url: / - title: About url: /about/ - title: Contact url: /contact/ - title: Link 1 url: /link-1.html - title: Link 2 url: /link-2.html jekyll-data-1.1.1/test/fixtures/test-theme/_data/sidemenu.yml000066400000000000000000000004141400321047600242220ustar00rootroot00000000000000# Side-menu navigation links - title: Home url: / - title: About url: /about/ - title: Contact url: /contact/ - title: Link 1 url: http://an-absolute-url-to/a-really-deep/filecalled/some_page.html - title: Link 2 url: http://another-absolute-url-to/a-page/ jekyll-data-1.1.1/test/fixtures/test-theme/_data/string.yml000066400000000000000000000002301400321047600237130ustar00rootroot00000000000000> No keys. Just a file with a lone string. Is this a data file then? This string is still accessible via `{{ site.data.string }}` in the templates. jekyll-data-1.1.1/test/fixtures/test-theme/_includes/000077500000000000000000000000001400321047600225645ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_includes/footer-links.html000066400000000000000000000002201400321047600260600ustar00rootroot00000000000000
    {% for link in site.data.navigation.footer-links %}
  • {{ link.title }}
  • {% endfor %}
jekyll-data-1.1.1/test/fixtures/test-theme/_layouts/000077500000000000000000000000001400321047600224565ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_layouts/default.html000066400000000000000000000002051400321047600247650ustar00rootroot00000000000000
{{ content }}
jekyll-data-1.1.1/test/fixtures/test-theme/_layouts/home.html000066400000000000000000000005161400321047600242760ustar00rootroot00000000000000--- layout: default ---

{{ site.data.locales[site.lang].greeting }}

{{ content }}

{{ site.data.locales[site.lang].prev }} {{ site.data.locales[site.lang].next }}

jekyll-data-1.1.1/test/fixtures/test-theme/_layouts/page.html000066400000000000000000000006071400321047600242630ustar00rootroot00000000000000--- layout: test ---

Site Details

{{ content }}

Is logo enabled? {% unless theme.logo == 'disabled' %}{{ theme.logo }}{% endunless %}

Theme Variant: {{ theme.theme_variant }}

Show recent posts in a: {{ theme.recent_posts.style }}

Max no. of recent posts: {{ theme.recent_posts.quantity }}

jekyll-data-1.1.1/test/fixtures/test-theme/_layouts/test.html000066400000000000000000000004541400321047600243260ustar00rootroot00000000000000
{{ content }}
{% unless theme.sidebar == 'disabled' %} {% else %}{% endunless %} jekyll-data-1.1.1/test/fixtures/test-theme/_sass/000077500000000000000000000000001400321047600217275ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/_sass/test-theme-black.scss000066400000000000000000000000341400321047600257520ustar00rootroot00000000000000.sample { color: black; } jekyll-data-1.1.1/test/fixtures/test-theme/_sass/test-theme-red.scss000066400000000000000000000000321400321047600254460ustar00rootroot00000000000000.sample { color: red; } jekyll-data-1.1.1/test/fixtures/test-theme/assets/000077500000000000000000000000001400321047600221215ustar00rootroot00000000000000jekyll-data-1.1.1/test/fixtures/test-theme/assets/application.coffee000066400000000000000000000000411400321047600255700ustar00rootroot00000000000000--- --- alert "From your theme." jekyll-data-1.1.1/test/fixtures/test-theme/assets/logo.png000066400000000000000000000106501400321047600235710ustar00rootroot00000000000000PNG  IHDR>atEXtSoftwareAdobe ImageReadyqe<JIDATx]Mr";N웾tv6ON`-p'pMof;_-T~RU 6*_RЅoZ|ziM [?6'->/>0_P%1şcó|J3Bv@| F,O?/ȰC/~<[wrӃe {iŸⳲXL?fd4?i&4Mtqlo%x{~DCn =!`J0AxῘᵁ\,;j_p.&@Аy0 s3IF ғdLz/BsE8zhҰi )?p`/T>BX#f q:O`605J )5ZJQ˙l0  F-do9*Mp ugD`|[;BAMV=KZAYOjZrUn3ou|H^}89@h:F${G =%da(uD怑r-F9}*GSvOmU3P>Y̋1wQ0R\v?G mvm&6$ݔ@%"`MZ{{>c˿'&em5K8kjs똮o,^DJ)j;)hI=!jW= {d^Pz`Тnp<-{%d6}}FV%(w+t  q8G9UZZ_Ԩsؠ^SY:I{W%cEFzWWR ''}$LZĖckob]EbFxgDOė9(f` ΦȻ_3ʩ2Ls©q jYDT5^"Hjj{nUg8Mх'RKK"&=%Ű$]SR/4ZJU NP<;莛JzK͌7i+]}1͈ʴ}?0%J P 0,aQ™U`[Fs]ݠge*¤,%p ̟"3yB%[=SL S`n3t tw`8voT&{~ݹn Zh?*LƄ( 顣7BWJ&VrK3r;I=HW6R@U%]DGpcyj!r[z&WF%J(DL[wGLQ ̽L,%^gYz )^EܷIJm߀\ ɚXc*!ƕ1bL[3>9f>KL ^L!Kq1 %s^ӋZy7{\[X#ya-"ۨ+U6X_eWM?_*G%#-Aa"l Z IA9$`YnhjR-nsF 1@ 0:,4TC;}VwiXV餟QaA]q=.2q/l/WwTj* t?juT0逦%gd|9Jd' qO|֪ڑ>tgfO)Pڿ5amKio_(RH 3F{uHnSؔȑəAk=;%CΥLj2BhgXkCQqٹ` -7y{&j8F8Lx,'K d"rI3 Qk/'ǘ]^NOɄӛ[` y@1xfQ=iv1V$r(A&Ͼ ɛ:Å@GrLq[f/Aa&GYIaLR|6@_6KCyƮ.TL'Ä*%&IHמ|]gK !C۝h #iH(1JǨH4q,cWWʑNByu #,Gh*#^]r .sr9ǽ(h$fy~jYo@:S 8Ϫ9]&2"g?KxL-*e5Ɨv83QAk(ΟʤT? QHhDt8515TIO"wdu2K3J(w3 T C33Z ˜N -V}=>4Ĺ9Ҭ$LcuJT^^KoK1uU CTT&#1 _D ߢ1Xa&`SASYdÜ맚11IV0>CJ2j:{kOA;Na>7F[t2nᛎ%9 ,Byz$=,W I5멪Хn x0Ri KC?_E:.fdlZ dl#JKY(1=:R[)gL”@11q6RwM_._=Qʹc=Eɗlk kRb E[T>;Qv I;rK9j.7{} I HC5-Ƞ|fosHySψm)-dL k6^Db%qYyH(QW:sW ؖw9\4kE'Ŗ~AԥWY pɯg\C CD[B'`_~ {kfr"dZUBhB0-9tE q )[R8H BZTW˟ -w8, w 2t #L@fP}`8V@D8dK^o9fB 4_Jn:%lɿߓHks 5I ǁ1whi3Fqh  j?5xcqv'0# 5{ǁw 0?VA6rŀ=SFf2'XcEo ࠲iW[у"yB4@Ѹ c󈌟J/od8]o,\\͞&&K&@C"yxaZ2^F@3̓KQ9 VO(:p:l`hS x40|L?8Z# (:M \I,Zj} j*jr(3J fSU_XJlzIXU^7Ѣr3ߩ~bn\ҟf_Xjl3IS..x8S[R_ӲM :n1b]gCQ n`~90Pbg[΄Zy8TA|hԶ O):0 Ɗ<2`࡛.|vo=Dv6nBxk+ki+ true ) ] module Minitest::Assertions def assert_exist(filename, msg = nil) msg = message(msg) { "Expected '#{filename}' to exist" } assert File.exist?(filename), msg end def refute_exist(filename, msg = nil) msg = message(msg) { "Expected '#{filename}' not to exist" } refute File.exist?(filename), msg end end module DirectoryHelpers def fixture_dir(*subdirs) test_dir("fixtures", *subdirs) end def dest_dir(*subdirs) test_dir("dest", *subdirs) end def source_dir(*subdirs) test_dir("source", *subdirs) end def test_dir(*subdirs) File.join(__dir__, *subdirs) end end class JekyllDataTest < Minitest::Test include Jekyll include JekyllData include DirectoryHelpers include ::RSpec::Mocks::ExampleMethods def mu_pp(obj) s = obj.is_a?(Hash) ? JSON.pretty_generate(obj) : obj.inspect s = s.encode Encoding.default_external if defined? Encoding s end def mocks_expect(*args) RSpec::Mocks::ExampleMethods::ExpectHost.instance_method(:expect)\ .bind(self).call(*args) end def before_setup RSpec::Mocks.setup super end def after_teardown super RSpec::Mocks.verify ensure RSpec::Mocks.teardown end def fixture_site(overrides = {}) Jekyll::Site.new(site_configuration(overrides)) end def default_configuration Marshal.load(Marshal.dump(Jekyll::Configuration::DEFAULTS)) end def build_configs(overrides, base_hash = default_configuration) Utils.deep_merge_hashes(base_hash, overrides) end def site_configuration(overrides = {}) full_overrides = build_configs( overrides, build_configs("incremental" => false) ) Configuration.from( full_overrides.merge( "theme" => "test-theme", "lang" => "en" ) ) end def clear_dest FileUtils.rm_rf(dest_dir) FileUtils.rm_rf(source_dir(".jekyll-metadata")) end def capture_output stderr = StringIO.new Jekyll.logger = Logger.new stderr yield stderr.rewind stderr.string.to_s end alias_method :capture_stdout, :capture_output alias_method :capture_stderr, :capture_output end jekyll-data-1.1.1/test/source/000077500000000000000000000000001400321047600161675ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/diff_data_keys/000077500000000000000000000000001400321047600211235ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/diff_data_keys/_data/000077500000000000000000000000001400321047600221735ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/diff_data_keys/_data/mu.yml000066400000000000000000000001001400321047600233260ustar00rootroot00000000000000greeting: Welcome to The Matrix! prev: Red Pill next: Blue Pill jekyll-data-1.1.1/test/source/diff_data_keys/different_data_key.md000066400000000000000000000002421400321047600252520ustar00rootroot00000000000000--- layout: home permalink: output.html --- This site has a _data directory at source root. It contains a `locale` subdirectory with a YAML file called `mu.yml` jekyll-data-1.1.1/test/source/empty_config_override/000077500000000000000000000000001400321047600225515ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/empty_config_override/_data/000077500000000000000000000000001400321047600236215ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/empty_config_override/_data/test-theme.yml000066400000000000000000000000361400321047600264220ustar00rootroot00000000000000# empty theme config override jekyll-data-1.1.1/test/source/empty_config_override/no_data.md000066400000000000000000000001421400321047600244750ustar00rootroot00000000000000--- layout: page permalink: output.html --- This site does not have a _data directory at source. jekyll-data-1.1.1/test/source/no_data_config/000077500000000000000000000000001400321047600211215ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/no_data_config/no_data.md000066400000000000000000000001421400321047600230450ustar00rootroot00000000000000--- layout: page permalink: output.html --- This site does not have a _data directory at source. jekyll-data-1.1.1/test/source/no_data_files/000077500000000000000000000000001400321047600207565ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/no_data_files/no_data.md000066400000000000000000000001421400321047600227020ustar00rootroot00000000000000--- layout: home permalink: output.html --- This site does not have a _data directory at source. jekyll-data-1.1.1/test/source/not_hash_config_override/000077500000000000000000000000001400321047600232165ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/not_hash_config_override/_data/000077500000000000000000000000001400321047600242665ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/not_hash_config_override/_data/test-theme.yml000066400000000000000000000001731400321047600270710ustar00rootroot00000000000000# theme config-override with data as an array (sequences) # - key: logo - value: logo.png - key: sidebar - value: disabled jekyll-data-1.1.1/test/source/not_hash_config_override/no_data.md000066400000000000000000000001421400321047600251420ustar00rootroot00000000000000--- layout: page permalink: output.html --- This site does not have a _data directory at source. jekyll-data-1.1.1/test/source/same_data_files/000077500000000000000000000000001400321047600212675ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/same_data_files/_data/000077500000000000000000000000001400321047600223375ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/same_data_files/_data/locales/000077500000000000000000000000001400321047600237615ustar00rootroot00000000000000jekyll-data-1.1.1/test/source/same_data_files/_data/locales/en.yml000066400000000000000000000000731400321047600251060ustar00rootroot00000000000000greeting: "Welcome to the Future!" prev: older next: newer jekyll-data-1.1.1/test/source/same_data_files/same_data_key.md000066400000000000000000000002441400321047600243770ustar00rootroot00000000000000--- layout: home permalink: override.html --- This site has a _data directory at source root. It contains a `locale` subdirectory with a YAML file called `en.yml` jekyll-data-1.1.1/test/test_theme_configuration.rb000066400000000000000000000034571400321047600223150ustar00rootroot00000000000000# frozen_string_literal: true require "helper" class TestThemeConfiguration < JekyllDataTest context "site without data files but with a configured theme" do setup do @site = fixture_site( "source" => File.join(source_dir, "no_data_config"), "destination" => File.join(dest_dir, "no_data_config") ) assert @site.theme @theme_data = ThemeDataReader.new(@site).read("_data") @site.process end should "read and use data under the 'theme' namespace" do assert_equal( File.read(File.join(fixture_dir, "no_data_config_output.html")), File.read(@site.in_dest_dir("output.html")) ) end end context "site with theme configuration overrides" do setup do @site = fixture_site( "source" => File.join(source_dir, "empty_config_override"), "destination" => File.join(dest_dir, "empty_config_override") ) end should "alert if the override file is empty" do reader = double(@site) msg = "Cannot define or override Theme Configuration with an empty file!" expect(reader).to receive(:process).with(no_args).and_return(msg) assert_equal msg, reader.process end end context "site with theme configuration overrides" do setup do @site = fixture_site( "source" => File.join(source_dir, "not_hash_config_override"), "destination" => File.join(dest_dir, "not_hash_config_override") ) end should "alert if the override is not a Hash Object" do reader = double(@site) msg = "Theme Config or its override should be a Hash of key:value pairs " \ "or mappings. But got Array instead." expect(reader).to receive(:process).with(no_args).and_return(msg) assert_equal msg, reader.process end end end jekyll-data-1.1.1/test/test_theme_reader.rb000066400000000000000000000054531400321047600207060ustar00rootroot00000000000000# frozen_string_literal: true require "helper" class TestThemeReader < JekyllDataTest context "site without data files but with a valid theme" do setup do @site = fixture_site( "source" => File.join(source_dir, "no_data_files"), "destination" => File.join(dest_dir, "no_data_files") ) assert @site.theme @theme_data = ThemeDataReader.new(@site).read("_data") @site.process end should "read data files in theme gem" do assert_equal @site.data["navigation"]["topnav"], @theme_data["navigation"]["topnav"] end should "use data from theme gem" do assert_equal( File.read(File.join(fixture_dir, "no_data_output.html")), File.read(@site.in_dest_dir("output.html")) ) end end context "site with data keys different from a valid theme data hash" do setup do @site = fixture_site( "source" => File.join(source_dir, "diff_data_keys"), "destination" => File.join(dest_dir, "diff_data_keys") ) assert @site.theme @theme_data = ThemeDataReader.new(@site).read("_data") @site.process end should "read and use data from other keys in theme gem" do assert_equal( File.read(File.join(fixture_dir, "different_data_output.html")), File.read(@site.in_dest_dir("output.html")) ) end should "not override theme data" do assert_equal( File.read(File.join(fixture_dir, "different_data_output.html")), File.read(@site.in_dest_dir("output.html")) ) end end context "site with same data keys as a valid theme data hash" do setup do @site = fixture_site( "source" => File.join(source_dir, "same_data_files"), "destination" => File.join(dest_dir, "same_data_files") ) assert @site.theme @theme_data = ThemeDataReader.new(@site).read("_data") @site.process end should "override theme data" do assert_equal( File.read(File.join(fixture_dir, "same_data_override.html")), File.read(@site.in_dest_dir("override.html")) ) end should "also use data from other keys in theme gem" do assert_equal( File.read(File.join(fixture_dir, "same_data_output.html")), File.read(@site.in_dest_dir("override.html")) ) end end context "theme gem shipped with a '_config.yml'" do setup do @site = fixture_site( "title" => "Config Test" ) end should "have its hash appended to site's config hash" do assert_contains @site.config, %w(post_excerpts enabled) end should "have its hash added only where its not already set" do refute_equal "Test Theme", @site.config["title"] assert_equal "Config Test", @site.config["title"] end end end