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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4eda29d80f2588f977183d092bc35c55eebe0fcd90b3660be7303e8ce86cca8
4
- data.tar.gz: 2a8618ed657b120ef1b5bb1f4578e74d4bdd1b491a42c4e1e2082fbb8a7fd1be
3
+ metadata.gz: 7e2c6036630870a945ef7a84793c16714e759d94559d3cd3b0f1955c552d1abc
4
+ data.tar.gz: 16466d851db87a8c81bf49dae35d669abcbafb610217c01c06e73897889f7021
5
5
  SHA512:
6
- metadata.gz: e6bb5a8fbe03a45cf9b9c323ec98d8fd718dd40d9a1f1fa278eeae323db2c582ad3e14dabbc1d992b73d938e39c6adf4a599b4ce4e42cfb45d7dde4954a2301b
7
- data.tar.gz: 2928d4197cf7f96d4b57047ec30dade3055edaf631e32c6580a8feb4c3a6431405eafc58eccfc386878285117ffd987ee5c52c26fb22ab320e5677b1a54c6176
6
+ metadata.gz: 751cbf3daab36bfedb7176fabeb7672d64acf88e99a5c79672640395c633ab938b87883665cb1d7d86592411f15021155a2cc5589fbe8110f21044c37c2a905c
7
+ data.tar.gz: 0433ff00eb1ab2690c23c35a73160f8bc63db9c37e8c7d154400e54829e28c40f804f9a40a3f58d4311048fb12a6e8cce4f81d9bfe3ae093e30b2dc3f2504f10
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SeleniumChromeHelper
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.7'
5
5
  end
@@ -22,32 +22,32 @@ namespace :chrome do
22
22
  raise "Unsupported platform: #{RUBY_PLATFORM}"
23
23
  end
24
24
 
25
- puts "➡️ Platform: #{platform}"
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 "⬇️ Chrome URL: #{chrome_url}"
43
- puts "⬇️ Chromedriver URL: #{driver_url}"
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
- next if entry.symlink? # silently skip symlinks
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.5
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/yourname/selenium_chrome_helper
53
+ homepage: https://github.com/pepito2k/selenium_chrome_helper
54
54
  licenses:
55
55
  - MIT
56
56
  metadata: {}