Module: See::Runner

Defined in:
lib/see/runner.rb

Defined Under Namespace

Classes: ProgressIndicator

Class Method Summary collapse

Class Method Details

.runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/see/runner.rb', line 3

def self.run
  #
  # Whole thing happens in two major steps:
  #   1. load ./see.yml
  #     (fail if it doesn't exist)
  #
  #   2. provide information from each configured plugin
  #     (provide content at the top and no content at the bottom)
  #
  config = See::Config.load
  progress = ProgressIndicator.start(config.length)
  threads = config.map do |cfg|
    Thread.new do
      begin
        Thread.current[:lines] = See::Plugins.run_plugin(cfg[0], config)
      rescue => error
        Thread.current[:lines] = "\nError running plugin: #{cfg[0]}".red
        Thread.current[:lines] << "\n  #{error}".light_red
      end
    end
  end

  lines = threads.map { |t| t.join[:lines] }.sort_by { |l| l[0] }
  progress.stop

  puts
  lines.each { |t| puts t }
  puts
end