Module: Linecounter::Scanner

Defined in:
lib/linecounter/scanner.rb

Constant Summary collapse

EXTS =
%w[rb].freeze

Class Method Summary collapse

Class Method Details

.loc(content) ⇒ Object



9
10
11
# File 'lib/linecounter/scanner.rb', line 9

def loc(content)
  content.each_line.count { |l| !l.strip.empty? }
end

.ruby_files(repo_path) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/linecounter/scanner.rb', line 13

def ruby_files(repo_path)
  Git.run("git", "-C", repo_path, "ls-files")
    .lines
    .map(&:strip)
    .select { |f| EXTS.include?(File.extname(f).delete(".")) }
    .reject { |f| File.basename(f) == "schema.rb" }
end