cv-tool 1.0.1 → 1.0.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/app/arguments.rb +13 -2
- data/app/main.rb +13 -3
- data/bin/cvtool +1 -0
- data/lib/cv_tool/version.rb +1 -1
- data/lib/cv_tool.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881853b9f0c1d49fc0519368b4a11e3ba66487480fef286e13c435a4d925ad33
|
4
|
+
data.tar.gz: d1dad9c2a656c647cae30dbd67df8530f82f6e6709b73a5e4495b3e0cd5314be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 953457a042e3126791e2f6c03470b647970a76da3b973e8ab5aa95356d7f20ce94ba36367de4c4e6d314fa5c2c75a99c62f2aea121ead7c30aff0428f2cbcc5c
|
7
|
+
data.tar.gz: d5030140d9394f794cd4e51b8d7d1a5b9ed5027e1b670cb7150f36b9a2a3f00b266e01f407da8caf776703ec5f58880cfbe891f19aa57d19ebd1fae0dd61f0a0
|
data/app/arguments.rb
CHANGED
@@ -6,6 +6,7 @@ require 'option_parser'
|
|
6
6
|
endpoint: nil,
|
7
7
|
request_body: nil,
|
8
8
|
generate_db: nil,
|
9
|
+
setup_db: nil,
|
9
10
|
},
|
10
11
|
gt_length: -1,
|
11
12
|
api_url: nil,
|
@@ -64,10 +65,10 @@ OptionParser.parse do |parser|
|
|
64
65
|
@options[:rest_api][:request_body] = path
|
65
66
|
CVTool::Event.print('REQUEST-BODY', path)
|
66
67
|
end
|
67
|
-
parser.on( "-gdb PATH", "--generate-db PATH", "It creates
|
68
|
+
parser.on( "-gdb PATH", "--generate-db PATH", "It creates JSON files for Projects and\n" +
|
68
69
|
"Articles in the defined path (it obtains\n" +
|
69
70
|
"the relevant data from the Rest API, which\n" +
|
70
|
-
"is then sorted and saved)
|
71
|
+
"is then sorted and saved)." ) do |path|
|
71
72
|
|
72
73
|
unless path
|
73
74
|
path = Dir.pwd
|
@@ -76,6 +77,16 @@ OptionParser.parse do |parser|
|
|
76
77
|
@options[:rest_api][:generate_db] = path
|
77
78
|
CVTool::Event.print('GENERATE-DB', path)
|
78
79
|
end
|
80
|
+
parser.on( "-sdb PATH", "--setup-db PATH", "All JSON files for Articles and Projects\n" +
|
81
|
+
"are uploaded to the database." ) do |path|
|
82
|
+
|
83
|
+
unless path
|
84
|
+
path = Dir.pwd
|
85
|
+
end
|
86
|
+
|
87
|
+
@options[:rest_api][:setup_db] = path
|
88
|
+
CVTool::Event.print('SETUP-DB', path)
|
89
|
+
end
|
79
90
|
end
|
80
91
|
end
|
81
92
|
parser.on( "-gt LENG", "--generate-token LENG",
|
data/app/main.rb
CHANGED
@@ -82,11 +82,21 @@ def generate_db_state()
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
|
86
|
-
|
85
|
+
def setup_db_state()
|
86
|
+
if @options[:rest_api][:endpoint] == CVTool::Constants::ENDPOINTS[12]
|
87
87
|
rest_api_state()
|
88
|
-
|
88
|
+
end
|
89
|
+
|
90
|
+
CVTool.setup_db(@options[:rest_api][:setup_db])
|
91
|
+
end
|
92
|
+
|
93
|
+
if @options[:rest_api][:is_active]
|
94
|
+
if @options[:rest_api][:generate_db]
|
89
95
|
generate_db_state()
|
96
|
+
elsif @options[:rest_api][:setup_db]
|
97
|
+
setup_db_state()
|
98
|
+
else
|
99
|
+
rest_api_state()
|
90
100
|
end
|
91
101
|
else
|
92
102
|
token_state()
|
data/bin/cvtool
CHANGED
data/lib/cv_tool/version.rb
CHANGED
data/lib/cv_tool.rb
CHANGED
@@ -36,4 +36,30 @@ module CVTool
|
|
36
36
|
CVTool::Event.print('GENERATE', absolute_path_file)
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
def setup_db(path)
|
41
|
+
dir_apath = File.join(path, '*/*.json')
|
42
|
+
json_files = Dir.glob(dir_apath)
|
43
|
+
files = {
|
44
|
+
articles: json_files.select { |e| e.index(/\/articles\//) },
|
45
|
+
projects: json_files.select { |e| e.index(/\/projects\//) },
|
46
|
+
}
|
47
|
+
|
48
|
+
h_execute_command = lambda do |symbol|
|
49
|
+
result = ""
|
50
|
+
files[symbol].each.with_index do |path, i|
|
51
|
+
result += "#{ROOT_FILE} -ra -ep post/#{symbol.to_s.sub(/s$/, '')}/add -reb #{path} &&\n"
|
52
|
+
end
|
53
|
+
return result
|
54
|
+
end
|
55
|
+
|
56
|
+
command = h_execute_command.call(:projects) + h_execute_command.call(:articles)
|
57
|
+
is_success = system(command.sub(/ &&\n$/, "\n"))
|
58
|
+
|
59
|
+
if is_success
|
60
|
+
CVTool::Event.print('SETUP-DB', "done")
|
61
|
+
else
|
62
|
+
CVTool::Event.print('SETUP-DB', "an error occurred during db setup.")
|
63
|
+
end
|
64
|
+
end
|
39
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cv-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Filip Vrba
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The tool will allow communication through a Rest API, enabling the retrieval
|
14
14
|
and transmission of data to and from the database. Additionally, it will provide
|