Class: SystemCloc

Inherits:
Object
  • Object
show all
Defined in:
lib/pluginscan/reports/cloc_report/system_cloc.rb

Overview

A thin wrapper around the ‘cloc` system call The CLOC project is at cloc.sourceforge.net/ and can be installed on OSX using homebrew:

brew install cloc

DANGER: not covered by tests

Instance Method Summary collapse

Constructor Details

#initialize(command_name = 'cloc') ⇒ SystemCloc

Returns a new instance of SystemCloc.



7
8
9
# File 'lib/pluginscan/reports/cloc_report/system_cloc.rb', line 7

def initialize(command_name = 'cloc')
  @command_name = command_name
end

Instance Method Details

#call(directory) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/pluginscan/reports/cloc_report/system_cloc.rb', line 16

def call(directory)
  # DANGER!!! calling system command
  # Should be safe from injection because of the `Dir.exist?` check.
  Open3.capture2("#{@command_name} --csv --quiet #{directory} 2> #{error_log_name}")
ensure
  delete_empty_error_log
end

#whichObject



11
12
13
14
# File 'lib/pluginscan/reports/cloc_report/system_cloc.rb', line 11

def which
  # DANGER!!! calling system command
  Open3.capture2("which #{@command_name}")
end