Class: Punchlist::Punchlist

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

Overview

Counts the number of ‘todo’ comments in your code.

Instance Method Summary collapse

Constructor Details

#initialize(args, outputter: STDOUT, option_parser_class: OptionParser, source_file_globber: SourceFinder::SourceFileGlobber.new) ⇒ Punchlist

Returns a new instance of Punchlist.



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

def initialize(args,
               outputter: STDOUT,
               option_parser_class: OptionParser,
               source_file_globber: SourceFinder::SourceFileGlobber.new)
  option_parser = option_parser_class.new(args)
  @config = option_parser.generate_config(source_file_globber)
  @outputter = outputter
end

Instance Method Details

#analyze_filesObject



27
28
29
30
31
32
33
# File 'lib/punchlist.rb', line 27

def analyze_files
  all_output = []
  @config.source_files.each do |filename|
    all_output.concat(look_for_punchlist_items(filename))
  end
  @outputter.print render(all_output)
end

#look_for_punchlist_items(filename) ⇒ Object



35
36
37
# File 'lib/punchlist.rb', line 35

def look_for_punchlist_items(filename)
  Inspector.new(@config.regexp, filename).run
end

#render(output) ⇒ Object



39
40
41
# File 'lib/punchlist.rb', line 39

def render(output)
  CliRenderer.new.render(output)
end

#runObject



21
22
23
24
25
# File 'lib/punchlist.rb', line 21

def run
  analyze_files

  0
end