Module: Grit

Defined in:
lib/enhancing_grit.rb

Instance Method Summary collapse

Instance Method Details

#shagit_foldernameObject

return foldername including extension



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

def shagit_foldername
  foldername = Pathname.new(self.path).basename.to_s
end

#shagit_nameObject

return foldername from path without extension



12
13
14
15
16
17
# File 'lib/enhancing_grit.rb', line 12

def shagit_name
  foldername = Pathname.new(self.shagit_foldername).basename.to_s

  # extract repository name without .git extension
  repo_name = foldername.match(/^[\w\s]+/).to_s
end

#shagit_sizeObject

return size of folder containing the repository in Kilobytes



20
21
22
23
24
25
26
27
28
# File 'lib/enhancing_grit.rb', line 20

def shagit_size
  dirsize = 0
  # recursively search the repositories path and sum up all file sizes
  Find.find(self.path) do |file|
    dirsize += File.stat(file).size
  end

  dirsize
end