nsrr 5.0.0.rc → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +1 -1
- data/README.md +21 -1
- data/lib/nsrr/commands/download.rb +3 -2
- data/lib/nsrr/helpers/download_request.rb +1 -4
- data/lib/nsrr/models/dataset.rb +7 -0
- data/lib/nsrr/version.rb +2 -2
- data/nsrr.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b100c526a2c495b60d331025f5d41a7b42c7665483198feaf75f7cf1b02790a
|
4
|
+
data.tar.gz: 22fc81dc33d64b6bd080003269115153094fbaec519ac8f0b4cfabeb8b4a0fcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4128e2ab10af765f53ebb7f78aa2ec1404ad3b70b66a4dccf464ca3e451ca6e6f33c08920f785a02e691b33a9455d3b49e204cc51ffa5bf609f46467b553f806
|
7
|
+
data.tar.gz: 906cacc94f180fab43e6adeafc76534dfd414b73e8c31bda2e045e2b5126b4d599114c5a1582112503b0bc3ef3fec8c10f81a69c8fc89ea8f38d9cadeecd5d29
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
##
|
1
|
+
## 8.0.0 (August 7, 2021)
|
2
|
+
|
3
|
+
### Bug Fix
|
4
|
+
- Fixed a bug that prevented folders and files with spaces in their paths from
|
5
|
+
being downloaded
|
6
|
+
|
7
|
+
## 7.0.0 (April 18, 2021)
|
8
|
+
|
9
|
+
### Enhancements
|
10
|
+
- **General Changes**
|
11
|
+
- Added `--file` option to specify a regular expression to match a file name,
|
12
|
+
(by @k0kubun)
|
13
|
+
|
14
|
+
## 6.0.0 (January 16, 2021)
|
15
|
+
|
16
|
+
### Enhancements
|
17
|
+
- **General Changes**
|
18
|
+
- Added compatibility for Ruby 3.0.0
|
19
|
+
|
20
|
+
## 5.0.0 (May 7, 2019)
|
2
21
|
|
3
22
|
### Enhancements
|
4
23
|
- **General Changes**
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ The official ruby gem built to simplify file downloads and dataset integration t
|
|
7
7
|
|
8
8
|
## Prerequisites
|
9
9
|
|
10
|
-
You must have **Ruby 2.
|
10
|
+
You must have **Ruby 2.7+ installed** on your system to use the NSRR gem.
|
11
11
|
|
12
12
|
- [Install Ruby on Windows](https://github.com/remomueller/documentation/blob/master/windows/130-ruby.md)
|
13
13
|
- [Install Ruby on Mac](https://github.com/remomueller/documentation/blob/master/macos/130-install-rvm.md)
|
@@ -65,6 +65,26 @@ You can combine the file check flag with the folder depth flag as well.
|
|
65
65
|
nsrr download shhs/datasets --shallow --fast
|
66
66
|
```
|
67
67
|
|
68
|
+
You can specify a regular expression to filter files that are downloaded.
|
69
|
+
|
70
|
+
```console
|
71
|
+
nsrr download nchsdb/health_data --file="^PROCEDURE.*\.csv$"
|
72
|
+
```
|
73
|
+
|
74
|
+
```console
|
75
|
+
create nchsdb/health_data/
|
76
|
+
skipped DEMOGRAPHIC.csv
|
77
|
+
skipped DIAGNOSIS.csv
|
78
|
+
skipped ENCOUNTER.csv
|
79
|
+
skipped MEASUREMENT.csv
|
80
|
+
skipped MEDICATION.csv
|
81
|
+
downloaded PROCEDURE.csv
|
82
|
+
downloaded PROCEDURE_SURG_HX.csv
|
83
|
+
skipped SLEEP_ENC_ID.csv
|
84
|
+
skipped SLEEP_STUDY.csv
|
85
|
+
skipped Sleep_Study_Data_File_Format.pdf
|
86
|
+
```
|
87
|
+
|
68
88
|
### Open the console and download entire datasets
|
69
89
|
|
70
90
|
```console
|
@@ -21,6 +21,7 @@ module Nsrr
|
|
21
21
|
(@token, argv) = parse_parameter_with_value(argv, ["token"], "")
|
22
22
|
(@file_comparison, argv) = parse_parameter(argv, ["fast", "fresh", "md5"], "md5")
|
23
23
|
(@depth, argv) = parse_parameter(argv, ["shallow", "recursive"], "recursive")
|
24
|
+
(@file, argv) = parse_parameter_with_value(argv, ["file"], "")
|
24
25
|
@dataset_slug = argv[1].to_s.split("/").first
|
25
26
|
@full_path = (argv[1].to_s.split("/")[1..-1] || []).join("/")
|
26
27
|
end
|
@@ -35,7 +36,7 @@ module Nsrr
|
|
35
36
|
@token = Nsrr::Helpers::Authorization.get_token(@token) if @token.to_s == ""
|
36
37
|
@dataset = Dataset.find(@dataset_slug, @token)
|
37
38
|
if @dataset
|
38
|
-
@dataset.download(@full_path, depth: @depth, method: @file_comparison)
|
39
|
+
@dataset.download(@full_path, depth: @depth, method: @file_comparison, file: Regexp.new(@file))
|
39
40
|
else
|
40
41
|
puts "\nThe dataset " + @dataset_slug.white + " was not found."
|
41
42
|
datasets = all_datasets
|
@@ -80,7 +81,7 @@ module Nsrr
|
|
80
81
|
result = default
|
81
82
|
options.each do |option|
|
82
83
|
argv.each do |arg|
|
83
|
-
result = arg.gsub(/^--#{option}=/, "") if arg =~ /^--#{option}
|
84
|
+
result = arg.gsub(/^--#{option}=/, "") if arg =~ /^--#{option}=[^\s]/
|
84
85
|
end
|
85
86
|
end
|
86
87
|
[result, argv]
|
@@ -17,8 +17,7 @@ module Nsrr
|
|
17
17
|
attr_reader :url, :error, :file_size
|
18
18
|
|
19
19
|
def initialize(url, download_folder)
|
20
|
-
|
21
|
-
@url = URI.parse(escaped_url)
|
20
|
+
@url = URI.parse(url.gsub(/\s/, "%20"))
|
22
21
|
@http = Net::HTTP.new(@url.host, @url.port)
|
23
22
|
if @url.scheme == "https"
|
24
23
|
@http.use_ssl = true
|
@@ -26,8 +25,6 @@ module Nsrr
|
|
26
25
|
end
|
27
26
|
@download_folder = download_folder
|
28
27
|
@file_size = 0
|
29
|
-
rescue
|
30
|
-
@error = "Invalid Token"
|
31
28
|
end
|
32
29
|
|
33
30
|
# Writes file segments to disk immediately instead of storing in memory
|
data/lib/nsrr/models/dataset.rb
CHANGED
@@ -69,6 +69,7 @@ module Nsrr
|
|
69
69
|
|
70
70
|
begin
|
71
71
|
puts " File Check: " + options[:method].to_s.white
|
72
|
+
puts " File Regex: " + options[:file].inspect.white
|
72
73
|
puts " Depth: " + options[:depth].to_s.white
|
73
74
|
puts ""
|
74
75
|
if @download_token.nil?
|
@@ -100,6 +101,12 @@ module Nsrr
|
|
100
101
|
create_folder_for_path(full_path)
|
101
102
|
|
102
103
|
files(full_path).select(&:is_file).each do |file|
|
104
|
+
unless file.file_name.match?(options[:file])
|
105
|
+
puts " skipped".blue + " #{file.file_name}"
|
106
|
+
@files_skipped += 1
|
107
|
+
next
|
108
|
+
end
|
109
|
+
|
103
110
|
current_folder = ::File.join(slug.to_s, file.folder.to_s)
|
104
111
|
result = file.download(options[:method], current_folder, @download_token)
|
105
112
|
case result
|
data/lib/nsrr/version.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module Nsrr
|
4
4
|
module VERSION #:nodoc:
|
5
|
-
MAJOR =
|
5
|
+
MAJOR = 8
|
6
6
|
MINOR = 0
|
7
7
|
TINY = 0
|
8
|
-
BUILD =
|
8
|
+
BUILD = nil # "pre", "beta1", "beta2", "rc", "rc2", nil
|
9
9
|
|
10
10
|
STRING = [MAJOR, MINOR, TINY, BUILD].compact.join(".")
|
11
11
|
end
|
data/nsrr.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.description = "The official ruby gem to download files and datasets from the [NSRR](https://sleepdata.org)"
|
22
22
|
spec.homepage = "https://github.com/nsrr/nsrr-gem"
|
23
23
|
|
24
|
-
spec.required_ruby_version = ">= 2.
|
24
|
+
spec.required_ruby_version = ">= 2.7.2"
|
25
25
|
spec.required_rubygems_version = ">= 2.6.3"
|
26
26
|
|
27
27
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nsrr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 8.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Remo Mueller
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,7 @@ homepage: https://github.com/nsrr/nsrr-gem
|
|
84
84
|
licenses:
|
85
85
|
- MIT
|
86
86
|
metadata: {}
|
87
|
-
post_install_message:
|
87
|
+
post_install_message:
|
88
88
|
rdoc_options: []
|
89
89
|
require_paths:
|
90
90
|
- lib
|
@@ -92,15 +92,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
93
93
|
- - ">="
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 2.
|
95
|
+
version: 2.7.2
|
96
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
98
|
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
100
|
version: 2.6.3
|
101
101
|
requirements: []
|
102
|
-
rubygems_version: 3.
|
103
|
-
signing_key:
|
102
|
+
rubygems_version: 3.2.16
|
103
|
+
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: Download files easily from the NSRR website, https://sleepdata.org
|
106
106
|
test_files: []
|