Skip to content

Commit

Permalink
Extract helper and replace if with case
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Jul 15, 2020
1 parent 8900869 commit 0fb892f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/api/app/helpers/webui/buildresult_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ def collapse_link(expanded, main_name, repository_name = nil)
end
end
end

# Paints an rpmlog line green-ish when the line has a Warning and red when it has an error.
def colorize_line(line)
case line
when /\w+(?:\.\w+)+: W: /
tag.span(line.strip, style: 'color: olive;')
when /\w+(?:\.\w+)+: E: /
tag.span(line.strip, style: 'color: red;')
else
line.strip
end
end
end
7 changes: 1 addition & 6 deletions src/api/app/views/webui/package/_rpmlint_log.html.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
-# FIXME: move this into a helper
- @log.lines.each do |line|
- if /\w+(?:\.\w+)+: W: /.match?(line)
= tag.span(line.strip, style: 'color: olive;')
- elsif /\w+(?:\.\w+)+: E: /.match?(line)
= tag.span(line.strip, style: 'color: red;')
- else
= line.strip
= colorize_line(line)

0 comments on commit 0fb892f

Please sign in to comment.