Sha256: 2106aadda35ba87da4d5acc03818779ec3a6569a353f17dc30e71744ee865ce9

Contents?: true

Size: 1.5 KB

Versions: 8

Compression:

Stored size: 1.5 KB

Contents

module Harness
  class Railtie < ::Rails::Railtie
    config.harness = Harness.config

    rake_tasks do
      load "harness/tasks.rake"
    end

    initializer "harness.adapter" do |app|
      case Rails.env
      when 'development'
        app.config.harness.adapter = :null
      when 'test'
        app.config.harness.adapter = :null
      else
        app.config.harness.adapter = :librato
      end
    end

    initializer "harness.logger" do |app|
      Harness.logger = Rails.logger
    end

    initializer "harness.redis" do 
      if existing_url = ENV['REDISTOGO_URL'] || ENV['REDIS_URL']
        Harness.redis ||= Redis::Namespace.new('harness', :redis => Redis.connect(:url => existing_url))
      else
        Harness.redis ||= Redis::Namespace.new('harness', :redis => Redis.connect(:host => 'localhost', :port => '6379'))
      end
    end

    initializer "harness.queue" do
      Harness.config.queue = Harness::SyncronousQueue
    end

    initializer "harness.queue.production" do |app|
      use_real_queue = Rails.env != 'development' && Rails.env != 'test'

      if defined?(Resque::Job) && use_real_queue
        require 'harness/queues/resque_queue'
        Harness.config.queue = :resque
      elsif defined?(Sidekiq::Worker) && use_real_queue
        require 'harness/queues/sidekiq_queue'
        Harness.config.queue = :sidekiq
      end
    end

    initializer "harness.sidekiq" do |app|
      if defined? Sidekiq::Worker
        require 'harness/integration/sidekiq'
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
harness-0.2.14 lib/harness/railtie.rb
harness-0.2.13 lib/harness/railtie.rb
harness-0.2.12 lib/harness/railtie.rb
harness-0.2.11 lib/harness/railtie.rb
harness-0.2.10 lib/harness/railtie.rb
harness-0.2.9 lib/harness/railtie.rb
harness-0.2.8 lib/harness/railtie.rb
harness-0.2.7 lib/harness/railtie.rb