exobasic 0.1.0 → 0.1.2
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 +4 -4
- data/README.md +9 -1
- data/lib/exobasic/data/csv.rb +74 -0
- data/lib/exobasic/settings.rb +1 -1
- data/lib/exobasic/version.rb +1 -1
- data/lib/exobasic.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7188dc6fd9369870387ec25111420f691d07b53319554db7cc177f17beeb17b9
|
4
|
+
data.tar.gz: f818440bebd8d174f594fde794a398591f3e32112f8915f0de29f3ad8ad4d61f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0676aa46835d71fea972a317288ec80f04dd90c0699ba5019293d86b087a7070c5eea208255235831c5f57fa9fd471807018af7a848d5804b3ca34a0d137073
|
7
|
+
data.tar.gz: 7188b9356f8bf78c23a5a97a852b38e6ef2fb59b3bbef95dc9550ae6e5e503fa2afae0e2dd68c64c75d41d117065cccb8c9cace135b2d4f26ee37de6e2134319
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
BasicHelpers: This gem provides basic helpers for a Ruby project.
|
4
4
|
|
5
|
-
- data: DFS
|
5
|
+
- data: DFS, CSV
|
6
6
|
- encryption: ECDSA, RSA, HMAC, Password
|
7
7
|
- http: JSON HTTP client
|
8
8
|
- stats: Average counters
|
@@ -18,6 +18,14 @@ BasicHelpers: This gem provides basic helpers for a Ruby project.
|
|
18
18
|
|
19
19
|
## Getting started
|
20
20
|
|
21
|
+
`bundle`
|
22
|
+
|
23
|
+
`rake build`
|
24
|
+
|
25
|
+
`gem push [GEM.gem]`
|
26
|
+
|
27
|
+
|
21
28
|
### Requirements
|
22
29
|
|
23
30
|
- Ruby 2.5+
|
31
|
+
- BCrypt 3.1.12
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module ExoBasic
|
2
|
+
class CSV
|
3
|
+
def self.str_tok(str, tok_char)
|
4
|
+
str.strip.split(tok_char)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.mk_hdr(elements)
|
8
|
+
elements.map { |i| i.downcase }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mk_rec(hdr, elements)
|
12
|
+
hdr.zip(elements)
|
13
|
+
.map do |pair|
|
14
|
+
k = pair[0]
|
15
|
+
v = pair[1]
|
16
|
+
if !v.nil?
|
17
|
+
v = v.strip
|
18
|
+
end
|
19
|
+
|
20
|
+
[k, v]
|
21
|
+
end
|
22
|
+
.to_h
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.append_file_info(rec, filename, line)
|
26
|
+
rec['file'] = filename
|
27
|
+
rec['line_no'] = line + 1
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.load_csv_file_as_list(csv_file,
|
31
|
+
tok_char=',', with_file_info=false)
|
32
|
+
fields = []
|
33
|
+
records = []
|
34
|
+
File.foreach(csv_file).with_index do |line, line_num|
|
35
|
+
pieces = CSV.str_tok(line, tok_char)
|
36
|
+
if line_num == 0
|
37
|
+
fields = CSV.mk_hdr(pieces)
|
38
|
+
else
|
39
|
+
record = CSV.mk_rec(fields, pieces)
|
40
|
+
if with_file_info
|
41
|
+
CSV.append_file_info(record, csv_file, line_num)
|
42
|
+
end
|
43
|
+
|
44
|
+
records.push(record)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
records
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.load_csv_file_as_hash(csv_file,
|
52
|
+
tok_char=',', with_file_info=false)
|
53
|
+
fields = []
|
54
|
+
records = {}
|
55
|
+
File.foreach(csv_file).with_index do |line, line_num|
|
56
|
+
pieces = CSV.str_tok(line, tok_char)
|
57
|
+
if line_num == 0
|
58
|
+
fields = CSV.mk_hdr(pieces)
|
59
|
+
else
|
60
|
+
record = CSV.mk_rec(fields, pieces)
|
61
|
+
record['id'] = pieces[0]
|
62
|
+
if with_file_info
|
63
|
+
CSV.append_file_info(record, csv_file, line_num)
|
64
|
+
end
|
65
|
+
|
66
|
+
records[record['id']] = record
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
records
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
data/lib/exobasic/settings.rb
CHANGED
data/lib/exobasic/version.rb
CHANGED
data/lib/exobasic.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exobasic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dionysios Kakolyris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.1.
|
19
|
+
version: 3.1.18
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 3.1.
|
26
|
+
version: 3.1.18
|
27
27
|
description: Exotic Basic Helpers
|
28
28
|
email:
|
29
29
|
- contact@exotic.industries
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- README.md
|
35
35
|
- lib/exobasic.rb
|
36
|
+
- lib/exobasic/data/csv.rb
|
36
37
|
- lib/exobasic/data/dfs.rb
|
37
38
|
- lib/exobasic/encrypt/ecdsa_keys.rb
|
38
39
|
- lib/exobasic/encrypt/hmac_keys.rb
|