Class: Inertia::Resistance
- Inherits:
-
Object
- Object
- Inertia::Resistance
- Defined in:
- lib/inertia/resistance.rb
Overview
Wrapping functions to provide some intuition on where you may encounter resistance.
Class Method Summary collapse
- .display ⇒ Object
-
.grouped_masses ⇒ Object
Git will list all files, this groups the top level direc.
- .total_lines ⇒ Object
- .tracked_files ⇒ Object
Class Method Details
.display ⇒ Object
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_masses ⇒ Object
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_lines ⇒ Object
27 28 29 |
# File 'lib/inertia/resistance.rb', line 27 def self.total_lines @total_lines ||= grouped_masses.sum(&:lines) end |
.tracked_files ⇒ Object
10 11 12 |
# File 'lib/inertia/resistance.rb', line 10 def self.tracked_files @tracked_files ||= `git ls-files -z`.split("\u0000") end |