lib/nanoc3/data_sources/filesystem.rb in nanoc3-3.1.2 vs lib/nanoc3/data_sources/filesystem.rb in nanoc3-3.1.3
- old
+ new
@@ -164,12 +164,12 @@
if ![ 0, 1 ].include?(content_filenames.size)
raise RuntimeError, "Found #{content_filenames.size} content files for #{key}; expected 0 or 1"
end
# Reorder elements and convert to extnames
- filenames[0] = meta_filenames[0] ? ext_of(meta_filenames[0])[1..-1] : nil
- filenames[1] = content_filenames[0] ? ext_of(content_filenames[0])[1..-1] : nil
+ filenames[0] = meta_filenames[0] ? 'yaml' : nil
+ filenames[1] = content_filenames[0] ? ext_of(content_filenames[0])[1..-1] || '': nil
end
# Done
grouped_filenames
end
@@ -237,18 +237,18 @@
# Read data
data = File.read(content_filename)
# Check presence of metadata section
- if data !~ /^(-{5}|-{3})/
+ if data[0, 3] != '-'*3 && data[0, 5] != '-'*5
return [ {}, data ]
end
# Split data
- pieces = data.split(/^(-{5}|-{3})/)
+ pieces = data.split(/^(-{5}|-{3})\s*$/)
if pieces.size < 4
raise RuntimeError.new(
- "The file '#{content_filename}' does not seem to be a nanoc #{kind}"
+ "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format."
)
end
# Parse
meta = YAML.load(pieces[2]) || {}