module Preseason::Colorize
Public Instance Methods
ask(statement, *args)
click to toggle source
override method from Thor::Shell::Basic
Calls superclass method
# File lib/preseason/colorize.rb, line 6 def ask(statement, *args) statement = colorize(statement) super end
readme(path)
click to toggle source
override method from Rails::Generators::Actions
Calls superclass method
# File lib/preseason/colorize.rb, line 18 def readme(path) begin say "#{option_color}" super ensure say "#{no_color}" end end
yes?(statement, color = nil)
click to toggle source
override method from Thor::Shell::Basic
Calls superclass method
# File lib/preseason/colorize.rb, line 12 def yes?(statement, color = nil) statement = colorize(statement) super end
Private Instance Methods
aside_index(statement)
click to toggle source
# File lib/preseason/colorize.rb, line 41 def aside_index(statement) statement.rindex '(' end
ask_color()
click to toggle source
# File lib/preseason/colorize.rb, line 45 def ask_color "\033[35m" # magenta end
colorize(statement)
click to toggle source
# File lib/preseason/colorize.rb, line 28 def colorize(statement) statement.insert 0, ask_color statement.insert option_index(statement), option_color if option_index(statement) statement.insert aside_index(statement) || -1, no_color statement end
no_color()
click to toggle source
# File lib/preseason/colorize.rb, line 53 def no_color "\033[0m" # reset end
option_color()
click to toggle source
# File lib/preseason/colorize.rb, line 49 def option_color "\033[33m" # yellow end
option_index(statement)
click to toggle source
# File lib/preseason/colorize.rb, line 36 def option_index(statement) index = statement.rindex '[' index if index && index > ask_color.size end