Top Level Namespace

Defined Under Namespace

Classes: AdminUser, Event, Plugin, PluginBuilder, PluginManager, Settings, Timer, Zmb

Instance Method Summary collapse

Instance Method Details

#ask(question) ⇒ Object



51
52
53
54
55
# File 'bin/zmb', line 51

def ask(question)
  puts "#{question} (yes/no)"
  answer = gets.chomp
  answer == 'yes' or answer == 'y'
end

#get_value(question) ⇒ Object



57
58
59
60
61
62
63
# File 'bin/zmb', line 57

def get_value(question)
  puts question
  answer = gets.chomp
  
  return nil if answer == ''
  answer
end

#wizard(zmb, plugin) ⇒ Object



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
# File 'bin/zmb', line 65

def wizard(zmb, plugin)
  STDOUT.flush
  
  if ask("Would you like to add the #{plugin.name} plugin? #{plugin.description}") then
    if plugin.multi_instances? then
      instance = get_value("What would you like to name this instance of #{plugin.name}?")
    else
      instance = plugin.name
    end
    
    if not instance then
      puts "Must supply instance name, if this plugin should only be loaded once such as commands or users then you can call it that."
      return wizard(zmb, plugin)
    end
    
    zmb.setup(plugin.name, instance)
    obj = zmb.plugin_manager.plugin plugin.name
    if obj.respond_to?('wizard') then
      settings = zmb.settings.setting(instance)
      settings['plugin'] = plugin.name
      
      obj.wizard.each do |key, value|
        if value.has_key?('help') then
          set = get_value("#{value['help']} (default=#{value['default']})")
          settings[key] = set if set
        end
      end
      
      zmb.settings.save(instance, settings)
    end
    zmb.load instance
  end
end