csr_data_inventory 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpers/color.rb +100 -0
- data/lib/csr_data_inventory.rb +11 -8
- data/lib/download_request.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ebb4dacd093e7db96697bbc920fdb5d09bbc3af4c6169797d18808c7c17f466
|
4
|
+
data.tar.gz: 27ac507c3e0ab24e4065b6cd6d49517be753a80f0d6f06e26577e515b49e4c6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a7ee1281de48ec8d5ffe188be76ac1d0d025080939b5f21a133076db004890cbbec8990e768348f404bc62f4a85cc7096c2db33c1016ea26542e394d39db35f
|
7
|
+
data.tar.gz: d6847123ce1124a7971fe78d0506882d510e8e597f36b552cae1a97e5462554fda2399a6f9ed7f9700d474f4f3f84d052e64300209f8fed9bce53866604c13fd
|
data/helpers/color.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Adds ANSI colors to string class.
|
4
|
+
class String
|
5
|
+
def black
|
6
|
+
"\e[30m#{self}\e[0m"
|
7
|
+
end
|
8
|
+
|
9
|
+
def red
|
10
|
+
"\e[31m#{self}\e[0m"
|
11
|
+
end
|
12
|
+
|
13
|
+
def green
|
14
|
+
"\e[32m#{self}\e[0m"
|
15
|
+
end
|
16
|
+
|
17
|
+
def brown
|
18
|
+
"\e[33m#{self}\e[0m"
|
19
|
+
end
|
20
|
+
|
21
|
+
def yellow
|
22
|
+
brown
|
23
|
+
end
|
24
|
+
|
25
|
+
def blue
|
26
|
+
"\e[34m#{self}\e[0m"
|
27
|
+
end
|
28
|
+
|
29
|
+
def magenta
|
30
|
+
"\e[35m#{self}\e[0m"
|
31
|
+
end
|
32
|
+
|
33
|
+
def cyan
|
34
|
+
"\e[36m#{self}\e[0m"
|
35
|
+
end
|
36
|
+
|
37
|
+
def gray
|
38
|
+
"\e[37m#{self}\e[0m"
|
39
|
+
end
|
40
|
+
|
41
|
+
def white
|
42
|
+
"\e[39m#{bold}\e[0m"
|
43
|
+
end
|
44
|
+
|
45
|
+
def bg_black
|
46
|
+
"\e[40m#{self}\e[0m"
|
47
|
+
end
|
48
|
+
|
49
|
+
def bg_red
|
50
|
+
"\e[41m#{self}\e[0m"
|
51
|
+
end
|
52
|
+
|
53
|
+
def bg_green
|
54
|
+
"\e[42m#{self}\e[0m"
|
55
|
+
end
|
56
|
+
|
57
|
+
def bg_brown
|
58
|
+
"\e[43m#{self}\e[0m"
|
59
|
+
end
|
60
|
+
|
61
|
+
def bg_blue
|
62
|
+
"\e[44m#{self}\e[0m"
|
63
|
+
end
|
64
|
+
|
65
|
+
def bg_magenta
|
66
|
+
"\e[45m#{self}\e[0m"
|
67
|
+
end
|
68
|
+
|
69
|
+
def bg_cyan
|
70
|
+
"\e[46m#{self}\e[0m"
|
71
|
+
end
|
72
|
+
|
73
|
+
def bg_gray
|
74
|
+
"\e[47m#{self}\e[0m"
|
75
|
+
end
|
76
|
+
|
77
|
+
def bold
|
78
|
+
"\e[1m#{self}\e[22m"
|
79
|
+
end
|
80
|
+
|
81
|
+
def italic
|
82
|
+
"\e[3m#{self}\e[23m"
|
83
|
+
end
|
84
|
+
|
85
|
+
def underline
|
86
|
+
"\e[4m#{self}\e[24m"
|
87
|
+
end
|
88
|
+
|
89
|
+
def blink
|
90
|
+
"\e[5m#{self}\e[25m"
|
91
|
+
end
|
92
|
+
|
93
|
+
def reverse_color
|
94
|
+
"\e[7m#{self}\e[27m"
|
95
|
+
end
|
96
|
+
|
97
|
+
def colorless
|
98
|
+
gsub(/\e\[\d{1,2}m/, "")
|
99
|
+
end
|
100
|
+
end
|
data/lib/csr_data_inventory.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require_relative './download_request.rb'
|
2
|
+
require_relative '../helpers/color.rb'
|
2
3
|
class CSRDataInventory
|
3
4
|
def self.download
|
4
5
|
puts "Please enter your token:"
|
5
6
|
token = gets.strip
|
6
|
-
download_url = "https://datascience.uth.edu/databases/download_file_list?"
|
7
|
+
download_url = "https://datascience.uth.edu/medcis/databases/download_file_list?"
|
7
8
|
params_part = URI.encode_www_form([["token",token]])
|
8
9
|
download_url = download_url + params_part
|
9
10
|
download_folder = download_folder = ::File.join(Dir.pwd, "#{token}_file_list.txt")
|
@@ -17,25 +18,27 @@ class CSRDataInventory
|
|
17
18
|
path = path_tokens[0]
|
18
19
|
file_size = path_tokens[1]
|
19
20
|
|
20
|
-
puts "Downloading file: #{path}"
|
21
|
-
download_url = "https://datascience.uth.edu/databases/download_file?"
|
21
|
+
puts " Downloading file: #{path}".bg_gray.blue
|
22
|
+
download_url = "https://datascience.uth.edu/medcis/databases/download_file?"
|
22
23
|
params_part = URI.encode_www_form([["token",token], ["path", path]])
|
23
24
|
download_url = download_url + params_part
|
24
25
|
download_folder = ::File.join(Dir.pwd, path[14..-1])
|
25
26
|
if File.exists?(download_folder) and (File.size(download_folder).to_s == file_size)
|
26
|
-
puts "File exists"
|
27
|
+
puts " File exists".white
|
27
28
|
next
|
28
29
|
end
|
29
30
|
download_request = DownloadRequest.new(download_url, download_folder)
|
30
31
|
download_request.get
|
31
32
|
if download_request.error.to_s == ""
|
32
|
-
puts "Successful"
|
33
|
+
puts " Successful".green
|
33
34
|
else
|
34
|
-
puts "Failed: #{download_request.error.to_s}"
|
35
|
+
puts " Failed: #{download_request.error.to_s}".red
|
35
36
|
end
|
36
|
-
end
|
37
|
+
end;nil
|
37
38
|
else
|
38
|
-
puts " #{download_request.error.to_s}"
|
39
|
+
puts " #{download_request.error.to_s}".red
|
39
40
|
end
|
41
|
+
rescue
|
42
|
+
puts "\nINTERRUPTED".red
|
40
43
|
end
|
41
44
|
end
|
data/lib/download_request.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csr_data_inventory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shiqiang Tao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem to download CSR Data in a scalable way.
|
14
14
|
email: shiqiang.tao@uth.tmc.edu
|
@@ -16,6 +16,7 @@ executables: []
|
|
16
16
|
extensions: []
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
|
+
- helpers/color.rb
|
19
20
|
- lib/csr_data_inventory.rb
|
20
21
|
- lib/download_request.rb
|
21
22
|
homepage: https://rubygems.org/gems/csr_data_inventory
|
@@ -37,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
38
|
- !ruby/object:Gem::Version
|
38
39
|
version: '0'
|
39
40
|
requirements: []
|
40
|
-
rubygems_version: 3.
|
41
|
+
rubygems_version: 3.1.6
|
41
42
|
signing_key:
|
42
43
|
specification_version: 4
|
43
44
|
summary: Download CSR Data
|