selenium_chrome_helper 0.1.8 → 0.1.9
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/railtie.rb +1 -1
- data/lib/selenium_chrome_helper/version.rb +1 -1
- data/lib/tasks/cleanup.rake +26 -0
- data/lib/tasks/install.rake +2 -42
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6cdf11fb32d7ca7556db57a369e70cc5c18e0a64bf7c175fe0846586364cde4
|
4
|
+
data.tar.gz: 725b8c1f6b089860ba819a923b36f4d1dfc7fc15f5e7dcf87fb1635a330a09e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a2c8fc0d8b0b28d1704db24bb8dcb89952a510f7b750169b37e6aa81d627d4b0aca397fab945ff6c94af00de0cb66ce4a53d18436d16f57658028bfb0bbc296
|
7
|
+
data.tar.gz: e0fa809b484155607985318c1202b2cb870553d1f8c855dce4ab194721e05ab76ecc1c3973b396b9fb5e0645fdeefb7ccc6d7595753acf9bafd856de6b7a2099
|
@@ -11,7 +11,7 @@ module SeleniumChromeHelper
|
|
11
11
|
# It registers two drivers: one for headless testing and one for non-headless testing.
|
12
12
|
class Railtie < Rails::Railtie
|
13
13
|
rake_tasks do
|
14
|
-
|
14
|
+
Dir[File.expand_path('../tasks/*.rake', __dir__)].each { |task| load task }
|
15
15
|
end
|
16
16
|
|
17
17
|
initializer 'selenium_chrome_helper.configure_capybara' do
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
namespace :chrome do
|
6
|
+
desc 'Remove the .chrome-for-testing directory and all its contents'
|
7
|
+
task :cleanup do
|
8
|
+
chrome_dir = File.expand_path('.chrome-for-testing', Dir.pwd)
|
9
|
+
|
10
|
+
unless Dir.exist?(chrome_dir)
|
11
|
+
puts " ❌ Directory #{chrome_dir} does not exist."
|
12
|
+
next
|
13
|
+
end
|
14
|
+
|
15
|
+
puts " ⚠️ This will permanently delete the directory: #{chrome_dir}"
|
16
|
+
print ' Are you sure? (yes/no): '
|
17
|
+
confirmation = $stdin.gets.strip.downcase
|
18
|
+
|
19
|
+
if confirmation == 'yes'
|
20
|
+
FileUtils.rm_rf(chrome_dir)
|
21
|
+
puts " ✅ Directory #{chrome_dir} has been removed."
|
22
|
+
else
|
23
|
+
puts ' ❌ Operation canceled.'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/tasks/install.rake
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'open-uri'
|
5
5
|
require 'json'
|
6
|
-
require 'zip'
|
7
6
|
|
8
7
|
# rubocop:disable Metrics/BlockLength, Security/Open
|
9
8
|
namespace :chrome do
|
@@ -22,7 +21,7 @@ namespace :chrome do
|
|
22
21
|
raise "Unsupported platform: #{RUBY_PLATFORM}"
|
23
22
|
end
|
24
23
|
|
25
|
-
puts "
|
24
|
+
puts " 💻 Platform: #{platform}"
|
26
25
|
puts " 📡 Fetching metadata for Chrome version #{version}..."
|
27
26
|
|
28
27
|
json = URI.open(api_url).read
|
@@ -64,46 +63,7 @@ namespace :chrome do
|
|
64
63
|
end
|
65
64
|
|
66
65
|
def unzip(zip_path, extract_to)
|
67
|
-
|
68
|
-
zip_file.each do |entry|
|
69
|
-
process_entry(entry, extract_to)
|
70
|
-
end
|
71
|
-
end
|
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(entry, entry_path)
|
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)
|
66
|
+
system("unzip -q '#{zip_path}' -d '#{extract_to}'") || abort(" ❌ Failed to unzip #{zip_path}")
|
107
67
|
end
|
108
68
|
end
|
109
69
|
# 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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gonzalo Robaina
|
@@ -49,6 +49,7 @@ files:
|
|
49
49
|
- lib/selenium_chrome_helper.rb
|
50
50
|
- lib/selenium_chrome_helper/railtie.rb
|
51
51
|
- lib/selenium_chrome_helper/version.rb
|
52
|
+
- lib/tasks/cleanup.rake
|
52
53
|
- lib/tasks/install.rake
|
53
54
|
homepage: https://github.com/pepito2k/selenium_chrome_helper
|
54
55
|
licenses:
|