Module: Gity::Common

Instance Method Summary collapse

Instance Method Details

#_clsObject



32
33
34
# File 'lib/gity/common.rb', line 32

def _cls
  print "\e[2J\e[f"
end

#_fmt(msg, *opts) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gity/common.rb', line 20

def _fmt(msg, *opts)
  res = msg

  if not_empty?(opts)
    opts.each do |f|
      res = _pastel.send(f, res)
    end
  end

  " #{res}"
end

#_logger(tag = nil, &block) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gity/common.rb', line 41

def _logger(tag = nil, &block)
  if @_logger.nil?
    if ENV['GITY_LOG_TO_STDOUT'] == "true"
      @_logger = TeLogger::Tlogger.new
    else
      @_logger = TeLogger::Tlogger.new("gity.log",5, 5*1024*1024)
    end
  end

  if block
    if not_empty?(tag)
      @_logger.with_tag(tag, &block)
    else
      @_logger.with_tag(@_logger.tag, &block)
    end
  else
    if is_empty?(tag)
      @_logger.tag = :gity
      @_logger
    else
      # no block but tag is given? hmm
      @_logger.tag = tag
      @_logger
    end
  end

end

#_pastelObject



6
7
8
9
10
11
# File 'lib/gity/common.rb', line 6

def _pastel
  if @_pastel.nil?
    @_pastel = Pastel.new
  end
  @_pastel
end

#_prmtObject



13
14
15
16
17
18
# File 'lib/gity/common.rb', line 13

def _prmt
  if @_prmt.nil?
    @_prmt = TTY::Prompt.new
  end
  @_prmt
end


36
37
38
# File 'lib/gity/common.rb', line 36

def print_header
  _prmt.puts _fmt "gity version #{Gity::VERSION}"
end