Class: Webdrivers::Common
- Inherits:
-
Object
- Object
- Webdrivers::Common
show all
- Defined in:
- lib/webdrivers/common.rb
Class Method Summary
collapse
Class Method Details
.download(version = nil) ⇒ Object
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/webdrivers/common.rb', line 40
def download(version = nil)
url = download_url(version)
filename = File.basename url
Dir.mkdir(install_dir) unless File.exists?(install_dir)
Dir.chdir install_dir do
FileUtils.rm_f filename
open(filename, "wb") do |file|
file.print get(url)
end
raise "Could not download #{url}" unless File.exists? filename
Webdrivers.logger.debug "Successfully downloaded #{filename}"
dcf = decompress_file(filename)
Webdrivers.logger.debug "Decompression Complete"
if dcf
Webdrivers.logger.debug "Deleting #{filename}"
FileUtils.rm_f filename
end
if respond_to? :extract_file
Webdrivers.logger.debug "Extracting #{dcf}"
(dcf)
end
end
raise "Could not decompress #{filename} to get #{binary}" unless File.exists?(binary)
FileUtils.chmod "ugo+rx", binary
Webdrivers.logger.debug "Completed download and processing of #{binary}"
binary
end
|
.latest ⇒ Object
31
32
33
|
# File 'lib/webdrivers/common.rb', line 31
def latest
downloads.keys.sort.last
end
|
.remove ⇒ Object
35
36
37
38
|
# File 'lib/webdrivers/common.rb', line 35
def remove
Webdrivers.logger.debug "Deleting #{binary}"
FileUtils.rm_f binary
end
|
.update ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/webdrivers/common.rb', line 8
def update
unless site_available?
return current.nil? ? nil : binary
end
released = latest()
location = binary()
return location if released.nil? && File.exists?(binary)
if released.nil? msg = "Unable to find the latest version of #{file_name}; try downloading manually from #{base_url} and place in #{install_dir}"
raise StandardError, msg
end
if correct_binary?
Webdrivers.logger.debug "Expected webdriver version found"
return location
end
remove download end
|