Class: C80GitBash::App

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/c80_git_bash/app.rb

Constant Summary

Constants included from Utils

Utils::BLACK, Utils::BLUE, Utils::BOLD, Utils::CLEAR, Utils::CYAN, Utils::DATE_PADDING, Utils::FILENAME_PADDING, Utils::GREEN, Utils::LOG_MESSAGE_LINE_SIZE, Utils::MAGENTA, Utils::RED, Utils::WHITE, Utils::YELLOW

Instance Method Summary collapse

Methods included from Utils

#format_file_name, #format_git_date, #format_git_message, #format_git_message_join

Instance Method Details

#exe(master_pwd) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/c80_git_bash/app.rb', line 11

def exe(master_pwd)

  # соберём имена файлов, отсортируем
  filenames = []
  Dir.foreach(master_pwd) { |f| filenames << f }
  filenames.sort!

  # обойдём то, что собрали
  filenames.each do |filename|
    # пропустим ненужное
    next if filename == '.' || filename == '..'

    # соберём полный путь
    full_filename = File.join(master_pwd, filename)

    # зайдём в каждую директорию
    if File.directory?(full_filename)
      r = "======[ #{full_filename} ]".ljust(130, '=')
      puts "\n\n#{r}\n\n"
      self.get_log(full_filename)
    end

  end


end

#get_log(pwd) ⇒ Object



38
39
40
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
68
69
70
71
72
73
74
75
76
77
# File 'lib/c80_git_bash/app.rb', line 38

def get_log(pwd)

  # соберём и отсортируем имена файлов по текущему пути
  filenames = []
  Dir.foreach(pwd) {|f| filenames << f}
  filenames.sort!

  #обходим каждый файл текущего пути
  filenames.each do |filename|

    # лабаем имя директории
    d = File.join(pwd, filename)
    next if filename == '.' || filename == '..'

    # выбираем только директории
    if File.directory?(d)

      # имя директории
      f = format_file_name(filename)

      # noinspection RubyEmptyRescueBlockInspection
      begin
        g = Git.open(d)
        log_last = g.log.last

        d = format_git_date(log_last.date)
        m = format_git_message_join(log_last.message)


        puts "\t#{f}#{d} #{m}"
      rescue Git::GitExecuteError
        puts "\t#{f}[#{''.ljust(10,'-')}] #{RED}GitExecuteError#{CLEAR}"
      rescue ArgumentError
      end

    end

  end

end

#runObject



7
8
9
# File 'lib/c80_git_bash/app.rb', line 7

def run
  exe ARGV[0]
end