Class: Kafo::KafoConfigure
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Kafo::KafoConfigure
show all
- Includes:
- StringHelper
- Defined in:
- lib/kafo/kafo_configure.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#dashize, #parametrize, #underscore, #with_prefix
Constructor Details
Returns a new instance of KafoConfigure.
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/kafo/kafo_configure.rb', line 43
def initialize(*args)
self.class.preset_color_scheme
self.class.logger = Logger.new
self.class.exit_handler = ExitHandler.new
@progress_bar = nil
@config_reload_requested = false
scenario_manager = setup_scenario_manager
self.class.scenario_manager = scenario_manager
scenario_manager.list_available_scenarios if ARGV.include?('--list-scenarios')
setup_config(config_file)
self.class.hooking.execute(:pre_migrations)
self.class.config.run_migrations
if ARGV.include?('--migrations-only')
self.class.verbose = (ARGV.include?('--verbose') || ARGV.include?('-v'))
Logger.setup
self.class.logger.info('Log buffers flushed')
self.class.exit(0)
end
if @config_reload_requested
scenario_manager = setup_scenario_manager
self.class.scenario_manager = scenario_manager
setup_config(self.class.config_file)
self.class.logger.info('Installer configuration was reloaded')
end
if scenario_manager.configured?
scenario_manager.check_scenario_change(self.class.config_file)
if scenario_manager.scenario_changed?(self.class.config_file)
prev_config = scenario_manager.load_configuration(scenario_manager.previous_scenario)
prev_config.run_migrations
self.class.config.migrate_configuration(prev_config, :skip => [:log_name])
setup_config(self.class.config_file)
self.class.logger.info("Due to scenario change the configuration (#{self.class.config_file}) was updated with #{scenario_manager.previous_scenario} and reloaded.")
end
end
super
self.class.hooking.execute(:boot)
set_app_options
parse clamp_app_arguments
parse_app_arguments
Logger.setup
self.class.set_color_scheme
self.class.hooking.execute(:init)
set_parameters
set_options
end
|
Class Attribute Details
.app_options ⇒ Object
Returns the value of attribute app_options.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def app_options
@app_options
end
|
.check_dirs ⇒ Object
Returns the value of attribute check_dirs.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def check_dirs
@check_dirs
end
|
.config ⇒ Object
Returns the value of attribute config.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def config
@config
end
|
.config_file ⇒ Object
Returns the value of attribute config_file.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def config_file
@config_file
end
|
.exit_handler ⇒ Object
Returns the value of attribute exit_handler.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def exit_handler
@exit_handler
end
|
.gem_root ⇒ Object
Returns the value of attribute gem_root.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def gem_root
@gem_root
end
|
.hooking ⇒ Object
38
39
40
|
# File 'lib/kafo/kafo_configure.rb', line 38
def hooking
@hooking ||= Hooking.new
end
|
.kafo_modules_dir ⇒ Object
Returns the value of attribute kafo_modules_dir.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def kafo_modules_dir
@kafo_modules_dir
end
|
.logger ⇒ Object
Returns the value of attribute logger.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def logger
@logger
end
|
.module_dirs ⇒ Object
Returns the value of attribute module_dirs.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def module_dirs
@module_dirs
end
|
.root_dir ⇒ Object
Returns the value of attribute root_dir.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def root_dir
@root_dir
end
|
.scenario_manager ⇒ Object
Returns the value of attribute scenario_manager.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def scenario_manager
@scenario_manager
end
|
.temp_config_file ⇒ Object
Returns the value of attribute temp_config_file.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def temp_config_file
@temp_config_file
end
|
.verbose ⇒ Object
Returns the value of attribute verbose.
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 33
def verbose
@verbose
end
|
Class Method Details
.app_option(*args, &block) ⇒ Object
183
184
185
186
187
|
# File 'lib/kafo/kafo_configure.rb', line 183
def self.app_option(*args, &block)
self.app_options ||= []
self.app_options.push self.option(*args, &block)
self.app_options.last
end
|
.exit(code, &block) ⇒ Object
159
160
161
|
# File 'lib/kafo/kafo_configure.rb', line 159
def self.exit(code, &block)
exit_handler.exit(code, &block)
end
|
.exit_code ⇒ Object
163
164
165
|
# File 'lib/kafo/kafo_configure.rb', line 163
def self.exit_code
self.exit_handler.exit_code
end
|
.help(*args) ⇒ Object
176
177
178
179
180
181
|
# File 'lib/kafo/kafo_configure.rb', line 176
def self.help(*args)
kafo = args.pop
builder_class = kafo.full_help? ? HelpBuilders::Advanced : HelpBuilders::Basic
args.push builder_class.new(kafo.params)
super(*args)
end
|
.run ⇒ Object
153
154
155
156
157
|
# File 'lib/kafo/kafo_configure.rb', line 153
def self.run
return super
rescue SystemExit => e
self.exit_handler.exit(self.exit_code)
end
|
Instance Method Details
#add_module(name) ⇒ Object
201
202
203
204
205
|
# File 'lib/kafo/kafo_configure.rb', line 201
def add_module(name)
config.add_module(name)
reset_params_cache
self.module(name)
end
|
#config ⇒ Object
104
105
106
|
# File 'lib/kafo/kafo_configure.rb', line 104
def config
self.class.config
end
|
#execute ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/kafo/kafo_configure.rb', line 112
def execute
parse_cli_arguments
if (self.class.verbose = !!verbose?)
Logger.setup_verbose
else
@progress_bar = self.class.config.app[:colors] ? ProgressBars::Colored.new : ProgressBars::BlackWhite.new
end
unless skip_checks_i_know_better?
unless SystemChecker.check
puts "Your system does not meet configuration criteria"
self.class.exit(:invalid_system)
end
end
self.class.hooking.execute(:pre_validations)
if interactive?
wizard = Wizard.new(self)
wizard.run
else
unless validate_all
puts "Error during configuration, exiting"
self.class.exit(:invalid_values)
end
end
self.class.hooking.execute(:pre_commit)
if dont_save_answers? || noop?
self.class.temp_config_file = self.class.config.temp_config_file
store_params(self.class.config.temp_config_file)
else
store_params
self.class.scenario_manager.link_last_scenario(self.class.config_file) if self.class.scenario_manager.configured?
end
run_installation
return self
rescue SystemExit
return self
end
|
#exit_code ⇒ Object
167
168
169
|
# File 'lib/kafo/kafo_configure.rb', line 167
def exit_code
self.class.exit_code
end
|
#help ⇒ Object
172
173
174
|
# File 'lib/kafo/kafo_configure.rb', line 172
def help
self.class.help(invocation_path, self)
end
|
#logger ⇒ Object
108
109
110
|
# File 'lib/kafo/kafo_configure.rb', line 108
def logger
self.class.logger
end
|
#module(name) ⇒ Object
211
212
213
|
# File 'lib/kafo/kafo_configure.rb', line 211
def module(name)
modules.detect { |m| m.name == name }
end
|
#modules ⇒ Object
207
208
209
|
# File 'lib/kafo/kafo_configure.rb', line 207
def modules
config.modules.sort
end
|
#param(mod, name) ⇒ Object
215
216
217
|
# File 'lib/kafo/kafo_configure.rb', line 215
def param(mod, name)
config.param(mod, name)
end
|
#params ⇒ Object
189
190
191
192
193
194
|
# File 'lib/kafo/kafo_configure.rb', line 189
def params
@params ||= modules.map(&:params).flatten
rescue KafoParsers::ModuleName => e
puts e
self.class.exit(:unknown_module)
end
|
#request_config_reload ⇒ Object
219
220
221
|
# File 'lib/kafo/kafo_configure.rb', line 219
def request_config_reload
@config_reload_requested = true
end
|
#reset_params_cache ⇒ Object
196
197
198
199
|
# File 'lib/kafo/kafo_configure.rb', line 196
def reset_params_cache
@params = nil
params
end
|