Class: Ghostbuster
- Inherits:
-
Object
show all
- Includes:
- Shell
- Defined in:
- lib/ghostbuster.rb,
lib/ghostbuster/rake.rb,
lib/ghostbuster/shell.rb,
lib/ghostbuster/config.rb,
lib/ghostbuster/runner.rb,
lib/ghostbuster/version.rb
Defined Under Namespace
Modules: Rake, Shell
Classes: Config, Runner
Constant Summary
collapse
- VERSION =
'0.3.11'
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Shell
#sh, #sh_with_code
Constructor Details
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/ghostbuster.rb', line 15
def initialize(path)
STDOUT.sync = true
@path = path && File.exist?(path) ? path : '.'
if File.directory?(@path)
@dir = @path
@file = 'Ghostfile'
else
@dir = File.dirname(@path)
@file = File.basename(@path)
end
@ghost_lib = File.expand_path(File.join(File.dirname(__FILE__), "ghostbuster.coffee"))
end
|
Class Method Details
.run(path) ⇒ Object
69
70
71
|
# File 'lib/ghostbuster.rb', line 69
def self.run(path)
new(path).run
end
|
Instance Method Details
#run ⇒ Object
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/ghostbuster.rb', line 28
def run
status = 1
Dir.chdir(@dir) do
load_config
spinner "Starting server" do
if @config.verbose
puts `#{@config.start_command}`
raise unless $!.success?
else
sh @config.start_command
end
sleep @config.start_wait
end
begin
_, status = Process.waitpid2 fork {
exec("#{@config.phantom_bin} #{@ghost_lib} #{@config.screenshots?} #{@config.screenshot_x} #{@config.screenshot_y} #{@temporary_screenshot_dir} #{Dir[@config.pattern].to_a.join(' ')}")
}
if @config.screenshots?
spinner "Copying screenshots" do
compress_and_copy_screenshots
end
end
ensure
spinner "Stopping server" do
if @config.verbose
puts `#{@config.stop_command}`
raise unless $!.success?
else
sh @config.stop_command
end
end
if @config.screenshots?
spinner "Cleaning up temporary screenshots" do
cleanup_screenshots
end
end
end
end
status.to_i
end
|