Class: SLOCCount

Inherits:
Object
  • Object
show all
Defined in:
lib/pluginscan/reports/sloccount_report/sloccount.rb

Overview

Responsible for accessing specific data in the output of the ‘sloccount` command

Instance Method Summary collapse

Constructor Details

#initialize(sloccount_output) ⇒ SLOCCount

Returns a new instance of SLOCCount.



3
4
5
# File 'lib/pluginscan/reports/sloccount_report/sloccount.rb', line 3

def initialize(sloccount_output)
  @sloccount_output = sloccount_output
end

Instance Method Details

#totalObject



7
8
9
10
11
# File 'lib/pluginscan/reports/sloccount_report/sloccount.rb', line 7

def total
  total_regex = /^Total Physical Source Lines of Code.*= ([\d\,]+)/
  # Numbers in sloccount are displayed with commas e.g. 1,791
  @sloccount_output.match(total_regex)[1].delete(',').to_i
end