File: asset_data_source.rb

package info (click to toggle)
ruby-compass 0.12.2~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,308 kB
  • sloc: ruby: 10,474; makefile: 42; xml: 14
file content (15 lines) | stat: -rw-r--r-- 400 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class AssetDataSource < Nanoc3::DataSource
  identifier :filesystem_assets

  def items
    files = []
    Dir.glob("assets/**/*").each do |f|
      files << f if File.file?(f)
    end
    files.map do |f|
      identifier = f[7..-1].gsub(/\.[^.]+$/,'')+"/"
      attrs = {:extension => File.extname(f)[1..-1]}
      Nanoc3::Item.new(File.read(f), attrs, identifier, File.mtime(f))
    end
  end
end