Module: SimpleCov::Directive::Slim

Extended by:
Slim
Includes:
IndentedTemplate
Included in:
Slim
Defined in:
lib/simplecov/directive/slim.rb

Overview

The Ruby a Slim template holds. Control and output lines (-, =, ==, and their whitespace variants) and the output a bare tag carries keep their Ruby with the markers blanked, a / comment becomes a Ruby comment, a ruby: block's lines are Ruby as written, and everything else is blanked. A tag with attributes is blanked whole, since = inside them is not the output marker.

Constant Summary collapse

CODE =
/\A(?:-|={1,2}[<>']*)(?=\s)/
TAG_CODE =
/\A[\w.#-]+\s*={1,2}[<>']*(?=\s)/

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



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/simplecov/directive/slim.rb', line 20

def convert(indent, rest)
  if rest.start_with?("/")
    ["#{indent}##{rest[1..]}", COMMENT]
  elsif rest.match?(/\Aruby:[ \t]*\n\z/)
    [Template.blank(indent + rest), RUBY]
  elsif rest.match?(/\A\w+:[ \t]*\n\z/)
    [Template.blank(indent + rest), TEXT]
  elsif (marker = rest[CODE] || rest[TAG_CODE])
    [indent + Template.blank(marker) + rest[marker.length..]]
  else
    [Template.blank(indent + rest)]
  end
end