pulse-downloader 0.1.3 → 0.1.8

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: 143241844753713ded3ebdb7fccf727a20ab2055ad9c40e9936b88f9ecd4a0a5
4
- data.tar.gz: 471f4432385de2dc96223ed014e5d3c88adccfda7c98a591b1cd2c915dbe3256
3
+ metadata.gz: 436723a4794bf433393fee28354ab8651f4d53117659fc78b135e0908aa0cace
4
+ data.tar.gz: b0e43da3b2388d7b61490f667597ac9cdc75ef54f6aea9f132132ff9e54b8af1
5
5
  SHA512:
6
- metadata.gz: f26e86e5e59e24be532fc542e2de26c33d69dd2e4bb264ef6fe1f28f46d68782d5d0838a80db769912fc202598dff4e40aad10a856e4659e01105c73997b7ed3
7
- data.tar.gz: a29a979395ce6b6d7311e7150e22f1ed11a62cd317e19aa42a16241674e7abe33397e8d210882aeb4fa6f7835e3a32e321ccdadf13ecc20219c7a9065a38f9f5
6
+ metadata.gz: 7ce6dd19019b842cda6d133c85ffcb8cb707593c329bccd68b3e67c0494ea74ff0ae01459f10cda843876dc55e5de5091849f1de7dd0997edaa127f339e7d107
7
+ data.tar.gz: 70a51cb0da1d1614f04f89a6bfef195f8cbd5b8a582fcab39a3d4bddd0053b256ae1006417aff91560298578a195d3501b44e5ffd319d47ce307337baad17d99
@@ -0,0 +1,18 @@
1
+ on:
2
+ pull_request: {}
3
+ push:
4
+ branches:
5
+ - main
6
+ - master
7
+ name: Semgrep
8
+ jobs:
9
+ semgrep:
10
+ name: Scan
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: returntocorp/semgrep-action@v1
15
+ with:
16
+ auditOn: push
17
+ publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
18
+ publishDeployment: 607
data/.gitignore CHANGED
File without changes
data/CODE_OF_CONDUCT.md CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
@@ -1,79 +1,79 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pulse-downloader (0.1.3)
4
+ pulse-downloader (0.1.4)
5
5
  active_attr (~> 0.15)
6
6
  httparty (~> 0.18)
7
- nokogiri (~> 1.10.9)
7
+ nokogiri (~> 1.11)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- actionpack (6.0.3.2)
13
- actionview (= 6.0.3.2)
14
- activesupport (= 6.0.3.2)
15
- rack (~> 2.0, >= 2.0.8)
12
+ actionpack (6.1.3.1)
13
+ actionview (= 6.1.3.1)
14
+ activesupport (= 6.1.3.1)
15
+ rack (~> 2.0, >= 2.0.9)
16
16
  rack-test (>= 0.6.3)
17
17
  rails-dom-testing (~> 2.0)
18
18
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
19
- actionview (6.0.3.2)
20
- activesupport (= 6.0.3.2)
19
+ actionview (6.1.3.1)
20
+ activesupport (= 6.1.3.1)
21
21
  builder (~> 3.1)
22
22
  erubi (~> 1.4)
23
23
  rails-dom-testing (~> 2.0)
24
24
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
25
- active_attr (0.15.0)
26
- actionpack (>= 3.0.2, < 6.1)
27
- activemodel (>= 3.0.2, < 6.1)
28
- activesupport (>= 3.0.2, < 6.1)
29
- activemodel (6.0.3.2)
30
- activesupport (= 6.0.3.2)
31
- activesupport (6.0.3.2)
25
+ active_attr (0.15.3)
26
+ actionpack (>= 3.0.2, < 7.0)
27
+ activemodel (>= 3.0.2, < 7.0)
28
+ activesupport (>= 3.0.2, < 7.0)
29
+ activemodel (6.1.3.1)
30
+ activesupport (= 6.1.3.1)
31
+ activesupport (6.1.3.1)
32
32
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
- i18n (>= 0.7, < 2)
34
- minitest (~> 5.1)
35
- tzinfo (~> 1.1)
36
- zeitwerk (~> 2.2, >= 2.2.2)
33
+ i18n (>= 1.6, < 2)
34
+ minitest (>= 5.1)
35
+ tzinfo (~> 2.0)
36
+ zeitwerk (~> 2.3)
37
37
  addressable (2.7.0)
38
38
  public_suffix (>= 2.0.2, < 5.0)
39
39
  ansi (1.5.0)
40
40
  builder (3.2.4)
41
41
  coderay (1.1.3)
42
- concurrent-ruby (1.1.6)
43
- crack (0.4.3)
44
- safe_yaml (~> 1.0.0)
42
+ concurrent-ruby (1.1.8)
43
+ crack (0.4.5)
44
+ rexml
45
45
  crass (1.0.6)
