Module: MadChatter::Config
- Defined in:
- lib/mad_chatter/config.rb
Class Method Summary collapse
- .init ⇒ Object
- .init_config ⇒ Object
- .init_default_channels ⇒ Object
- .init_default_message_listeners ⇒ Object
- .init_extensions ⇒ Object
Class Method Details
.init ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/mad_chatter/config.rb', line 6 def init config = init_config init_extensions init_default_channels return config end |
.init_config ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mad_chatter/config.rb', line 14 def init_config config_file = File.join(Dir.pwd, 'config.yml') abort 'Could not find Mad Chatter config.yml file' unless File.exist?(config_file) config = YAML::load(File.open(config_file)) defaults = { 'websocket_port' => 8100, } @config = defaults.merge!(config) end |
.init_default_channels ⇒ Object
45 46 47 |
# File 'lib/mad_chatter/config.rb', line 45 def init_default_channels MadChatter.channels << MadChatter::Channel.new('default') end |
.init_default_message_listeners ⇒ Object
25 26 27 28 29 |
# File 'lib/mad_chatter/config.rb', line 25 def %w{ ChannelCommands Nick Image Code Markdown }.each do |listener| MadChatter. << Object.const_get('MadChatter').const_get('MessageListeners').const_get(listener).new end end |
.init_extensions ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/mad_chatter/config.rb', line 31 def init_extensions # simple_extensions_file = File.join(Dir.pwd, 'extensions.rb') # if File.exist?(simple_extensions_file) # file_contents = File.read(simple_extensions_file) # MadChatter::Extensions.class_eval file_contents # end # Auto-require User Defined Extension Classes Dir[Dir.pwd + '/extensions/*.rb'].each do |file| require file # MadChatter.message_listeners << Object.const_get('MadChatter').const_get('Extensions').const_get(file).new end end |