Module: Gity::Common
- Included in:
- Landing, Operation, Operation::Add, Operation::Commit, Operation::CommitAll, Operation::Delete, Operation::Diff, Operation::Ignore, Operation::RemoveStaged, Overview
- Defined in:
- lib/gity/common.rb
Instance Method Summary collapse
- #_cls ⇒ Object
- #_flash ⇒ Object
- #_fmt(msg, *opts) ⇒ Object
- #_logger(tag = nil, &block) ⇒ Object
- #_operation_done(no_exit = false) ⇒ Object
- #_pastel ⇒ Object
- #_prmt ⇒ Object
- #print_header ⇒ Object
Instance Method Details
#_cls ⇒ Object
55 56 57 |
# File 'lib/gity/common.rb', line 55 def _cls print "\e[2J\e[f" end |
#_flash ⇒ Object
42 43 44 |
# File 'lib/gity/common.rb', line 42 def _flash Flash.instance end |
#_fmt(msg, *opts) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gity/common.rb', line 21 def _fmt(msg, *opts) res = msg if not_empty?(opts) opts.each do |f| res = _pastel.send(f, res) end elsif msg.is_a?(GitCli::Delta::VCSItem) case msg when GitCli::Delta::ModifiedFile, GitCli::Delta::ModifiedDir res = _pastel.bright_yellow(res) when GitCli::Delta::DeletedFile, GitCli::Delta::DeletedDir res = _pastel.strikethrough(res) when GitCli::Delta::StagedFile, GitCli::Delta::StagedDir res = _pastel.on_yellow(res) end end " #{res}" end |
#_logger(tag = nil, &block) ⇒ Object
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 |
# File 'lib/gity/common.rb', line 64 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 |
#_operation_done(no_exit = false) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/gity/common.rb', line 46 def _operation_done(no_exit = false) no_exit = false if no_exit.nil? if no_exit raise OperationCompleted else exit(0) end end |
#_pastel ⇒ Object
7 8 9 10 11 12 |
# File 'lib/gity/common.rb', line 7 def _pastel if @_pastel.nil? @_pastel = Pastel.new end @_pastel end |
#_prmt ⇒ Object
14 15 16 17 18 19 |
# File 'lib/gity/common.rb', line 14 def _prmt if @_prmt.nil? @_prmt = TTY::Prompt.new end @_prmt end |