46
- erubi (1.9.0)
46
+ erubi (1.10.0)
47
47
  hashdiff (1.0.1)
48
48
  httparty (0.18.1)
49
49
  mime-types (~> 3.0)
50
50
  multi_xml (>= 0.5.2)
51
- i18n (1.8.3)
51
+ i18n (1.8.10)
52
52
  concurrent-ruby (~> 1.0)
53
- loofah (2.6.0)
53
+ loofah (2.9.1)
54
54
  crass (~> 1.0.2)
55
55
  nokogiri (>= 1.5.9)
56
56
  method_source (1.0.0)
57
57
  mime-types (3.3.1)
58
58
  mime-types-data (~> 3.2015)
59
- mime-types-data (3.2020.0512)
60
- mini_portile2 (2.4.0)
61
- minitest (5.14.1)
59
+ mime-types-data (3.2021.0225)
60
+ minitest (5.14.4)
62
61
  minitest-focus (1.1.2)
63
62
  minitest (>= 4, < 6)
64
- minitest-reporters (1.4.2)
63
+ minitest-reporters (1.4.3)
65
64
  ansi
66
65
  builder
67
66
  minitest (>= 5.0)
68
67
  ruby-progressbar
69
68
  mocha (1.11.2)
70
69
  multi_xml (0.6.0)
71
- nokogiri (1.10.10)
72
- mini_portile2 (~> 2.4.0)
73
- pry (0.13.1)
70
+ nokogiri (1.11.3-x86_64-linux)
71
+ racc (~> 1.4)
72
+ pry (0.14.1)
74
73
  coderay (~> 1.1)
75
74
  method_source (~> 1.0)
76
- public_suffix (4.0.5)
75
+ public_suffix (4.0.6)
76
+ racc (1.5.2)
77
77
  rack (2.2.3)
78
78
  rack-test (1.1.0)
79
79
  rack (>= 1.0, < 3)
@@ -83,23 +83,22 @@ GEM
83
83
  rails-html-sanitizer (1.3.0)
84
84
  loofah (~> 2.3)
85
85
  rake (12.3.3)
86
- ruby-progressbar (1.10.1)
87
- safe_yaml (1.0.5)
88
- thread_safe (0.3.6)
89
- timecop (0.9.1)
90
- tzinfo (1.2.7)
91
- thread_safe (~> 0.1)
86
+ rexml (3.2.5)
87
+ ruby-progressbar (1.11.0)
88
+ timecop (0.9.4)
89
+ tzinfo (2.0.4)
90
+ concurrent-ruby (~> 1.0)
92
91
  webmock (3.8.3)
93
92
  addressable (>= 2.3.6)
94
93
  crack (>= 0.3.2)
95
94
  hashdiff (>= 0.4.0, < 2.0.0)
96
- zeitwerk (2.4.0)
95
+ zeitwerk (2.4.2)
97
96
 
98
97
  PLATFORMS
99
- ruby
98
+ x86_64-linux
100
99
 
101
100
  DEPENDENCIES
102
- bundler (~> 2.1.4)
101
+ bundler (~> 2.2.16)
103
102
  minitest (~> 5.0)
104
103
  minitest-focus (~> 1.1.2)
105
104
  minitest-reporters (~> 1.4.2)
@@ -111,4 +110,4 @@ DEPENDENCIES
111
110
  webmock (~> 3.8.3)
112
111
 
113
112
  BUNDLED WITH
114
- 2.1.4
113
+ 2.2.16
data/LICENSE CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
@@ -31,9 +31,12 @@ client = Pulse::Downloader::Client.new(
31
31
  read_from_save_path: false,
32
32
  verify_ssl: true,
33
33
  drop_exitsing_files_in_path: false,
34
- save_and_dont_return: true
35
- report_time: false
34
+ save_and_dont_return: true,
35
+ report_time: false,
36
+ progress_bar: true
36
37
  )
