Class: Spider::SpiderSetupWizard
- Defined in:
- lib/spiderfw/setup/spider_setup_wizard.rb
Instance Attribute Summary collapse
-
#first_run ⇒ Object
Returns the value of attribute first_run.
Instance Method Summary collapse
Methods inherited from Wizard
#add_key, #ask, #ask!, #ask?, #do_ask, #get_value, #implementation, #initialize, #set_value, #values, #wizard_instance
Constructor Details
This class inherits a constructor from Spider::Wizard
Instance Attribute Details
#first_run ⇒ Object
Returns the value of attribute first_run.
186 187 188 |
# File 'lib/spiderfw/setup/spider_setup_wizard.rb', line 186 def first_run @first_run end |
Instance Method Details
#get_db_wizard(db_type) ⇒ Object
216 217 218 219 220 221 |
# File 'lib/spiderfw/setup/spider_setup_wizard.rb', line 216 def get_db_wizard(db_type) { 'mysql' => MySQLSetupWizard, 'oracle' => OracleSetupWizard }[db_type] end |
#run ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/spiderfw/setup/spider_setup_wizard.rb', line 188 def run if ask? _("Do you want to configure a database?"), :default => (@first_run ? true : nil) ask _("Which database do you want to configure?"), :db_label, :choices => ['default', 'civiliaopen', 'tracciatointermedio'], :default => 'default' conf = Spider.conf.get("storages.#{@db_label}") url_db_type = nil if conf && conf["url"] if conf["url"] =~ /db:(\w+):\/\// url_db_type = $1 end end ask _("Database type: "), :db_type, :choices => ['sqlite', 'mysql', 'oracle'], \ :default => url_db_type return unless @db_type unless @db_type == 'sqlite' db = wizard_instance(get_db_wizard(@db_type)) db.parse_url(conf["url"]) if conf && conf["url"] && @db_type == url_db_type db.run editor = Spider.config.get_editor editor.set('storages', @db_label, 'url', db.get_url) editor.save end puts _("Configuration saved.") end end |