Class: HolePicker::Scanner

Inherits:
Object
  • Object
show all
Includes:
HasLogger
Defined in:
lib/holepicker/scanner.rb

Instance Method Summary collapse

Methods included from HasLogger

included, #logger

Constructor Details

#initialize(paths, options = {}) ⇒ Scanner

Returns a new instance of Scanner.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/holepicker/scanner.rb', line 16

def initialize(paths, options = {})
  @paths = paths.is_a?(Array) ? paths : [paths]
  @stdin = options[:stdin]

  @database = options[:offline] ? OfflineDatabase.load : OnlineDatabase.load

  @finder = if options[:follow_roots]
    ConfigGemfileFinder.new
  else
    DirectGemfileFinder.new(
      :skip_ignored => !options[:dont_skip],
      :only_current => options[:current]
    )
  end

  @parser = GemfileParser.new(options[:ignored_gems])
end

Instance Method Details

#scanObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/holepicker/scanner.rb', line 34

def scan
  @reporter = ScanReporter.new

  if @stdin
    scan_gemfile(STDIN.read, nil)
  else
    logger.info "Looking for gemfiles..."

    @paths.each { |p| scan_path(p) }
  end

  @reporter.print_report

  @reporter.success?
end