Sha256: 4d9c8e4f4b80c06ce125643cfa93e2ce4bab7c426a5c61c5636d09d1835b6a4f

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module MadChatter
  
  def self.simple_extensions
    @@simple_extensions ||= []
  end
  
  def self.extension_classes
    @@extension_classes ||= []
  end
  
  module Config
    class << self
      
      def init
        config = MadChatter::Config.initialize_config
        MadChatter::Config.initialize_extensions
        return config
      end
    
      def initialize_config
        config_file = File.join(Dir.pwd, 'config.yml')
      
        unless File.exist?(config_file)
          abort 'Could not find Mad Chatter config.yml file'
        end
        
        config = YAML::load(File.open(config_file))
        defaults = {
          'websocket_backend' => 'websocket-rack',
          'websocket_port' => 8100,
        }
        @config = defaults.merge!(config)
      end

      def initialize_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.load_simple_extensions(file_contents)
        end
        
        # Dir[Dir.pwd + '/extensions/*.rb'].each do |file|
        #   require file
        # end
      end
      
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mad_chatter-0.2.1 lib/mad_chatter/config.rb
mad_chatter-0.2.0 lib/mad_chatter/config.rb