Module: Puffer::Extensions::DirectiveProcessor

Extended by:
ActiveSupport::Concern
Defined in:
lib/puffer/extensions/directive_processor.rb

Instance Method Summary collapse

Instance Method Details

#process_require_all_directive(path) ⇒ Object

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puffer/extensions/directive_processor.rb', line 8

def process_require_all_directive(path)
  raise ArgumentError, "require_all argument must be relative" unless relative?(path)

  context.environment.paths.each do |root_path|
    root = Pathname.new(root_path).join(path).expand_path

    if root.exist? && root.directory?
      context.depend_on(root)

      Dir["#{root}/*"].sort.each do |filename|
        if filename == self.file
          next
        elsif context.asset_requirable?(filename)
          context.require_asset(filename)
        end
      end
    end
  end
end