Module: Popart
- Defined in:
- lib/popart.rb,
lib/popart/config.rb,
lib/popart/worker.rb,
lib/popart/browser.rb,
lib/popart/version.rb,
lib/popart/selenium_session.rb
Defined Under Namespace
Classes: Browser, Config, SeleniumSession, Worker
Constant Summary
collapse
- VERSION =
"0.2.0"
Class Method Summary
collapse
Class Method Details
.configuration ⇒ Object
9
10
11
|
# File 'lib/popart.rb', line 9
def configuration
@config ||= self.configure
end
|
13
14
15
16
17
18
|
# File 'lib/popart.rb', line 13
def configure
@config = Popart::Config.new
@config.initial_config
@browsers = @config.browsers.map { |b| Popart::Browser.new b }
end
|
.save_screenshots(directory, &actions) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/popart.rb', line 20
def save_screenshots directory, &actions
@browsers.each do |browser|
screenshot = browser.perform &actions
File.open((File.join directory, browser.filename), 'w') do |file|
file.write screenshot
end
end
end
|
.thread_things(directory, &actions) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/popart.rb', line 30
def thread_things directory, &actions
threadcount = @config.thread_count
lock = Mutex.new
threads = []
threadcount.times do |t|
puts "Thread #{t}"
threads << Thread.new do
w = Popart::Worker.new @browsers, lock
w.perform do |browser|
screenshot = browser.perform &actions
File.open((File.join directory, browser.filename), 'w') do |file|
file.write screenshot
end
end
end
end
threads.map(&:join)
end
|