Class: Stylo::Combiner

Inherits:
Object
  • Object
show all
Defined in:
lib/stylo/combiner.rb

Instance Method Summary collapse

Constructor Details

#initialize(require_pattern) ⇒ Combiner

Returns a new instance of Combiner.



3
4
5
# File 'lib/stylo/combiner.rb', line 3

def initialize(require_pattern)
  @require_pattern = require_pattern
end

Instance Method Details

#process(base_directory, content) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/stylo/combiner.rb', line 7

def process(base_directory, content)
  content.gsub @require_pattern do |match|
    required_dir = File.dirname($1)
	required_dir = required_dir == '.' ? base_directory : File.join(base_directory, required_dir)

	raise "Cannot find referenced asset '#{$1}'." if !(content = AssetLoader.load_content(File.join(base_directory, $1)))
    process(required_dir, content)
  end
end