Module: C80GitBash::Utils

Included in:
App
Defined in:
lib/c80_git_bash/utils.rb

Constant Summary collapse

CLEAR =
"\e[0m"
BOLD =
"\e[1m"
BLACK =
"\e[30m"
RED =
"\e[31m"
GREEN =
"\e[32m"
YELLOW =
"\e[33m"
BLUE =
"\e[34m"
MAGENTA =
"\e[35m"
CYAN =
"\e[36m"
WHITE =
"\e[37m"
LOG_MESSAGE_LINE_SIZE =
60
FILENAME_PADDING =
25
DATE_PADDING =
13

Instance Method Summary collapse

Instance Method Details

#format_file_name(filename) ⇒ Object



19
20
21
# File 'lib/c80_git_bash/utils.rb', line 19

def format_file_name(filename)
  "#{GREEN}#{filename.ljust(FILENAME_PADDING, '.')}#{CLEAR}"
end

#format_git_date(d) ⇒ Object



40
41
42
# File 'lib/c80_git_bash/utils.rb', line 40

def format_git_date(d)
  "#{BLUE}[#{d.to_s.split(' ')[0]}]#{CLEAR}"
end

#format_git_message(s) ⇒ Object

see utils_spec.rb: #format_git_message



24
25
26
27
28
29
30
31
32
33
# File 'lib/c80_git_bash/utils.rb', line 24

def format_git_message(s)

  n = LOG_MESSAGE_LINE_SIZE
  m = []

  s = s.ljust(s.size + (n - s.size % n), ' ')
  s.scan(/.{#{n}}/).each do |line|
    m << line
  end
end

#format_git_message_join(s) ⇒ Object



35
36
37
38
# File 'lib/c80_git_bash/utils.rb', line 35

def format_git_message_join(s)
  m = self.format_git_message(s)
  m.join("#{BLACK}\n\t#{''.ljust(FILENAME_PADDING + DATE_PADDING - 1, '.')}#{CLEAR} ")
end