From e1e60499b1ba7117ea9cee828db380dac13397ab Mon Sep 17 00:00:00 2001 From: Garen Torikian Date: Thu, 29 Jan 2015 12:41:19 -0800 Subject: [PATCH] Factor out a `read_data_file` call to keep things clean --- lib/jekyll/site.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 85cdac18..3af47672 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -258,16 +258,23 @@ module Jekyll if File.directory?(path) read_data_to(path, data[key] = {}) else - case File.extname(path).downcase - when '.csv' - data[key] = CSV.read(path, :headers => true).map(&:to_hash) - else - data[key] = SafeYAML.load_file(path) - end + data[key] = read_data_file(path) end end end - + + # Determines how to read a data file. + # + # Returns the contents of the data file. + def read_data_file(path) + case File.extname(path).downcase + when '.csv' + CSV.read(path, :headers => true).map(&:to_hash) + else + SafeYAML.load_file(path) + end + end + # Read in all collections specified in the configuration # # Returns nothing.