class DeepCover::Reporter::Istanbul
Public Class Methods
available?()
click to toggle source
# File lib/deep_cover/reporter/istanbul.rb, line 178 def available? `#{bin_path} --version` >= '11.' rescue false end
bin_path()
click to toggle source
# File lib/deep_cover/reporter/istanbul.rb, line 182 def bin_path ::File.executable?('node_modules/.bin/nyc') ? 'node_modules/.bin/nyc' : 'nyc' end
report(coverage, **options)
click to toggle source
# File lib/deep_cover/reporter/istanbul.rb, line 174 def report(coverage, **options) new(coverage, **options).report end
Public Instance Methods
convert()
click to toggle source
# File lib/deep_cover/reporter/istanbul.rb, line 144 def convert each.to_a.to_h.transform_values do |covered_code| CoveredCodeConverter.new(covered_code, **@options).convert end end
report()
click to toggle source
# File lib/deep_cover/reporter/istanbul.rb, line 158 def report output = @options[:output] dir = save.dirname unless [nil, false, '', 'false'].include? output output = File.expand_path(output) html = "--reporter=html --report-dir='#{output}'" if @options[:open] html += " && open '#{output}/index.html'" else msg = "\nHTML coverage written to: '#{output}/index.html'" end end `cd #{dir} && #{Istanbul.bin_path} report --exclude-after-remap=false --reporter=text #{html}` + msg.to_s end
save(dir: '.', name: '.nyc_output')
click to toggle source
# File lib/deep_cover/reporter/istanbul.rb, line 150 def save(dir: '.', name: '.nyc_output') path = Pathname.new(dir).expand_path.join(name) path.mkpath path.each_child(&:delete) path.join('deep_cover.json').write(JSON.pretty_generate(convert)) path end