pulse-downloader 0.1.5 → 0.1.10
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73e18a59a2534ac4b716222495792c2624a827aa220647579321552baa31e451
|
4
|
+
data.tar.gz: 25c64012141ae32139ff3fb6eed9ed8e388a5ce001580127dc28040135731cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1423d3cf884fca38e31d5b54133e5449f365f848f6a1d441edfa053031f8cf5a6b19f99b9b0bbdc2d8d71126fa5294051d101f38ca7d43a7440105644d2ed1f7
|
7
|
+
data.tar.gz: b86aac8791cb20f12f1e9b992e650614e4f895658c492b61288f581c1aa43148fd21a76612a73df3edd660b5e6d0c3589659c8c97243abc126ab973a1a5bcf07
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Pulse
|
2
2
|
module Downloader
|
3
3
|
class Client
|
4
|
+
require 'progress_bar'
|
4
5
|
include ::Pulse::Downloader::WebPageParser
|
5
6
|
include ::Pulse::Downloader::FileChecker
|
6
7
|
include ::Pulse::Downloader::FileDownloader
|
@@ -24,6 +25,8 @@ module Pulse
|
|
24
25
|
# TODO: Validation
|
25
26
|
# TODO: Retry
|
26
27
|
# TODO: DNS
|
28
|
+
# TODO: Multiple filetypes
|
29
|
+
# TODO: lib/pulse/downloader/file_downloader.rb:13: warning: URI.escape is obsolete
|
27
30
|
def initialize(url:,
|
28
31
|
file_type:,
|
29
32
|
save_data: false,
|
@@ -44,10 +47,7 @@ module Pulse
|
|
44
47
|
@drop_exitsing_files_in_path = drop_exitsing_files_in_path
|
45
48
|
@save_and_dont_return = save_and_dont_return
|
46
49
|
@report_time = report_time
|
47
|
-
|
48
|
-
if progress_bar
|
49
|
-
@progress_bar = ProgressBar.new
|
50
|
-
end
|
50
|
+
@progress_bar = progress_bar
|
51
51
|
end
|
52
52
|
|
53
53
|
def call!
|
@@ -58,7 +58,7 @@ module Pulse
|
|
58
58
|
return false unless valid?
|
59
59
|
|
60
60
|
if @progress_bar
|
61
|
-
@progress_bar = ProgressBar.new(fetch_file_paths.size)
|
61
|
+
@progress_bar = ::ProgressBar.new(fetch_file_paths.size)
|
62
62
|
end
|
63
63
|
|
64
64
|
fetch_file_paths.map do |file_path|
|
@@ -10,11 +10,11 @@ module Pulse
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def compute_save_path(url)
|
13
|
-
"#{save_path}/#{compute_filename(url)}".gsub('//', '/')
|
13
|
+
"#{save_path}/#{compute_filename(url)}".gsub('//', '/').gsub(' ', '')
|
14
14
|
end
|
15
15
|
|
16
16
|
def compute_filename(file_path)
|
17
|
-
file_path.scan(/[\/]\S+/).last
|
17
|
+
file_path.scan(/[\/]\S+/).last.split('/').last
|
18
18
|
end
|
19
19
|
|
20
20
|
def list_files_in(path)
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Pulse
|
2
2
|
module Downloader
|
3
3
|
module FileDownloader
|
4
|
+
require 'uri'
|
5
|
+
|
4
6
|
# save_path and verify_ssl are defined in client.rb
|
5
7
|
def download(file_path, progress_bar=nil)
|
6
8
|
raise "save_path is undefined" if save_data && save_path == ''
|
@@ -8,7 +10,7 @@ module Pulse
|
|
8
10
|
|
9
11
|
@start_time = get_micro_second_time
|
10
12
|
|
11
|
-
file_data = HTTParty.get(compute_file_link(file_path), verify: verify_ssl)
|
13
|
+
file_data = HTTParty.get(URI.escape(compute_file_link(file_path)), verify: verify_ssl)
|
12
14
|
|
13
15
|
@end_time = get_micro_second_time
|
14
16
|
|