Module: IntegrationTestsRails::Istanbul::Instrumenter
- Defined in:
- lib/integration_tests_rails/istanbul/instrumenter.rb
Overview
Instruments JavaScript files for code coverage using Istanbul.
Class Method Summary collapse
Class Method Details
.instrument_all ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/integration_tests_rails/istanbul/instrumenter.rb', line 13 def instrument_all config = IntegrationTestsRails.configuration output_path = config.output_path # Clean output directory FileUtils.rm_rf(output_path) FileUtils.mkdir_p(output_path) # Find all JS files js_files = Dir.glob(config.source_path.join('**/*.js')) Util.log "Instrumenting #{js_files.length} JavaScript files..." js_files.each do |file| instrument_file(file) end Util.log '✓ Instrumented files created' Util.log '=== Istanbul Instrumentation Complete ===' end |
.instrument_file(file) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/integration_tests_rails/istanbul/instrumenter.rb', line 33 def instrument_file(file) config = IntegrationTestsRails.configuration relative_path = Pathname.new(file).relative_path_from(config.source_path) output_file = config.output_path.join(relative_path) FileUtils.mkdir_p(output_file.dirname) code = File.read(file) instrumented = instrument_code_with_istanbul(code, file) write_instrumented_file(output_file, instrumented, relative_path) end |