Sha256: 3629ac9eefd2c14655808b92879f2484b48da9c4117eb80b776b04b5ece26c54

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require 'rails'

module Ampere
  class Railtie < Rails::Railtie
    if config.respond_to?(:app_generators) then
      config.app_generators.orm :ampere, :migration => false
    else
      config.generators.orm :ampere, :migration => false
    end
    
    console do
      Ampere.connect
      puts "[ampere] Connected."
    end
    
    initializer 'railtie.initialize_redis_connection' do |app|
      config_file = Rails.root.join("config", "ampere.yml")
      
      options = {
        'development' => {
          'host' => '127.0.0.1',
          'port' => 6379
        },
        'test' => {
          'host' => '127.0.0.1',
          'port' => 6379
        },
        'production' => {
          'host' => '127.0.0.1',
          'port' => 6379
        },
      }
      
      if config_file.file?
        options = YAML.load_file(config_file)
      end
      
      Rails.logger.info "[ampere] Initializing redis connection redis://#{options[Rails.env]['host']}:#{options[Rails.env]['port']}"
      
      Ampere.connect options[Rails.env]
    end
    
    rake_tasks do
      load File.join(File.dirname(__FILE__), '..', 'rails', 'tasks', 'ampere.rake')
    end
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ampere-1.2.3 lib/rails/railtie.rb
ampere-1.2.2 lib/rails/railtie.rb
ampere-1.2.1 lib/rails/railtie.rb
ampere-1.2.0 lib/rails/railtie.rb