Class: Leftovers::Precompilers::Precompiler

Inherits:
Object
  • Object
show all
Defined in:
lib/leftovers/precompilers/precompiler.rb

Instance Method Summary collapse

Constructor Details

#initialize(precompiler, matcher) ⇒ Precompiler

Returns a new instance of Precompiler.



8
9
10
11
# File 'lib/leftovers/precompilers/precompiler.rb', line 8

def initialize(precompiler, matcher)
  @precompiler = precompiler
  @matcher = matcher
end

Instance Method Details

#precompile(content, file) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/leftovers/precompilers/precompiler.rb', line 13

def precompile(content, file)
  return unless @matcher === file.relative_path

  begin
    @precompiler.precompile(content)
  rescue PrecompileError => e
    e.warn(path: file.relative_path)
    ''
  rescue ::StandardError => e
    ::Leftovers.warn "#{e.class}: #{file.relative_path} #{e.message}"
    ''
  end
end