Class: GitHealthCheck::WorkingCopy

Inherits:
Object
  • Object
show all
Defined in:
lib/git-health-check/working_copy.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ WorkingCopy

Returns a new instance of WorkingCopy.



5
6
7
8
# File 'lib/git-health-check/working_copy.rb', line 5

def initialize(options)
  @limit = options[:limit]
  @git_lib = GitHealthCheck::GitLib.new
end

Instance Method Details

#find_in_working_copyObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/git-health-check/working_copy.rb', line 10

def find_in_working_copy
  largest_files = @git_lib.get_largest_files @limit
  largest_files = largest_files.split "\n"

  files = []

  largest_files.each do |file|
    split = file.split
    size = split[4]
    path = split[8]
    sha = @git_lib.get_object_sha_from_path path
    size = (size.to_f * 9.53674e-7).round 2 # bytes to MB
    files << [sha, size, path] # no hash in case of blob-reuse in various paths
  end

  files
end