pulse-downloader 0.1.4 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/semgrep.yml +18 -0
- data/.gitignore +0 -0
- data/CODE_OF_CONDUCT.md +0 -0
- data/Gemfile +0 -0
- data/Gemfile.lock +41 -42
- data/LICENSE +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +5 -2
- data/Rakefile +0 -0
- data/lib/pulse/downloader.rb +0 -0
- data/lib/pulse/downloader/client.rb +22 -6
- data/lib/pulse/downloader/file_checker.rb +1 -1
- data/lib/pulse/downloader/file_downloader.rb +5 -3
- data/lib/pulse/downloader/version.rb +1 -1
- data/lib/pulse/downloader/web_page_parser.rb +0 -0
- data/pulse-downloader.gemspec +3 -2
- metadata +25 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6062b23861d00bffe9abfa30adefc1acd6e4e585bd6d8d5b088abb413602a7f
|
4
|
+
data.tar.gz: 97dade0776f86e397c334fb82dbe242edfd9fb0431bb322c46decede8a0437f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e3846244c78ba9d90ab37a19c5fde92618ebf3db1f52b68e7b50a2bbcfd9233b45fd154e26fd788361588c7737e7bcc04200920e8132d9aadefe9d3799864e6
|
7
|
+
data.tar.gz: 181ab8446777a7be665d20aac80b284b5c197d710cca5a11b58066a049b143dfaf974931d7ef60c98ec6742a935333232f80b9756a7d6ad3318aaa0ead2c531e
|
@@ -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
@@ -4,76 +4,76 @@ PATH
|
|
4
4
|
pulse-downloader (0.1.4)
|
5
5
|
active_attr (~> 0.15)
|
6
6
|
httparty (~> 0.18)
|
7
|
-
nokogiri (~> 1.
|
7
|
+
nokogiri (~> 1.11)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (6.
|
13
|
-
actionview (= 6.
|
14
|
-
activesupport (= 6.
|
15
|
-
rack (~> 2.0, >= 2.0.
|
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.
|
20
|
-
activesupport (= 6.
|
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.
|
26
|
-
actionpack (>= 3.0.2, <
|
27
|
-
activemodel (>= 3.0.2, <
|
28
|
-
activesupport (>= 3.0.2, <
|
29
|
-
activemodel (6.
|
30
|
-
activesupport (= 6.
|
31
|
-
activesupport (6.
|
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 (>=
|
34
|
-
minitest (
|
35
|
-
tzinfo (~>
|
36
|
-
zeitwerk (~> 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.
|
43
|
-
crack (0.4.
|
44
|
-
|
42
|
+
concurrent-ruby (1.1.8)
|
43
|
+
crack (0.4.5)
|
44
|
+
rexml
|
45
45
|
crass (1.0.6)
|
46
|
-
erubi (1.
|
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.
|
51
|
+
i18n (1.8.10)
|
52
52
|
concurrent-ruby (~> 1.0)
|
53
|
-
loofah (2.
|
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.
|
60
|
-
|
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.
|
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.
|
72
|
-
|
73
|
-
pry (0.
|
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.
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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.
|
95
|
+
zeitwerk (2.4.2)
|
97
96
|
|
98
97
|
PLATFORMS
|
99
|
-
|
98
|
+
x86_64-linux
|
100
99
|
|
101
100
|
DEPENDENCIES
|
102
|
-
bundler (~> 2.
|
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.
|
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
|
data/lib/pulse/downloader.rb
CHANGED
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
|
@@ -15,15 +16,17 @@ module Pulse
|
|
15
16
|
:save_and_dont_return,
|
16
17
|
:report_time,
|
17
18
|
:start_time,
|
18
|
-
:end_time
|
19
|
+
:end_time,
|
20
|
+
:progress_bar
|
19
21
|
|
20
22
|
# Does not continue downloads-
|
21
23
|
# Will only save once the file has been downloaded in memory
|
22
24
|
|
23
|
-
# TODO: Add in progress bar
|
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,
|
@@ -32,7 +35,8 @@ module Pulse
|
|
32
35
|
verify_ssl: true,
|
33
36
|
drop_exitsing_files_in_path: false,
|
34
37
|
save_and_dont_return: true,
|
35
|
-
report_time: false
|
38
|
+
report_time: false,
|
39
|
+
progress_bar: false)
|
36
40
|
|
37
41
|
@url = url
|
38
42
|
@file_type = file_type
|
@@ -43,6 +47,7 @@ module Pulse
|
|
43
47
|
@drop_exitsing_files_in_path = drop_exitsing_files_in_path
|
44
48
|
@save_and_dont_return = save_and_dont_return
|
45
49
|
@report_time = report_time
|
50
|
+
@progress_bar = progress_bar
|
46
51
|
end
|
47
52
|
|
48
53
|
def call!
|
@@ -52,8 +57,13 @@ module Pulse
|
|
52
57
|
def call
|
53
58
|
return false unless valid?
|
54
59
|
|
60
|
+
if @progress_bar
|
61
|
+
@progress_bar = ::ProgressBar.new(fetch_file_paths.size)
|
62
|
+
end
|
63
|
+
|
55
64
|
fetch_file_paths.map do |file_path|
|
56
|
-
download(file_path)
|
65
|
+
download(file_path, @progress_bar)
|
66
|
+
@progress_bar.increment!
|
57
67
|
end
|
58
68
|
end
|
59
69
|
|
@@ -67,8 +77,14 @@ module Pulse
|
|
67
77
|
(Time.now.to_f * 1000).to_i
|
68
78
|
end
|
69
79
|
|
70
|
-
def print_time
|
71
|
-
|
80
|
+
def print_time(progress_bar=nil)
|
81
|
+
output = "Request time: #{end_time - start_time} ms."
|
82
|
+
|
83
|
+
if progress_bar
|
84
|
+
progress_bar.puts output
|
85
|
+
else
|
86
|
+
puts output
|
87
|
+
end
|
72
88
|
end
|
73
89
|
end
|
74
90
|
end
|
@@ -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
|
File without changes
|
data/pulse-downloader.gemspec
CHANGED
@@ -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.
|
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.
|
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.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- trex22
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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.
|
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.
|
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.
|
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.
|
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.
|
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: []
|