From fb39b41ffb4c596e31cdc6f11d6e58bda250403d Mon Sep 17 00:00:00 2001 From: Parker Moore Date: Thu, 24 Apr 2014 13:29:54 -0400 Subject: [PATCH] NO MORE DATA COLLECTION I CAN'T HANDLE IT --- lib/jekyll/site.rb | 19 ++++++++++--------- test/test_collections.rb | 6 ++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 0d6f80fc6..4f3d04fe8 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -195,17 +195,18 @@ module Jekyll # # Returns nothing def read_data(dir) - unless dir.to_s.eql?("_data") - Jekyll.logger.error "Error:", "Data source directories other than '_data' have been removed.\n" + - "Please move your YAML files to `_data` and remove the `data_source` key from your `_config.yml`." - end + base = File.join(source, dir) + return unless File.directory?(base) && (!safe || !File.symlink?(base)) - collections['data'] = Jekyll::Collection.new(self, "data") - collections['data'].read + entries = Dir.chdir(base) { Dir['*.{yaml,yml}'] } + entries.delete_if { |e| File.directory?(File.join(base, e)) } - collections['data'].docs.each do |doc| - key = sanitize_filename(doc.basename(".*")) - self.data[key] = doc.data + entries.each do |entry| + path = File.join(source, dir, entry) + next if File.symlink?(path) && safe + + key = sanitize_filename(File.basename(entry, '.*')) + self.data[key] = SafeYAML.load_file(path) end end diff --git a/test/test_collections.rb b/test/test_collections.rb index b6fd41d5b..8dbc397d1 100644 --- a/test/test_collections.rb +++ b/test/test_collections.rb @@ -57,10 +57,8 @@ class TestCollections < Test::Unit::TestCase @site.process end - should "not contain any collections other than the default ones" do - collections = @site.collections.dup - assert collections.delete("data").is_a?(Jekyll::Collection) - assert_equal Hash.new, collections + should "not contain any collections" do + assert_equal Hash.new, @site.collections end end