Class: Propshaft::Js::Coverage::Compiler

Inherits:
Compiler
  • Object
show all
Defined in:
lib/propshaft/js/coverage/compiler.rb

Constant Summary collapse

@@context =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.configObject



12
13
14
# File 'lib/propshaft/js/coverage/compiler.rb', line 12

def config
  @config ||= Configuration.new
end

.configure {|config| ... } ⇒ Object

Yields:



8
9
10
# File 'lib/propshaft/js/coverage/compiler.rb', line 8

def configure
  yield config
end

Instance Method Details

#compile(asset, input) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/propshaft/js/coverage/compiler.rb', line 17

def compile(asset, input)
  if Propshaft::Js::Coverage::Compiler.config.should_process
    return input unless Propshaft::Js::Coverage::Compiler.config.should_process.call(asset.path.to_s)
  end

  begin
    covered_source = $context.call("instrument", input, asset.path.to_s)
  rescue => e
    warn "Error instrumenting #{asset.path}: #{e}"
    return input
  end
  covered_source
end