Commit cd6fc8b8 authored by Fabio Pitino's avatar Fabio Pitino

Compact syntax for default class names

parent ad9079da
...@@ -197,9 +197,7 @@ module Gitlab ...@@ -197,9 +197,7 @@ module Gitlab
css_classes = [] css_classes = []
if @sections.any? if @sections.any?
css_classes << "section" css_classes = %w[section line] + sections.map { |section| "s_#{section}" }
css_classes += sections.map { |section| "s_#{section}" }
css_classes << "line"
end end
write_in_tag %{<br/>} write_in_tag %{<br/>}
...@@ -217,13 +215,13 @@ module Gitlab ...@@ -217,13 +215,13 @@ module Gitlab
normalized_section = section_to_class_name(section) normalized_section = section_to_class_name(section)
if action == "start" if action == "start"
handle_section_start(normalized_section, timestamp, line) handle_section_start(normalized_section, timestamp)
elsif action == "end" elsif action == "end"
handle_section_end(normalized_section, timestamp) handle_section_end(normalized_section, timestamp)
end end
end end
def handle_section_start(section, timestamp, line) def handle_section_start(section, timestamp)
return if @sections.include?(section) return if @sections.include?(section)
@sections << section @sections << section
......
...@@ -233,7 +233,7 @@ describe Gitlab::Ci::Ansi2html do ...@@ -233,7 +233,7 @@ describe Gitlab::Ci::Ansi2html do
text = "#{section_start}\e[91mHello\e[0m\n#{section_end}" text = "#{section_start}\e[91mHello\e[0m\n#{section_end}"
header = %{<span class="term-fg-l-red section js-section-header js-s-#{class_name(section_name)}">Hello</span>} header = %{<span class="term-fg-l-red section js-section-header js-s-#{class_name(section_name)}">Hello</span>}
line_break = %{<span class="section js-section-header js-s-#{class_name(section_name)}"><br/></span>} line_break = %{<span class="section js-section-header js-s-#{class_name(section_name)}"><br/></span>}
line = %{<span class="section s_#{class_name(section_name)} line"></span>} line = %{<span class="section line s_#{class_name(section_name)}"></span>}
empty_line = %{<span class="section js-s-#{class_name(section_name)}"></span>} empty_line = %{<span class="section js-s-#{class_name(section_name)}"></span>}
html = "#{section_start_html}#{header}#{line_break}#{line}#{empty_line}#{section_end_html}" html = "#{section_start_html}#{header}#{line_break}#{line}#{empty_line}#{section_end_html}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment