Class: Js::Preflight::Scanner

Inherits:
Object
  • Object
show all
Defined in:
lib/js-preflight/scanner.rb

Class Method Summary collapse

Class Method Details

.scan(file, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/js-preflight/scanner.rb', line 5

def scan(file, options = {})
  exclude_paths = options[:exclude_paths] || []
  file = File.open(file, "r") unless file.kind_of?(File)
  while line = file.gets do
    line.scan(::Js::Preflight::JsRegexp).each do |js_file|
      yield js_file[0] unless exclude_paths.any? { |p| js_file[0].match(p) }
    end
  end
end