Top Level Namespace

Defined Under Namespace

Modules: ClothesNetwork, Fox, Mixin Classes: All, Array, Choice, Configuration, Create, Default, DefaultModel, Hash, History, IO, Info, Init, Model, New, Pomodoro, ProjectBuilder, SecureConfig, Version

Instance Method Summary collapse

Instance Method Details

#clean(target) ⇒ Object

Parameters:

  • target (String)

    Target folder to clean



38
39
40
41
42
43
44
45
46
47
# File 'lib/fox/interface/rake/library.rb', line 38

def clean target

  files = Dir.glob( File.join( target, "*" ) )

  files.each do |file|
    print "(--) "
    sh "rm -vrf #{file.to_s}" if( File.exists?( "#{file.to_s}" ) )
  end

end

#colorize(color, message) ⇒ String

FIXME: Implement bold behavior FIXME: This method is currently b0rked

Parameters:

  • color (String)

    The colorname in plain english. e.g. “LightGray”, “Gray”, “Red”, “BrightRed”

  • message (String)

    The message which should be wrapped

Returns:

  • (String)

    Colorized message string



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/fox/interface/rake/library.rb', line 61

def colorize color, message

  # Black       0;30     Dark Gray     1;30
  # Blue        0;34     Light Blue    1;34
  # Green       0;32     Light Green   1;32
  # Cyan        0;36     Light Cyan    1;36
  # Red         0;31     Light Red     1;31
  # Purple      0;35     Light Purple  1;35
  # Brown       0;33     Yellow        1;33
  # Light Gray  0;37     White         1;37

  colors  = { 
    "Gray"        => "\e[1;30m",
    "LightGray"   => "\e[0;37m",
    "Cyan"        => "\e[0;36m",
    "LightCyan"   => "\e[1;36m",
    "Blue"        => "\e[0;34m",
    "LightBlue"   => "\e[1;34m",
    "Green"       => "\e[0;32m",
    "LightGreen"  => "\e[1;32m",
    "Red"         => "\e[0;31m",
    "LightRed"    => "\e[1;31m",
    "LightRedBlink"    => "\e[5;31m",
    "Purple"      => "\e[0;35m",
    "LightPurple" => "\e[1;35m",
    "Brown"       => "\e[0;33m",
    "Yellow"      => "\e[1;33m",
    "White"       => "\e[1;37m"
  }
  nocolor    = "\e[0m"

  colors[ color ] + message + nocolor
end

#egrep(pattern) ⇒ Object

Parameters:

  • pattern (Regexp)

    Regular Expression pattern class



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fox/interface/rake/library.rb', line 18

def egrep( pattern )

  Dir[ "**/*.{rb,thor,rake}" ].each do |fn|
    count = 0
    open(fn) do |f|

      while line = f.gets
        count += 1
        STDOUT.puts "#{fn}:#{count}:#{line}" if line =~ pattern
      end

    end # end of open
  end # end of Dir.each

end

#message(level, msg) ⇒ Object

Helpers: colorize

Parameters:

  • level (Symbol)

    Can either be :info, :success, :error or :question

  • msg (String)

    Represents the message you want to send to stdout (info, ok, question) stderr (error)

Raises:

  • (ArugmentError)


103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/fox/interface/rake/library.rb', line 103

def message level, msg

  symbols = {
    :info      => [ "(--)", "Brown"       ],
    :success   => [ "(II)", "LightGreen"  ],
    :error     => [ "(EE)", "LightRed"    ],
    :question  => [ "(??)", "LightCyan"   ],
    :debug     => [ "(++)", "LightBlue"   ],
    :warning   => [ "(WW)", "Yellow"      ]
  }

  raise ArugmentError, "Can't find the corresponding symbol for this message level (#{level.to_s}) - is the spelling wrong?" unless( symbols.key?( level )  )

  if( level == :error )
    STDERR.puts colorize( symbols[ level.to_sym ].last, "#{symbols[ level.to_sym ].first.to_s} #{msg.to_s}" )
  else
    STDOUT.puts colorize( symbols[ level.to_sym ].last, "#{symbols[ level.to_sym ].first.to_s} #{msg.to_s}" )
  end

end