Class: Sloc::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/sloc/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Runner

Returns a new instance of Runner.



5
6
7
8
# File 'lib/sloc/runner.rb', line 5

def initialize(options = {})
  @options = options
  @analyzer = Analyzer.new(@options)
end

Instance Method Details

#raw_report(paths) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sloc/runner.rb', line 19

def raw_report(paths)
  target_files = find_target_files(paths)

  # TODO: count sloc
  report = target_files.each_with_object({}) do |path, h|
    code      = File.read(path)
    extension = File.extname(path)

    h[path] = @analyzer.analyze(code, extension)
  end

  process_options(report)
end

#report(paths) ⇒ Object



14
15
16
17
# File 'lib/sloc/runner.rb', line 14

def report(paths)
  require 'pp'
  PP.pp(raw_report(paths), '')
end

#run(paths) ⇒ Object



10
11
12
# File 'lib/sloc/runner.rb', line 10

def run(paths)
  report(paths)
end