pulse-downloader 0.1.23 → 0.1.24

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: e354feaf3ad68d91b2b58b1410ad297582ace9b6f3493b17cf8ae11d11c18d8d
4
- data.tar.gz: 3e036681abb31307b958bba6038d1fda3a9634195d71c61af3e8896bd695b22a
3
+ metadata.gz: 13ed97a9caedc58bca6c4247f2d56d7456aecafe0f2eecb65b6c25b5de404fd4
4
+ data.tar.gz: 0d450684690c49812a63a0aec81f9e9d77e6074898a6ac2be9b7143fe5989adb
5
5
  SHA512:
6
- metadata.gz: cf401b59b944a0bdca308998c19f4c8b996fadf60cc8118c06a909b5eaa1ca98d9f0f3d234af7050ce71611475d8f9a9c4a79503003649870a5d7f18dc62caa0
7
- data.tar.gz: 98bd01ea727425dad6a932fd431c241b023d954134827ac781faab9b90559a3d05c75916eb4e0bf99d4f8f4c4244b2ce7b019df8ced9c474ad8efe18fa4e7e7d
6
+ metadata.gz: '001790c43ba48c68ad1222d70f1352e5b399384fb7be69c6951ac80fd629ed2009fcc4a1292e23ab712ddaa1a9f206a59b1abd7f965625486160224e4e7a77bb'
7
+ data.tar.gz: d49f98068eec42477b7069948f4a7c72b37b4e166c6f843b4e7e81763c27eb5e5561115f7b15800e48ed2cd86f5397e6a21f7d3eaf2816a91b017795399fbb9f
@@ -1,5 +1,5 @@
1
1
  module Pulse
2
2
  module Downloader
3
- VERSION = "0.1.23"
3
+ VERSION = "0.1.24"
4
4
  end
5
5
  end
@@ -12,30 +12,36 @@ module Pulse
12
12
  print_time
13
13
  end
14
14
 
15
- extract_file_urls(response, custom_path_root)
15
+ if file_type.is_a?(Array)
16
+ file_type.flat_map do |type|
17
+ extract_file_urls(response, custom_path_root, type)
18
+ end
19
+ else
20
+ extract_file_urls(response, custom_path_root, file_type)
21
+ end
16
22
  end
17
23
 
18
24
  private
19
25
 
20
- def extract_file_urls(response, custom_path_root)
26
+ def extract_file_urls(response, custom_path_root, type)
21
27
  return [] if response.body.nil? || response.body.empty?
22
28
  (
23
- extract_download_links(response, custom_path_root) +
24
- extract_embedded_images(response, custom_path_root)
29
+ extract_download_links(response, custom_path_root, type) +
30
+ extract_embedded_images(response, custom_path_root, type)
25
31
  ).uniq
26
32
  end
27
33
 
28
- def extract_download_links(response, custom_path_root)
34
+ def extract_download_links(response, custom_path_root, type)
29
35
  parse_html(response.body)
30
36
  .css('a')
31
37
  .to_a
32
38
  .map { |link| link['href'] }
33
39
  .compact
34
- .select { |link| (link.include? file_type || link.include?(custom_path_root)) }
40
+ .select { |link| (link.include? type || link.include?(custom_path_root)) }
35
41
  .map { |link| add_base_url(link) }
36
42
  end
37
43
 
38
- def extract_embedded_images(response, custom_path_root)
44
+ def extract_embedded_images(response, custom_path_root, type)
39
45
  return [] unless scrape_images
40
46
 
41
47
  parse_html(response.body)
@@ -43,7 +49,7 @@ module Pulse
43
49
  .to_a
44
50
  .map { |e| e["src"] }
45
51
  .compact
46
- .select { |link| (link.include? file_type || link.include?(custom_path_root)) }
52
+ .select { |link| (link.include? type || link.include?(custom_path_root)) }
47
53
  .map { |link| add_base_url(link) }
48
54
  end
49
55
 
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.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22