selenium_chrome_helper 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/selenium_chrome_helper/version.rb +1 -1
- data/lib/tasks/install.rake +43 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e2c6036630870a945ef7a84793c16714e759d94559d3cd3b0f1955c552d1abc
|
4
|
+
data.tar.gz: 16466d851db87a8c81bf49dae35d669abcbafb610217c01c06e73897889f7021
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 751cbf3daab36bfedb7176fabeb7672d64acf88e99a5c79672640395c633ab938b87883665cb1d7d86592411f15021155a2cc5589fbe8110f21044c37c2a905c
|
7
|
+
data.tar.gz: 0433ff00eb1ab2690c23c35a73160f8bc63db9c37e8c7d154400e54829e28c40f804f9a40a3f58d4311048fb12a6e8cce4f81d9bfe3ae093e30b2dc3f2504f10
|
data/lib/tasks/install.rake
CHANGED
@@ -22,32 +22,32 @@ namespace :chrome do
|
|
22
22
|
raise "Unsupported platform: #{RUBY_PLATFORM}"
|
23
23
|
end
|
24
24
|
|
25
|
-
puts "➡️
|
26
|
-
puts "📡 Fetching metadata for Chrome version #{version}..."
|
25
|
+
puts " ➡️ Platform: #{platform}"
|
26
|
+
puts " 📡 Fetching metadata for Chrome version #{version}..."
|
27
27
|
|
28
28
|
json = URI.open(api_url).read
|
29
29
|
data = JSON.parse(json)
|
30
30
|
|
31
31
|
version_info = data['versions'].find { |v| v['version'] == version }
|
32
32
|
|
33
|
-
abort "❌ Version #{version} not found in known-good list." unless version_info
|
33
|
+
abort " ❌ Version #{version} not found in known-good list." unless version_info
|
34
34
|
|
35
35
|
chrome_url = version_info.dig('downloads', 'chrome')&.find { |d| d['platform'] == platform }&.dig('url')
|
36
36
|
driver_url = version_info.dig('downloads', 'chromedriver')&.find { |d| d['platform'] == platform }&.dig('url')
|
37
37
|
|
38
38
|
unless chrome_url && driver_url
|
39
|
-
abort "❌ No matching downloads found for platform #{platform} and version #{version}"
|
39
|
+
abort " ❌ No matching downloads found for platform #{platform} and version #{version}"
|
40
40
|
end
|
41
41
|
|
42
|
-
puts "⬇️
|
43
|
-
puts "⬇️
|
42
|
+
puts " ⬇️ Chrome URL: #{chrome_url}"
|
43
|
+
puts " ⬇️ Chromedriver URL: #{driver_url}"
|
44
44
|
|
45
45
|
FileUtils.mkdir_p(install_base)
|
46
46
|
|
47
47
|
download_and_unzip(chrome_url, File.join(install_base, 'chrome.zip'), install_base)
|
48
48
|
download_and_unzip(driver_url, File.join(install_base, 'chromedriver.zip'), install_base)
|
49
49
|
|
50
|
-
puts "✅ Chrome and Chromedriver installed to #{install_base}"
|
50
|
+
puts " ✅ Chrome and Chromedriver installed to #{install_base}"
|
51
51
|
end
|
52
52
|
|
53
53
|
def download_and_unzip(url, zip_path, extract_to)
|
@@ -66,13 +66,44 @@ namespace :chrome do
|
|
66
66
|
def unzip(zip_path, extract_to)
|
67
67
|
Zip::File.open(zip_path) do |zip_file|
|
68
68
|
zip_file.each do |entry|
|
69
|
-
|
70
|
-
|
71
|
-
entry_path = File.join(extract_to, entry.name)
|
72
|
-
FileUtils.mkdir_p(File.dirname(entry_path))
|
73
|
-
zip_file.extract(entry, entry_path) unless File.exist?(entry_path)
|
69
|
+
process_entry(entry, extract_to)
|
74
70
|
end
|
75
71
|
end
|
76
72
|
end
|
73
|
+
|
74
|
+
def process_entry(entry, extract_to)
|
75
|
+
return if entry.symlink? # silently skip symlinks
|
76
|
+
|
77
|
+
entry_path = File.join(extract_to, entry.name)
|
78
|
+
create_entry_directory(entry_path)
|
79
|
+
extract_entry(entry, entry_path)
|
80
|
+
make_executable_if_chromedriver(entry, entry_path)
|
81
|
+
make_executable_if_chrome(entry, entry_path)
|
82
|
+
end
|
83
|
+
|
84
|
+
def create_entry_directory(entry_path)
|
85
|
+
FileUtils.mkdir_p(File.dirname(entry_path))
|
86
|
+
end
|
87
|
+
|
88
|
+
def extract_entry(entry, entry_path)
|
89
|
+
entry.extract(entry_path) unless File.exist?(entry_path)
|
90
|
+
end
|
91
|
+
|
92
|
+
def make_executable_if_chromedriver(entry, entry_path)
|
93
|
+
return unless entry.name =~ /chromedriver$/ && File.exist?(entry_path)
|
94
|
+
|
95
|
+
FileUtils.chmod('+x', entry_path)
|
96
|
+
end
|
97
|
+
|
98
|
+
def make_executable_if_chrome
|
99
|
+
return unless RUBY_PLATFORM =~ /darwin/
|
100
|
+
|
101
|
+
FileUtils.chmod('+x', entry_path) if entry.name.end_with?('MacOS/Google Chrome for Testing')
|
102
|
+
|
103
|
+
return unless entry.name.include?('Google Chrome for Testing.app')
|
104
|
+
|
105
|
+
app_bundle_root = entry_path[/.*Google Chrome for Testing\.app/]
|
106
|
+
system('xattr', '-d', 'com.apple.quarantine', app_bundle_root) if app_bundle_root && File.exist?(app_bundle_root)
|
107
|
+
end
|
77
108
|
end
|
78
109
|
# rubocop:enable Metrics/BlockLength, Security/Open
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_chrome_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Robaina
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- lib/selenium_chrome_helper/railtie.rb
|
51
51
|
- lib/selenium_chrome_helper/version.rb
|
52
52
|
- lib/tasks/install.rake
|
53
|
-
homepage: https://github.com/
|
53
|
+
homepage: https://github.com/pepito2k/selenium_chrome_helper
|
54
54
|
licenses:
|
55
55
|
- MIT
|
56
56
|
metadata: {}
|