Class: Chromedriver::Installer
- Inherits:
-
Object
- Object
- Chromedriver::Installer
show all
- Defined in:
- lib/chromedriver/installer.rb,
lib/chromedriver/installer/version.rb,
lib/chromedriver/installer/google_code_parser.rb
Defined Under Namespace
Classes: GoogleCodeParser
Constant Summary
collapse
- VERSION =
"0.0.6"
Instance Method Summary
collapse
Instance Method Details
#binary_path ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/chromedriver/installer.rb', line 35
def binary_path
if platform == "win"
File.join platform_install_dir, "chromedriver.exe"
else
File.join platform_install_dir, "chromedriver"
end
end
|
#download(hit_network = false) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/chromedriver/installer.rb', line 14
def download hit_network=false
return if File.exists?(binary_path) && ! hit_network
url = download_url
filename = File.basename url
Dir.chdir platform_install_dir do
system "rm #{filename}"
system("wget -c -O #{filename} #{url}") || system("curl -C - -o #{filename} #{url}")
raise "Could not download #{url}" unless File.exists? filename
system "unzip -o #{filename}"
end
raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
end
|
#download_url ⇒ Object
31
32
33
|
# File 'lib/chromedriver/installer.rb', line 31
def download_url
GoogleCodeParser.new(platform).newest_download
end
|
#install_dir ⇒ Object
49
50
51
52
53
|
# File 'lib/chromedriver/installer.rb', line 49
def install_dir
dir = File.expand_path File.join(ENV['HOME'], ".chromedriver-installer")
FileUtils.mkdir_p dir
dir
end
|
55
56
57
58
59
60
61
62
63
|
# File 'lib/chromedriver/installer.rb', line 55
def platform
cfg = RbConfig::CONFIG
case cfg['host_os']
when /linux/ then
cfg['host_cpu'] =~ /x86_64|amd64/ ? "linux64" : "linux32"
when /darwin/ then "mac"
else "win"
end
end
|
43
44
45
46
47
|
# File 'lib/chromedriver/installer.rb', line 43
def platform_install_dir
dir = File.join install_dir, platform
FileUtils.mkdir_p dir
dir
end
|
#run(*args) ⇒ Object
9
10
11
12
|
# File 'lib/chromedriver/installer.rb', line 9
def run *args
download
exec binary_path, *args
end
|
#update ⇒ Object
27
28
29
|
# File 'lib/chromedriver/installer.rb', line 27
def update
download true
end
|