Class: Nanoc::DataSources::SprocketsDataSource

Inherits:
Nanoc::DataSource
  • Object
show all
Defined in:
lib/nanoc-sprockets.rb

Constant Summary collapse

LOOSE_ASSETS =
lambda do |filename, path|
  path =~ /assets/ && !%w(.js .css).include?(File.extname(filename))
end

Instance Method Summary collapse

Instance Method Details

#itemsObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/nanoc-sprockets.rb', line 21

def items
  assets = environment.each_logical_path(*compiled_assets).to_a

  assets.map do |bundle|
    identifier = "/#{bundle}"
    asset = environment.find_asset(bundle)
    is_binary = !!(asset.pathname && !@site_config[:text_extensions].include?(File.extname(asset.pathname)[1..-1]))

    content_of_filename = is_binary ? asset.pathname : asset.to_s
    attributes = {filename: identifier, mtime: asset.mtime}
    new_item(content_of_filename, attributes, identifier, binary: is_binary)
  end
end

#upObject



13
14
15
16
17
18
19
# File 'lib/nanoc-sprockets.rb', line 13

def up
  @config = {
    path: 'assets',
    compile: [],
    assets_additionnal_paths: []
  }.merge(@config)
end