Module: Treebis::Stylize

Includes:
Colorize
Included in:
FileUtilsProxy, Task::RunContext
Defined in:
lib/treebis.rb,
lib/treebis.rb

Constant Summary collapse

ReasonStyles =
{ :identical => :skip, :"won't overwrite" => :skip,
:changed   => :did,  :wrote => :did, :exists=>:skip,
:patched   => :changed2, :notice => :changed2,
:exec   => :changed2}
StyleCodes =
{   :skip => [:bold, :red], :did  => [:bold, :green] ,
:changed2 => [:bold, :yellow] }

Constants included from Colorize

Colorize::Codes

Instance Method Summary collapse

Methods included from Colorize

colorize

Instance Method Details

#get_style(foo) ⇒ Object

Returns nil if not found. feel free to override.

Returns:

  • nil if not found. feel free to override.



534
535
536
# File 'lib/treebis.rb', line 534

def get_style foo
  StyleCodes[ReasonStyles[foo]]
end

#notice(head, tail) ⇒ Object

write to ui.puts() whatever you want with the notice style. if color?, colorize head and separate it with a space and print tail without color. if not color?, the above but in “b&w”



543
544
545
546
547
548
549
550
# File 'lib/treebis.rb', line 543

def notice head, tail
  if color?            #  && /\A(\s*\S+)(.*)\Z/ =~ msg
    msg = colorize(head, * get_style(:notice))+' '+tail
  else
    msg = "#{head} #{tail}"
  end
  ui.puts "#{prefix}#{msg}"
end