selenium_download_helper 1.1.0 → 1.2.1
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/Gemfile.lock +3 -7
- data/lib/selenium_download_helper/errors.rb +12 -0
- data/lib/selenium_download_helper/version.rb +1 -1
- data/lib/selenium_download_helper.rb +8 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def57c20317984adb28e0c8172d28df8bb4e476725670ad5419da5220db6d8a0
|
4
|
+
data.tar.gz: 3c540b24dcbb3f3ad6deb2076dcd7bcce80369a86f94b5607a31079f601482e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 165cdbdc81f4669786265d56cd9772d3ea1a53be066f14f1ecf902437f45fd880d42682651ee6fc3aa2e6cffa711dab2e6f761e68ab42190b53d96ca9657ceb8
|
7
|
+
data.tar.gz: 45290576fb05da2cdb4cfa14aa5c738253302fc2ec60362194de1445359a0db8aa5f3e638e82f8d49f25310b23046eebad4a642c8f08f20fc7322de64584ea95
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
selenium_download_helper (1.1
|
4
|
+
selenium_download_helper (1.2.1)
|
5
5
|
rails (>= 7.0)
|
6
6
|
selenium-webdriver
|
7
7
|
|
@@ -119,12 +119,8 @@ GEM
|
|
119
119
|
net-smtp (0.5.0)
|
120
120
|
net-protocol
|
121
121
|
nio4r (2.7.3)
|
122
|
-
nokogiri (1.
|
123
|
-
mini_portile2 (~> 2.8.
|
124
|
-
racc (~> 1.4)
|
125
|
-
nokogiri (1.16.7-arm64-darwin)
|
126
|
-
racc (~> 1.4)
|
127
|
-
nokogiri (1.16.7-x86_64-darwin)
|
122
|
+
nokogiri (1.14.3)
|
123
|
+
mini_portile2 (~> 2.8.0)
|
128
124
|
racc (~> 1.4)
|
129
125
|
psych (5.1.2)
|
130
126
|
stringio
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module SeleniumDownloadHelper
|
2
|
+
class TimeoutError < StandardError
|
3
|
+
def initialize(error, download_path)
|
4
|
+
@download_path = download_path
|
5
|
+
super("#{error.message}\nDownloaded files:\n#{downloaded_files.join("\n")}")
|
6
|
+
end
|
7
|
+
|
8
|
+
def downloaded_files
|
9
|
+
Dir[File.join(@download_path, '*')]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -5,10 +5,14 @@ require 'fileutils'
|
|
5
5
|
require 'selenium-webdriver'
|
6
6
|
require 'active_support/concern'
|
7
7
|
require_relative 'selenium_download_helper/version'
|
8
|
+
require_relative 'selenium_download_helper/errors'
|
8
9
|
|
9
10
|
module SeleniumDownloadHelper
|
10
11
|
extend ActiveSupport::Concern
|
11
12
|
|
13
|
+
TEMPORARY_DOWNLOAD_FILENAME_PATTERN = /(\.crdownload|^downloads.html)$/
|
14
|
+
|
15
|
+
|
12
16
|
included do
|
13
17
|
after(:all) do
|
14
18
|
FileUtils.rm_rf(base_download_dir)
|
@@ -21,6 +25,8 @@ module SeleniumDownloadHelper
|
|
21
25
|
yield
|
22
26
|
Selenium::WebDriver::Wait.new(timeout: timeout, interval: interval).until { downloaded?(download_path, filename:) }
|
23
27
|
downloaded_files(download_path, filename:).then { |files| all ? files : files.first }
|
28
|
+
rescue Selenium::WebDriver::Error::TimeoutError => e
|
29
|
+
raise TimeoutError.new(e, download_path)
|
24
30
|
end
|
25
31
|
|
26
32
|
private
|
@@ -37,11 +43,11 @@ module SeleniumDownloadHelper
|
|
37
43
|
def downloaded_files(download_path, filename: nil)
|
38
44
|
Dir[File.join(download_path, '*')]
|
39
45
|
.map { |filepath| Pathname.new(filepath) }
|
46
|
+
.reject { |file| TEMPORARY_DOWNLOAD_FILENAME_PATTERN.match?(file.basename.to_s) }
|
40
47
|
.select { |file| filename.nil? || filename === file.basename.to_s }
|
41
48
|
end
|
42
49
|
|
43
50
|
def downloaded?(download_path, filename: nil)
|
44
|
-
|
45
|
-
files.map(&:to_s).grep(/\.crdownload$/).none? && files.any?
|
51
|
+
downloaded_files(download_path, filename:).any?
|
46
52
|
end
|
47
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_download_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- bin/console
|
59
59
|
- bin/setup
|
60
60
|
- lib/selenium_download_helper.rb
|
61
|
+
- lib/selenium_download_helper/errors.rb
|
61
62
|
- lib/selenium_download_helper/version.rb
|
62
63
|
- selenium_download_helper.gemspec
|
63
64
|
homepage: https://github.com/SonicGarden/selenium_download_helper
|