pulse-downloader 0.1.5 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 528b545a62356f1b1d9c1786f975b059f0387c3fecd58d6fe211b62405922d56
4
- data.tar.gz: a173671066bb527aaf9abdd8e68be48ab0e849a22d70cce4b4abaf0271ba425a
3
+ metadata.gz: 73e18a59a2534ac4b716222495792c2624a827aa220647579321552baa31e451
4
+ data.tar.gz: 25c64012141ae32139ff3fb6eed9ed8e388a5ce001580127dc28040135731cae
5
5
  SHA512:
6
- metadata.gz: 8028861136a23be938d906811375d24dd4da26ad25c33b97ed8872316610daf34ca8e83a285a16e5b76445bab5fe8164592848442a51d7c3dd00696e9092f688
7
- data.tar.gz: 50b64203c44b39b458fd8ea5dc7610ba6d1e22418a74762d6ebae78c06a14a31ea5c3e7606eec21cf1a60bf6c82f1d1be6549b3eb8a7f3945777f35d93b27714
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
 
@@ -1,5 +1,5 @@
1
1
  module Pulse
2
2
  module Downloader
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.10"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulse-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22