Module: SimpleCov::Directive::Haml

Extended by:
Haml
Includes:
IndentedTemplate
Included in:
Haml
Defined in:
lib/simplecov/directive/haml.rb

Overview

The Ruby a Haml template holds. Script lines (-, =, and their !, &, and ~ variants) and the script a tag outputs keep their Ruby with the markers blanked, a -# comment becomes a Ruby comment, a :ruby filter's lines are Ruby as written, and everything else is blanked.

Constant Summary collapse

SCRIPT =
/\A[!&]?[-=~]/
TAG_SCRIPT =
/\A[%.#][\w:.#-]*(?:\{[^{}]*\}|\([^()]*\)|\[[^\[\]]*\])*[<>]*[!&]?[=~]/

Constants included from IndentedTemplate

IndentedTemplate::COMMENT, IndentedTemplate::RUBY, IndentedTemplate::TEXT

Instance Method Summary collapse

Methods included from IndentedTemplate

#ruby_lines

Instance Method Details

#convert(indent, rest) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/simplecov/directive/haml.rb', line 18

def convert(indent, rest)
  if rest.start_with?("-#")
    ["#{indent} ##{rest[2..]}", COMMENT]
  elsif rest.match?(/\A:ruby[ \t]*\n\z/)
    [Template.blank(indent + rest), RUBY]
  elsif rest.start_with?(":")
    [Template.blank(indent + rest), TEXT]
  elsif (marker = rest[SCRIPT] || rest[TAG_SCRIPT])
    [indent + Template.blank(marker) + rest[marker.length..]]
  else
    [Template.blank(indent + rest)]
  end
end