mass-client 1.0.20 → 1.0.21

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/first-line/profile_rpa.rb +61 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ee4e0f04af40b7fb0a7e26fedb26ec7fa3d76602baec49add355f620940c9b0
4
- data.tar.gz: 73fa2542b417954bedc8352420b131d81dbaeea82dacca0e43dffd96002728b4
3
+ metadata.gz: a9aa67c61c00611402f922ed7988f67bba40ccaab9db879440512fa1b2288bc4
4
+ data.tar.gz: 21f416174b865c81f5122d2242aea75b55acaae7224d5bc1bc7bef13e64b1f19
5
5
  SHA512:
6
- metadata.gz: 458fd9aa4929a889264c7e90b69b856e8272ee9ed26106243e64dca225ece4ec847a91b0d536036c10d8f0a43525adf6922f88587e35de8963f40fc11d2b35f7
7
- data.tar.gz: a20f0ce501ed952360e071a696fc39e0c060c18a5d8d89af7cea557709f0296db2700f79152e63430766e870b1ba2e66d811bc9c116635e7cccf82a340e460c6
6
+ metadata.gz: fdaca0893c886f465fbc617d4b301b5fca7552354bd4daf8d96731de5a4db7b9b0eb9a78500e1a842b21f6d3d6f64f8b12be963db44c0048d4c1f426ee0eed14
7
+ data.tar.gz: 9dc92ae9b578167df3835499c56bf44de27b94c78356f2972aacb8390f5600f5c5bcac0dbade36dc49e3105abe11653280cb9ba665dab861e7a4a4acd87501c9
@@ -175,7 +175,23 @@ module Mass
175
175
  automaticDownloads.find_element(:id => status.to_s).click()
176
176
  end # def automatic_downloads
177
177
 
178
-
178
+ # Waits for the presence of a file in specified file paths within a given timeout period.
179
+ # This function checks each file path in the provided array and returns the path of the
180
+ # first file it finds to exist. It raises an exception if none of the files are found
181
+ # within the specified timeout.
182
+ #
183
+ # @param file_paths [Array<String>] An array of file paths to check for the file's existence.
184
+ # @param timeout [Integer] The maximum number of seconds to wait for the file to appear.
185
+ # Default is 30 seconds.
186
+ #
187
+ # @return [String] The path of the first file found in `file_paths`.
188
+ # @raise [RuntimeError] If no file is found within the specified timeout, raises an error with a message
189
+ # listing the paths that were checked and the timeout duration.
190
+ #
191
+ # @example
192
+ # wait_for_file(['/path/to/file1', '/path/to/file2'], timeout: 60)
193
+ # # => "/path/to/file1" (if the file appears within 60 seconds)
194
+ #
179
195
  def wait_for_file(file_paths, timeout = 30)
180
196
  Timeout.timeout(timeout) do
181
197
  loop do
@@ -189,6 +205,45 @@ module Mass
189
205
  raise "Downloaded file not found in paths #{file_paths.join(',')} after #{timeout} seconds."
190
206
  end
191
207
 
208
+
209
+ # Retrieves the URL of a file stored in Dropbox with a timeout mechanism.
210
+ # This function continuously attempts to retrieve the file URL until it
211
+ # becomes available in Dropbox, up to a specified maximum wait time.
212
+ #
213
+ # @param path [String] The path to the file in Dropbox.
214
+ # @param max_wait [Integer] Maximum time to wait (in seconds) for the file to
215
+ # appear in Dropbox. Default is 30 seconds.
216
+ # @param interval [Integer] Time interval (in seconds) between each retry
217
+ # attempt. Default is 2 seconds.
218
+ #
219
+ # @return [String] The URL of the file in Dropbox, with the `&dl=1` parameter
220
+ # replaced by `&dl=0`.
221
+ # @raise [RuntimeError] If the file is not available within the specified
222
+ # maximum wait time, raises an error with a timeout message.
223
+ #
224
+ # @example
225
+ # wait_for_dropbox_url('/path/to/file', max_wait: 60, interval: 3)
226
+ # # => "https://www.dropbox.com/s/yourfile?dl=0"
227
+ #
228
+ def wait_for_dropbox_url(path, max_wait: 30, interval: 2)
229
+ start_time = Time.now
230
+
231
+ loop do
232
+ begin
233
+ # Try to get the file URL
234
+ return BlackStack::DropBox.get_file_url(path).gsub('&dl=1', '&dl=0')
235
+ rescue => e
236
+ # Check if the timeout has been exceeded
237
+ if Time.now - start_time > max_wait
238
+ raise "Timeout exceeded while waiting for file to appear in Dropbox: #{e.message}"
239
+ end
240
+
241
+ # Wait for a short interval before retrying
242
+ sleep(interval)
243
+ end
244
+ end
245
+ end
246
+
192
247
  # download image from Selenium using JavaScript and upload to Dropbox
193
248
  # return the URL of the screenshot
194
249
  #
@@ -274,8 +329,12 @@ module Mass
274
329
  BlackStack::DropBox.dropbox_upload_file(tmp_path, path)
275
330
  # Delete the local file
276
331
  File.delete(tmp_path)
332
+
277
333
  # Return the URL of the file in Dropbox
278
- BlackStack::DropBox.get_file_url(path).gsub('&dl=1', '&dl=0')
334
+ #
335
+ # Add a timeout to wait the file is present in the cloud.
336
+ # Reference: https://github.com/MassProspecting/docs/issues/320
337
+ self.wait_for_dropbox_url(path).gsub('&dl=1', '&dl=0')
279
338
  end
280
339
 
281
340
  # download image from Selenium using JavaScript and upload to Dropbox
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mass-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.20
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-21 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timeout