Class: Inertia::Resistance

Inherits:
Object
  • Object
show all
Defined in:
lib/inertia/resistance.rb

Overview

Wrapping functions to provide some intuition on where you may encounter resistance.

Class Method Summary collapse

Class Method Details

.displayObject



5
6
7
8
# File 'lib/inertia/resistance.rb', line 5

def self.display
  puts "#{total_lines} lines\tInertia v#{Inertia::VERSION}\n\n"
  puts grouped_masses.sort.reverse
end

.grouped_massesObject

Git will list all files, this groups the top level direc



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/inertia/resistance.rb', line 15

def self.grouped_masses
  @grouped_masses ||= tracked_files.reduce({}) do |memo, file|
    # Grab only the top level directory, or filename.
    root =  /[^\/]*\/?/.match(file).to_s
    memo[root] ||= []
    memo[root].push Inertia::Mass.new(path: file)
    memo
  end.map do |path, masses|
    Inertia::GroupedMass.new(path, masses)
  end
end

.total_linesObject



27
28
29
# File 'lib/inertia/resistance.rb', line 27

def self.total_lines
  @total_lines ||= grouped_masses.sum(&:lines)
end

.tracked_filesObject



10
11
12
# File 'lib/inertia/resistance.rb', line 10

def self.tracked_files
  @tracked_files ||= `git ls-files -z`.split("\u0000")
end