Module: PlatformosCheck::PlatformosLiquid::Tag

Extended by:
Tag
Included in:
Tag
Defined in:
lib/platformos_check/platformos_liquid/tag.rb

Constant Summary collapse

LABELS_NOT_IN_SOURCE_INDEX =
%w[elsif ifchanged catch ensure when]

Instance Method Summary collapse

Instance Method Details

#end_labelsObject



18
19
20
21
22
# File 'lib/platformos_check/platformos_liquid/tag.rb', line 18

def end_labels
  @end_labels ||= tags_file_contents
                  .select { |x| x.is_a?(Hash) }
                  .map { |x| x.values[0] }
end

#labelsObject



12
13
14
15
16
# File 'lib/platformos_check/platformos_liquid/tag.rb', line 12

def labels
  @labels ||= tags_file_contents
              .map { |x| to_label(x) }
              .to_set
end

#liquid_tag_regex(tag) ⇒ Object



31
32
33
34
35
36
# File 'lib/platformos_check/platformos_liquid/tag.rb', line 31

def liquid_tag_regex(tag)
  return unless labels.include?(tag)

  @tag_liquid_regexes ||= {}
  @tag_liquid_regexes[tag] ||= /^\s*#{tag}/m
end

#tag_regex(tag) ⇒ Object



24
25
26
27
28
29
# File 'lib/platformos_check/platformos_liquid/tag.rb', line 24

def tag_regex(tag)
  return unless labels.include?(tag)

  @tag_regexes ||= {}
  @tag_regexes[tag] ||= /\A#{Liquid::TagStart}-?\s*#{tag}/m
end