Class: TodoScanner::Todo

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

Class Method Summary collapse

Class Method Details

.scanObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/todo_scanner.rb', line 3

def self.scan
  files = Dir["**/*.rb"]
  config['Exclude'].each { |excluded_file| files.reject! { |f| f[excluded_file] } } if config.present?

  todos_found = []
  files.each do |file|
    line_number = File.foreach(file).with_index(1) do | line, index |
      todos_found << "#{line.strip} - #{file}:#{index}" if found_todo?(line)
    end
  end

  puts "TODOs Found : #{todos_found.count}"
  todos_found.each do |todo|
    puts todo
  end if todos_found.count > 0
end