lib/nanoc3/data_sources/filesystem.rb in nanoc3-3.0.5 vs lib/nanoc3/data_sources/filesystem.rb in nanoc3-3.0.6

- old
+ new

@@ -94,11 +94,11 @@ # Get attributes attributes = meta.merge(:file => Nanoc3::Extra::FileProxy.new(content_filename)) # Get identifier - identifier = meta_filename.sub(/^content/, '').sub(/[^\/]+\.yaml$/, '') + identifier = meta_filename_to_identifier(meta_filename, /^content/) # Get modification times meta_mtime = File.stat(meta_filename).mtime content_mtime = File.stat(content_filename).mtime mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime @@ -116,11 +116,11 @@ # Get attributes attributes = YAML.load_file(meta_filename) || {} # Get identifier - identifier = meta_filename.sub(/^layouts\//, '').sub(/\/[^\/]+\.yaml$/, '') + identifier = meta_filename_to_identifier(meta_filename, /^layouts/) # Get modification times meta_mtime = File.stat(meta_filename).mtime content_mtime = File.stat(content_filename).mtime mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime @@ -229,9 +229,13 @@ ) end # Return content filename filenames.first + end + + def meta_filename_to_identifier(meta_filename, regex) + meta_filename.sub(regex, '').sub(/[^\/]+\.yaml$/, '') end end end