9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/see/runner.rb', line 9
def run
config_path = "#{Dir.pwd}/see.yml"
begin
config = YAML.load_file(config_path)
rescue
puts "No configuration file found (tried #{config_path})".yellow
puts ' (if the file exists it may be malformed)'
exit 1
end
progress = Thread.new do
print "Pulling data from #{config.length} source#{config.length == 1 ? '' : 's'}"
loop do
sleep 0.25
print '.'
end
end
threads = []
config.each do |cfg|
threads << Thread.new do
begin
Thread.current[:lines] = [See::Plugins.run_plugin(cfg[0], config)]
rescue => error
Thread.current[:lines] = ["Error running plugin: #{cfg[0]}".red]
Thread.current[:lines] << " #{error}".light_red
end
end
end
lines = threads.map { |t| t.join[:lines].flatten }
progress.kill
puts
lines.sort_by { |l| l[0] }.each { |l| puts l }
puts
end
|