class Inertia::Resistance

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

Public Class Methods

display() click to toggle source
# 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_masses() click to toggle source

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

# 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_lines() click to toggle source
# File lib/inertia/resistance.rb, line 27
def self.total_lines
  @total_lines ||= grouped_masses.sum(&:lines)
end
tracked_files() click to toggle source
# File lib/inertia/resistance.rb, line 10
def self.tracked_files
  @tracked_files ||= `git ls-files -z`.split("\u0000")
end