Top Level Namespace
Defined Under Namespace
Modules: CVTool
Classes: JsonParser, OptionParser, String
Instance Method Summary
collapse
Instance Method Details
#api_url_state ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'app/main.rb', line 14
def api_url_state()
sym = :api_url
api_url = @options[sym]
if api_url
@configuration.parse(sym, api_url)
CVTool::Event.print('SET', "#{sym.to_s}: #{api_url.to_s}")
end
end
|
#generate_db_state ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/main.rb', line 66
def generate_db_state()
get_endpoints = [
CVTool::Constants::ENDPOINTS[0],
CVTool::Constants::ENDPOINTS[1]
]
get_endpoints.each do |endpoint|
@options[:rest_api][:endpoint] = endpoint
rest_api_state() do |response|
args = {
endpoint: endpoint,
response: response,
path: @options[:rest_api][:generate_db]
}
CVTool.generate_db(args)
end
end
end
|
#get_config_str ⇒ Object
15
16
17
|
# File 'app/configuration.rb', line 15
def get_config_str()
JSON.pretty_generate(@configuration.db)
end
|
#is_ssl_state ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'app/main.rb', line 23
def is_ssl_state()
sym = :is_ssl
is_ssl = @options[sym]
unless is_ssl == nil
@configuration.parse(sym, is_ssl.to_s)
CVTool::Event.print('SET', "#{sym.to_s}: #{is_ssl.to_s}")
end
end
|
#ra_define_method_state(endpoint, &block) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'app/main.rb', line 32
def ra_define_method_state(endpoint, &block)
h_get = lambda do
CVTool::RestApi.get(@options[:rest_api]) do |response|
if block
block.call(response)
end
end
end
h_post = lambda do
CVTool::RestApi.post(@options[:rest_api]) do |response|
if block
block.call(response)
end
end
end
CVTool::RestApi.define_method( endpoint, h_get, h_post )
end
|
#rest_api_state(&block) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/main.rb', line 51
def rest_api_state(&block)
endpoint = @options[:rest_api][:endpoint]
unless endpoint
CVTool::Event.print('WARNING', "| You must fill out the Endpoint for " +
"the Rest API in order to manage the server.")
exit
end
ra_define_method_state(endpoint) do |response|
if block
block.call(response)
end
end
end
|
#setup_db_state ⇒ Object
85
86
87
88
89
90
91
|
# File 'app/main.rb', line 85
def setup_db_state()
if @options[:rest_api][:endpoint] == CVTool::Constants::ENDPOINTS[12]
rest_api_state()
end
CVTool.setup_db(@options[:rest_api][:setup_db])
end
|
#token_state ⇒ Object
7
8
9
10
11
12
|
# File 'app/main.rb', line 7
def token_state()
unless @options[:gt_length] == -1
token = CVTool.generate_token( @options[:gt_length] )
CVTool::Event.print('TOKEN |', token)
end
end
|