lib/macros4cuke/templating/engine.rb in macros4cuke-0.4.03 vs lib/macros4cuke/templating/engine.rb in macros4cuke-0.4.04

- old
+ new

@@ -159,18 +159,18 @@ def variables() # The result will be cached/memoized... @variables ||= begin vars = @representation.each_with_object([]) do |element, subResult| case element - when Placeholder - subResult << element.name - - when Section - subResult.concat(element.variables) - - else - # Do nothing + when Placeholder + subResult << element.name + + when Section + subResult.concat(element.variables) + + else + # Do nothing end end vars.flatten.uniq end @@ -219,12 +219,12 @@ # var. equals count_of(<) - count_of(>): can only be 0 or temporarily 1 unbalance = 0 no_escaped.each_char do |ch| case ch - when '<' then unbalance += 1 - when '>' then unbalance -= 1 + when '<' then unbalance += 1 + when '>' then unbalance -= 1 end fail(StandardError, "Nested opening chevron '<'.") if unbalance > 1 fail(StandardError, "Missing opening chevron '<'.") if unbalance < 0 end @@ -263,22 +263,22 @@ # Apply the rule: when a line just consist of spaces # and a section element, then remove all the spaces from that line. section_item = nil line_to_squeeze = line_rep.all? do |item| case item - when StaticText - item.source =~ /\s+/ - - when Section, SectionEndMarker - if section_item.nil? - section_item = item - true + when StaticText + item.source =~ /\s+/ + + when Section, SectionEndMarker + if section_item.nil? + section_item = item + true + else + false + end else false - end - else - false end end if line_to_squeeze && !section_item.nil? line_rep = [section_item] else @@ -307,13 +307,13 @@ # Where kind must be one of :static, :dynamic def compile_couple(aCouple) (kind, text) = aCouple result = case kind - when :static then StaticText.new(text) - when :comment then Comment.new(text) - when :dynamic then parse_tag(text) + when :static then StaticText.new(text) + when :comment then Comment.new(text) + when :dynamic then parse_tag(text) end return result end @@ -348,22 +348,22 @@ def compile_sections(flat_sequence) open_sections = [] # The list of nested open sections compiled = flat_sequence.each_with_object([]) do |element, subResult| case element - when Section - open_sections << element - - when SectionEndMarker - validate_section_end(element, open_sections) - subResult << open_sections.pop - - else - if open_sections.empty? - subResult << element + when Section + open_sections << element + + when SectionEndMarker + validate_section_end(element, open_sections) + subResult << open_sections.pop + else - open_sections.last.add_child(element) - end + if open_sections.empty? + subResult << element + else + open_sections.last.add_child(element) + end end end unless open_sections.empty? error_message = "Unterminated section #{open_sections.last}."