Sha256: ea399c9d9a7ea41d843f8f088c74603587461d87a2f318473c3895cfde825599
Contents?: true
Size: 1.21 KB
Versions: 13
Compression:
Stored size: 1.21 KB
Contents
require 'sprockets' module BPM # Like the regular directive processor but knows how to resolve directives # as module ids, not just file paths class DirectiveProcessor < Sprockets::DirectiveProcessor def process_require_directive(path) project = context.environment.project module_path = project.path_from_module(path) path = context.resolve(module_path) rescue path context.require_asset(path) end def process_require_tree_directive(path = ".") if relative?(path) super path else project = context.environment.project module_path = project.path_from_module path root = module_path.sub(/^([^\/]+)\//) do |s| project.path_from_package s end context.depend_on(root) Dir["#{root}/**/*"].sort.each do |filename| if filename == self.file next elsif File.directory?(filename) context.depend_on(filename) elsif context.asset_requirable?(filename) context.require_asset(filename) end end end end private def relative?(path) path =~ /^\.($|\.?\/)/ end end end
Version data entries
13 entries across 13 versions & 1 rubygems