38
+
39
+ client.call!
37
40
  ```
38
41
 
39
42
  ## Development
data/Rakefile CHANGED
File without changes
File without changes
@@ -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
@@ -12,17 +13,19 @@ module Pulse
12
13
  :read_from_save_path,
13
14
  :verify_ssl,
14
15
  :drop_exitsing_files_in_path,
16
+ :save_and_dont_return,
15
17
  :report_time,
16
18
  :start_time,
17
- :end_time
19
+ :end_time,
20
+ :progress_bar
18
21
 
19
22
  # Does not continue downloads-
20
23
  # Will only save once the file has been downloaded in memory
21
24
 
22
- # TODO: Add in progress bar
23
25
  # TODO: Validation
24
26
  # TODO: Retry
25
27
  # TODO: DNS
28
+ # TODO: Multiple filetypes
26
29
  def initialize(url:,
27
30
  file_type:,
28
31
  save_data: false,
@@ -31,7 +34,8 @@ module Pulse
31
34
  verify_ssl: true,
32
35
  drop_exitsing_files_in_path: false,
33
36
  save_and_dont_return: true,
34
- report_time: false)
37
+ report_time: false,
38
+ progress_bar: false)
35
39
 
36
40
  @url = url
37
41
  @file_type = file_type
@@ -40,7 +44,9 @@ module Pulse
40
44
  @read_from_save_path = read_from_save_path
41
45
  @verify_ssl = verify_ssl
42
46
  @drop_exitsing_files_in_path = drop_exitsing_files_in_path
47
+ @save_and_dont_return = save_and_dont_return
43
48
  @report_time = report_time
49
+ @progress_bar = progress_bar
44
50
  end
45
51
 
46
52
  def call!
@@ -50,8 +56,13 @@ module Pulse
50
56
  def call
51
57
  return false unless valid?
52
58
 
59
+ if @progress_bar
60
+ @progress_bar = ::ProgressBar.new(fetch_file_paths.size)
61
+ end
62
+
53
63
  fetch_file_paths.map do |file_path|
54
- download(file_path)
64
+ download(file_path, @progress_bar)
65
+ @progress_bar.increment!
55
66
  end
56
67
  end
57
68
 
@@ -65,8 +76,14 @@ module Pulse
65
76
  (Time.now.to_f * 1000).to_i
66
77
  end
67
78
 
68
- def print_time
69
- puts "Request time: #{end_time - start_time} ms."
79
+ def print_time(progress_bar=nil)
80
+ output = "Request time: #{end_time - start_time} ms."
81
+
82
+ if progress_bar
83
+ progress_bar.puts output
84
+ else
85
+ puts output
86
+ end
70
87
  end
71
88
  end
72
89
  end
File without changes
@@ -1,19 +1,21 @@
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
- def download(file_path)
7
+ def download(file_path, progress_bar=nil)
6
8
  raise "save_path is undefined" if save_data && save_path == ''
7
9
  return if file_path_in_file_list?(file_path) # skip downloading the file
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
 
15
17
  if report_time
16
- print_time
18
+ print_time(progress_bar)
17
19
  end
18
20
 
19
21
  if save_data
@@ -1,5 +1,5 @@
1
1
  module Pulse
2
2
  module Downloader
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
File without changes
@@ -22,10 +22,11 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency "httparty", "~> 0.18"
24
24
  spec.add_dependency "active_attr", "~> 0.15"
25
- spec.add_dependency "nokogiri", "~> 1.10.9"
25
+ spec.add_dependency "nokogiri", "~> 1.11"
26
+ spec.add_dependency "progress_bar", "~> 1.3.3"
26
27
 
27
28
  # Development dependancies
28
- spec.add_development_dependency "bundler", "~> 2.1.4"
29
+ spec.add_development_dependency "bundler", "~> 2.2.16"
29
30
  spec.add_development_dependency "rake", "~> 13.0"
30
31
  spec.add_development_dependency "minitest", "~> 5.0"
31
32
  spec.add_development_dependency "minitest-focus", "~> 1.1.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pulse-downloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-18 00:00:00.000000000 Z
11
+ date: 2021-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -44,28 +44,42 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.10.9
47
+ version: '1.11'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.10.9
54
+ version: '1.11'
55
+ - !ruby/object:Gem::Dependency
56
+ name: progress_bar
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.3
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 2.1.4
75
+ version: 2.2.16
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 2.1.4
82
+ version: 2.2.16
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -185,6 +199,7 @@ executables: []
185
199
  extensions: []
186
200
  extra_rdoc_files: []
187
201
  files:
202
+ - ".github/workflows/semgrep.yml"
188
203
  - ".gitignore"
189
204
  - CODE_OF_CONDUCT.md
190
205
  - Gemfile
@@ -206,7 +221,7 @@ homepage: https://github.com/TRex22/pulse-downloader
206
221
  licenses:
207
222
  - MIT
208
223
  metadata: {}
209
- post_install_message:
224
+ post_install_message:
210
225
  rdoc_options: []
211
226
  require_paths:
212
227
  - lib
@@ -221,8 +236,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
236
  - !ruby/object:Gem::Version
222
237
  version: '0'
223
238
  requirements: []
224
- rubygems_version: 3.1.4
225
- signing_key:
239
+ rubygems_version: 3.2.3
240
+ signing_key:
226
241
  specification_version: 4
227
242
  summary: Client to download datasets from webpages.
228
243
  test_files: []