Class: SimpleCov::Formatter::TailwindFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov-tailwindcss.rb,
lib/simplecov-tailwindcss/version.rb

Overview

rubocop:disable Metrics/ClassLength

Constant Summary collapse

VERSION =
"2.2.0"

Instance Method Summary collapse

Constructor Details

#initializeTailwindFormatter

Returns a new instance of TailwindFormatter.



18
19
20
# File 'lib/simplecov-tailwindcss.rb', line 18

def initialize
  @branchable_result = SimpleCov.branch_coverage?
end

Instance Method Details

#branchable_result?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/simplecov-tailwindcss.rb', line 39

def branchable_result?
  @branchable_result
end

#format(result) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/simplecov-tailwindcss.rb', line 22

def format(result)
  Dir[File.join(File.dirname(__FILE__), "../public/*")].each do |path|
    FileUtils.cp_r(path, asset_output_path)
  end

  File.open(File.join(output_path, "index.html"), "wb") do |file|
    file.puts template("main").result(binding)
  end
  puts output_message(result)
end

#line_status?(source_file, line) ⇒ Boolean

Returns:

  • (Boolean)


43
44
45
46
47
48
49
50
# File 'lib/simplecov-tailwindcss.rb', line 43

def line_status?(source_file, line)
  if branchable_result? &&
     source_file.line_with_missed_branch?(line.number)
    "missed-branch"
  else
    line.status
  end
end

#output_message(result) ⇒ Object



33
34
35
36
37
# File 'lib/simplecov-tailwindcss.rb', line 33

def output_message(result)
  "Coverage report generated for #{result.command_name} to " \
    "#{output_path}. #{result.covered_lines} / #{result.total_lines} LOC " \
    "(#{result.covered_percent.round(2)}%) covered."
end