Class: BPM::DirectiveProcessor

Inherits:
Sprockets::DirectiveProcessor
  • Object
show all
Defined in:
lib/bpm/pipeline/directive_processor.rb

Overview

Like the regular directive processor but knows how to resolve directives as module ids, not just file paths

Instance Method Summary collapse

Instance Method Details

#process_require_directive(path) ⇒ Object



9
10
11
12
13
14
# File 'lib/bpm/pipeline/directive_processor.rb', line 9

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

#process_require_tree_directive(path = ".") ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bpm/pipeline/directive_processor.rb', line 16

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