Module: Gitloc::LineCounts

Defined in:
lib/gitloc/line_counts.rb

Class Method Summary collapse

Class Method Details

.call(names_to_bodies) ⇒ Object



3
4
5
6
7
# File 'lib/gitloc/line_counts.rb', line 3

def self.call(names_to_bodies)
  names_to_bodies
    .map    { |name, body| [name, count_lines(body)] }
    .select { |name, body| body }
end

.count_lines(body) ⇒ Object



9
10
11
12
13
# File 'lib/gitloc/line_counts.rb', line 9

def self.count_lines(body)
  body.lines.count { |line| line !~ /^\s*$/ }
rescue ArgumentError
  nil
end