NO MORE DATA COLLECTION I CAN'T HANDLE IT

This commit is contained in:
Parker Moore 2014-04-24 13:29:54 -04:00
parent 764dc88832
commit fb39b41ffb
2 changed files with 12 additions and 13 deletions

View File

@ -195,17 +195,18 @@ module Jekyll
# #
# Returns nothing # Returns nothing
def read_data(dir) def read_data(dir)
unless dir.to_s.eql?("_data") base = File.join(source, dir)
Jekyll.logger.error "Error:", "Data source directories other than '_data' have been removed.\n" + return unless File.directory?(base) && (!safe || !File.symlink?(base))
"Please move your YAML files to `_data` and remove the `data_source` key from your `_config.yml`."
end
collections['data'] = Jekyll::Collection.new(self, "data") entries = Dir.chdir(base) { Dir['*.{yaml,yml}'] }
collections['data'].read entries.delete_if { |e| File.directory?(File.join(base, e)) }
collections['data'].docs.each do |doc| entries.each do |entry|
key = sanitize_filename(doc.basename(".*")) path = File.join(source, dir, entry)
self.data[key] = doc.data next if File.symlink?(path) && safe
key = sanitize_filename(File.basename(entry, '.*'))
self.data[key] = SafeYAML.load_file(path)
end end
end end

View File

@ -57,10 +57,8 @@ class TestCollections < Test::Unit::TestCase
@site.process @site.process
end end
should "not contain any collections other than the default ones" do should "not contain any collections" do
collections = @site.collections.dup assert_equal Hash.new, @site.collections
assert collections.delete("data").is_a?(Jekyll::Collection)
assert_equal Hash.new, collections
end end
end end