Class: KafoConfigure
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- KafoConfigure
show all
- Includes:
- StringHelper
- Defined in:
- lib/kafo/kafo_configure.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#dashize, #parametrize, #underscore, #with_prefix
Constructor Details
Returns a new instance of KafoConfigure.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/kafo/kafo_configure.rb', line 22
def initialize(*args)
self.class.config_file = config_file
self.class.config = Configuration.new(self.class.config_file)
self.class.root_dir = File.expand_path(self.class.config.app[:installer_dir])
modules_dir = self.class.config.app[:module_dir] || (self.class.config.app[:installer_dir] + '/modules')
self.class.modules_dir = File.expand_path(modules_dir)
self.class.gem_root = File.join(File.dirname(__FILE__), '../../')
self.class.kafo_modules_dir = self.class.config.app[:kafo_modules_dir] || (self.class.gem_root + '/modules')
Logger.setup
@logger = Logging.logger.root
super
set_parameters
set_options
end
|
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def config
@config
end
|
.config_file ⇒ Object
Returns the value of attribute config_file.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def config_file
@config_file
end
|
.gem_root ⇒ Object
Returns the value of attribute gem_root.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def gem_root
@gem_root
end
|
.kafo_modules_dir ⇒ Object
Returns the value of attribute kafo_modules_dir.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def kafo_modules_dir
@kafo_modules_dir
end
|
.modules_dir ⇒ Object
Returns the value of attribute modules_dir.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def modules_dir
@modules_dir
end
|
.root_dir ⇒ Object
Returns the value of attribute root_dir.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def root_dir
@root_dir
end
|
.temp_config_file ⇒ Object
Returns the value of attribute temp_config_file.
18
19
20
|
# File 'lib/kafo/kafo_configure.rb', line 18
def temp_config_file
@temp_config_file
end
|
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
15
16
17
|
# File 'lib/kafo/kafo_configure.rb', line 15
def logger
@logger
end
|
Class Method Details
.exit(code) ⇒ Object
86
87
88
89
|
# File 'lib/kafo/kafo_configure.rb', line 86
def self.exit(code)
@exit_code = translate_exit_code(code)
throw :exit
end
|
.exit_code ⇒ Object
91
92
93
|
# File 'lib/kafo/kafo_configure.rb', line 91
def self.exit_code
@exit_code ||= 0
end
|
.run ⇒ Object
75
76
77
78
79
80
|
# File 'lib/kafo/kafo_configure.rb', line 75
def self.run
catch :exit do
return super
end
Kernel.exit(self.exit_code) end
|
.translate_exit_code(code) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/kafo/kafo_configure.rb', line 95
def self.translate_exit_code(code)
return code if code.is_a? Fixnum
error_codes = { :invalid_system => 20,
:invalid_values => 21,
:manifest_error => 22,
:no_answer_file => 23,
:unknown_module => 24,
:defaults_error => 25}
if error_codes.has_key? code
return error_codes[code]
else
raise "Unknown code #{code}"
end
end
|
Instance Method Details
#config ⇒ Object
37
38
39
|
# File 'lib/kafo/kafo_configure.rb', line 37
def config
self.class.config
end
|
#execute ⇒ Object
41
42
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
|
# File 'lib/kafo/kafo_configure.rb', line 41
def execute
catch :exit do
parse_cli_arguments
if verbose?
logger.appenders = logger.appenders << ::Logging.appenders.stdout(:layout => Logger::COLOR_LAYOUT)
end
unless SystemChecker.check
puts "Your system does not meet configuration criteria"
exit(:invalid_system)
end
if interactive?
wizard = Wizard.new
wizard.run
else
unless validate_all
puts "Error during configuration, exiting"
exit(:invalid_values)
end
end
if dont_save_answers?
self.class.temp_config_file = temp_config_file
store_params(temp_config_file)
else
store_params
end
run_installation
end
return self
end
|
#exit_code ⇒ Object
82
83
84
|
# File 'lib/kafo/kafo_configure.rb', line 82
def exit_code
self.class.exit_code
end
|
#module(name) ⇒ Object
121
122
123
|
# File 'lib/kafo/kafo_configure.rb', line 121
def module(name)
modules.detect { |m| m.name == name}
end
|
#modules ⇒ Object
117
118
119
|
# File 'lib/kafo/kafo_configure.rb', line 117
def modules
config.modules
end
|
#param(mod, name) ⇒ Object
125
126
127
|
# File 'lib/kafo/kafo_configure.rb', line 125
def param(mod, name)
params.detect { |p| p.name == name && p.module.name == mod }
end
|
#params ⇒ Object
110
111
112
113
114
115
|
# File 'lib/kafo/kafo_configure.rb', line 110
def params
@params ||= modules.map(&:params).flatten
rescue ModuleName => e
puts e
exit(:unknown_module)
end
|