Sha256: 7b49a2490fdcc2e9b24761ee2291f7e9180dd49b5b108c1f45bb9a0bb639a290

Contents?: true

Size: 898 Bytes

Versions: 28

Compression:

Stored size: 898 Bytes

Contents

module Racecar
  module RailsConfigFileLoader
    def self.load!
      config_file = "config/racecar.yml"

      begin
        require "rails"
      rescue LoadError
        # Not a Rails application.
      end

      if defined?(Rails)
        $stderr.puts "=> Detected Rails, booting application..."

        require "./config/environment"

        if (Rails.root + config_file).readable?
          Racecar.config.load_file(config_file, Rails.env)
        end

        # In development, write Rails logs to STDOUT. This mirrors what e.g.
        # Unicorn does.
        if Rails.env.development? && defined?(ActiveSupport::Logger)
          console = ActiveSupport::Logger.new($stdout)
          console.formatter = Rails.logger.formatter
          console.level = Rails.logger.level
          Rails.logger.extend(ActiveSupport::Logger.broadcast(console))
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
racecar-0.4.1 lib/racecar/rails_config_file_loader.rb
racecar-0.4.0 lib/racecar/rails_config_file_loader.rb
racecar-0.4.0.beta1 lib/racecar/rails_config_file_loader.rb
racecar-0.3.8 lib/racecar/rails_config_file_loader.rb
racecar-0.3.7 lib/racecar/rails_config_file_loader.rb
racecar-0.3.6 lib/racecar/rails_config_file_loader.rb
racecar-0.3.5 lib/racecar/rails_config_file_loader.rb
racecar-0.3.4 lib/racecar/rails_config_file_loader.rb