Class: GitDiffLcs::Stat

Inherits:
Object
  • Object
show all
Defined in:
lib/git_diff_lcs/stat.rb

Overview

stat

Constant Summary collapse

SRC_FOLDER =
"src_#{SecureRandom.uuid}"
DEST_FOLDER =
"dest_#{SecureRandom.uuid}"
INIT_COUNT =
[0, 0, 0].freeze

Instance Method Summary collapse

Constructor Details

#initialize(repo, src, dest) ⇒ Stat

repo(String) : git repository address src(String) : src commit or branch dest(String) : dest commit or branch



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/git_diff_lcs/stat.rb', line 18

def initialize(repo, src, dest)
  @go_next = false
  @dir = Dir.mktmpdir
  @add, @del, @mod = *INIT_COUNT
  @target_files = []

  @diff = git_clone(repo, src, dest).diff(src, dest)
  @target_files = @diff.name_status.keys
  calculate
rescue Git::GitExecuteError
  puts "[ERROR] wrong git info(repo or src or dest)"
end

Instance Method Details

#deletionsObject



41
42
43
# File 'lib/git_diff_lcs/stat.rb', line 41

def deletions
  @del
end

#insertionsObject



37
38
39
# File 'lib/git_diff_lcs/stat.rb', line 37

def insertions
  @add
end

#modificationsObject



45
46
47
# File 'lib/git_diff_lcs/stat.rb', line 45

def modifications
  @mod
end

#summaryObject



31
32
33
34
35
# File 'lib/git_diff_lcs/stat.rb', line 31

def summary
  total = @add + @del + @mod
  changed = @target_files.size
  "#{changed} files changed, #{@add} insertions(+), #{@del} deletions(-), #{@mod} modifications(!), total(#{total})"
end