Top Level Namespace
Defined Under Namespace
Modules: FormatHelpers, Veye
Classes: BaseCSV, BaseExecutor, BaseJSON, BaseMarkdown, BasePretty, BaseTable
Constant Summary
collapse
- DEFAULT_CONFIG_FILE =
'.veye.rc'
- DEFAULT_CONFIG_PATH =
'~'
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.check_configs(global_opts, needs_api_key) ⇒ Object
43
44
45
46
47
|
# File 'lib/veye.rb', line 43
def self.check_configs(global_opts, needs_api_key)
check_config_file
check_api_key(global_opts) if needs_api_key
true
end
|
Instance Method Details
#check_api_key(global_opts) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/veye.rb', line 58
def check_api_key(global_opts)
result = false
if global_opts[:api_key].nil? || global_opts[:api_key].match("add your api key")
printf(
"%s: %s\n",
'Warning: API key is missing.'.color(:yellow),
'You cant access private data.'
)
else
result = true
end
result
end
|
#check_config_file ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/veye.rb', line 32
def check_config_file
unless config_exists?
printf(
"%s: %s\n",
'config file doesnt exist.'.color(:red),
'Use `veye initconfig` to initialize settings file.'
)
exit
end
end
|
#config_exists? ⇒ Boolean
27
28
29
30
|
# File 'lib/veye.rb', line 27
def config_exists?
filepath = get_config_fullpath
File.exist?(filepath)
end
|
#get_config_fullpath ⇒ Object
#init_environment ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'lib/veye.rb', line 49
def init_environment
config_file = get_config_fullpath
$global_options = YAML.load_file(config_file)
$global_options[:config_file] = config_file
$global_options[:url] = Veye::API::Resource.build_url($global_options)
$global_options
end
|
#save_configs ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/veye.rb', line 73
def save_configs
filepath = get_config_fullpath
File.open(filepath, 'w') do |f|
f.puts $global_options.to_yaml
end
printf(
"%s: %s",
'Success'.color(:green),
"new settings are saved into file: `#{filepath}`"
)
end
|