Skip to content
Browse files

colorize helper

  • Loading branch information...
1 parent c1fb308 commit ed8ba4010a2c0715d05aef14c0d9d72a8edf0b0f @tpope tpope committed Dec 9, 2008
Showing with 10 additions and 6 deletions.
  1. +10 −6 lib/pickler/runner.rb
View
16 lib/pickler/runner.rb
@@ -118,16 +118,20 @@ def color?
end
end
+ def colorize(code, string)
+ if color?
+ "\e[#{code}m#{string}\e[00m"
+ else
+ string
+ end
+ end
+
def puts_summary(story)
summary = "%6d " % story.id
type = story.estimate || TYPE_SYMBOLS[story.story_type]
state = STATE_SYMBOLS[story.current_state]
- if color?
- summary << "\e[3#{STATE_COLORS[story.current_state]}m#{state}\e[00m "
- summary << "\e[01;3#{TYPE_COLORS[story.story_type]}m#{type}\e[00m "
- else
- summary << "#{state} #{type} "
- end
+ summary << colorize("3#{STATE_COLORS[story.current_state]}", state) << ' '
+ summary << colorize("01;3#{TYPE_COLORS[story.story_type]}", type) << ' '
summary << story.name
puts summary
end

0 comments on commit ed8ba40

Please sign in to comment.
Something went wrong with that request. Please try again.