pulse-downloader 0.1.34 → 0.1.35

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: ee4cd8b3e10c09d8a52ddf222d3d423ffb188a0b7eb4993febbcc97b74644764
4
- data.tar.gz: 2126a1a1cecc91c2b0aa275ca17322deac30779682acbd6c08d4dad9f48d412e
3
+ metadata.gz: df940062ab2c0dcdc96b256b76e8198683776d7bdb834198c0f75da85d5e63fb
4
+ data.tar.gz: 158f5746ceb0d820934e126cae7ca53dfca0a841ae8a588b2b955c85de5abc7f
5
5
  SHA512:
6
- metadata.gz: 0b38229caa3120433d2434acc5ca8122c86fef5957db323895ea781473ef1cf40a9ab202f581c48de5ab27f438bfd0d046248867e5ea924ff9d473828d84763f
7
- data.tar.gz: fd5908c8b30f58f07fa6496db39b88ba24a9f1dde4a6d87df5e65ba133b00241e6e836aeb4d66badbe832b6c4eb8621f98c1cbca03d3e94cfc2c7cbc18bef2d6
6
+ metadata.gz: 2494b72940a92e4b13fc44c8c9c81ff63e48a35940e9bcc6437235afdd4c1ca2fdc43098b71f976ce42d5fa65b53979aa3b055b511c91c1ca6b0ff64a0dd472c
7
+ data.tar.gz: 1c40920e57fdbb4184034cc91953f82c5babf1c09146027b9b887b1bac5d8b45f4e386b21133bd44625f8adb8843daac8b4652e35e94ebf25188738d02d8a36c
@@ -22,7 +22,8 @@ module Pulse
22
22
  :end_time,
23
23
  :progress_bar,
24
24
  :base_url,
25
- :file_paths
25
+ :file_paths,
26
+ :folder_urls
26
27
 
27
28
  # Does not continue downloads-
28
29
  # Will only save once the file has been downloaded in memory
@@ -60,6 +61,7 @@ module Pulse
60
61
  @progress_bar = progress_bar
61
62
 
62
63
  @base_url = get_base_url
64
+ @folder_urls = []
63
65
  end
64
66
 
65
67
  def call!
@@ -1,5 +1,5 @@
1
1
  module Pulse
2
2
  module Downloader
3
- VERSION = "0.1.34"
3
+ VERSION = "0.1.35"
4
4
  end
5
5
  end
@@ -14,10 +14,23 @@ module Pulse
14
14
  private
15
15
 
16
16
  def fetch_folders(base_url)
17
+ current_paths = extract_hrefs(get_response(folder_url), custom_path_root)
18
+ return unless current_paths.compact.size > 0
17
19
 
20
+ @folder_urls = folder_urls.union(current_paths).uniq.compact
21
+
22
+ current_paths.each do |path|
23
+ fetch_folders(path)
24
+ end
25
+
26
+ folder_urls
18
27
  end
19
28
 
20
29
  def fetch_and_parse_response(folder_url, custom_path_root)
30
+ parse_response(get_response(folder_url), custom_path_root, file_type)
31
+ end
32
+
33
+ def get_response(folder_url)
21
34
  @start_time = get_micro_second_time
22
35
 
23
36
  response = HTTParty.get(folder_url, verify: verify_ssl, headers: headers)
@@ -28,7 +41,7 @@ module Pulse
28
41
  print_time
29
42
  end
30
43
 
31
- parse_response(response, custom_path_root, file_type)
44
+ response
32
45
  end
33
46
 
34
47
  def parse_response(response, custom_path_root, file_type)
@@ -51,6 +64,14 @@ module Pulse
51
64
  ).uniq
52
65
  end
53
66
 
67
+ def extract_hrefs(response, custom_path_root)
68
+ parse_html(response.body)
69
+ .css('a')
70
+ .map { |link| link['href'] }
71
+ .reject { |link| link == "../" }
72
+ .map { |link| add_base_url(link, custom_path_root) }
73
+ end
74
+
54
75
  def extract_all_urls(response, custom_path_root, type)
55
76
  parse_html(response.body)
56
77
  .to_s
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.34
4
+ version: 0.1.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22