lib/nanoc/data_sources/static.rb in nanoc-3.6.2 vs lib/nanoc/data_sources/static.rb in nanoc-3.6.3

- old
+ new

@@ -24,28 +24,25 @@ # Unless the `hide_items` configuration attribute is false, items from static # data sources will have the :is_hidden attribute set by default, which will # exclude them from the Blogging helper's atom feed generator, among other # things. class Static < Nanoc::DataSource + identifier :static def items # Get prefix prefix = config[:prefix] || 'static' - # Get all files under prefix dir - filenames = Dir[prefix + '/**/*'].select { |f| File.file?(f) } - # Convert filenames to items - filenames.map do |filename| + self.all_files_in(prefix).map do |filename| attributes = { :extension => File.extname(filename)[1..-1], :filename => filename, } attributes[:is_hidden] = true unless config[:hide_items] == false identifier = filename[(prefix.length+1)..-1] + '/' - mtime = File.mtime(filename) checksum = Pathname.new(filename).checksum Nanoc::Item.new( filename, @@ -54,7 +51,14 @@ :binary => true, :mtime => mtime, :checksum => checksum ) end end + protected + + def all_files_in(dir_name) + Nanoc::Extra::FilesystemTools.all_files_in(dir_name) + end + end + end