Sha256: cc318544f0e0387ebbbba55fef16f2a479d507e56b6443c88934a8198c785e94

Contents?: true

Size: 1.4 KB

Versions: 21

Compression:

Stored size: 1.4 KB

Contents

# Copyright (c) 2010-2011, Diaspora Inc.  This file is
# licensed under the Affero General Public License version 3 or later.  See
# the COPYRIGHT file.

module EnvironmentConfiguration

  def self.heroku?
    ENV['HEROKU']
  end

  def self.secret_token_initializer_is_not_present?
    !File.exists?( Rails.root.join('config', 'initializers', 'secret_token.rb'))
  end

  def self.prevent_fetching_community_spotlight?
    return true if heroku?
    !ActiveRecord::Base.connection.table_exists?('projects') || Rails.env == 'test'
  end

  def self.cache_git_version?
    !self.heroku?
  end

  def self.ensure_secret_token!
    if heroku?
      puts 'heroku app detected; using session secret from config vars...'
      Rails.application.config.secret_token = ENV['SECRET_TOKEN'] 
    elsif secret_token_initializer_is_not_present?
      `rake generate:secret_token`
      require  Rails.root.join('config', 'initializers', 'secret_token.rb')
    else
      #do nothing
    end
  end

  def self.enforce_ssl?
    return false unless Rails.env == 'production'
    return false if ENV['NO_SSL'] 
    return false if AppConfig[:circumvent_ssl_requirement].present?
    true
  end

  def self.ca_cert_file_location
    if self.heroku?
      "/usr/lib/ssl/certs/ca-certificates.crt"
    else
      AppConfig[:ca_file]
    end
  end

  def self.using_new_relic?
    defined?(NewRelic) && AppConfig['NEW_RELIC_LICENSE_KEY'].present?
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
voluntary-0.7.1 lib/environment_configuration.rb
voluntary-0.7.0 lib/environment_configuration.rb
voluntary-0.6.0 lib/environment_configuration.rb
voluntary-0.5.2 lib/environment_configuration.rb
voluntary-0.5.1 lib/environment_configuration.rb
voluntary-0.5.0 lib/environment_configuration.rb
voluntary-0.4.0 lib/environment_configuration.rb
voluntary-0.3.0 lib/environment_configuration.rb
voluntary-0.2.4 lib/environment_configuration.rb
voluntary-0.2.3 lib/environment_configuration.rb
voluntary-0.2.2 lib/environment_configuration.rb
voluntary-0.2.1 lib/environment_configuration.rb
voluntary-0.2.0 lib/environment_configuration.rb
voluntary-0.1.0 lib/environment_configuration.rb
voluntary-0.1.0.rc4 lib/environment_configuration.rb
voluntary-0.1.0.rc3 lib/environment_configuration.rb
voluntary-0.1.0.rc2 lib/environment_configuration.rb
voluntary-0.1.0.rc1 lib/environment_configuration.rb
voluntary-0.0.3 lib/environment_configuration.rb
voluntary-0.0.2 lib/environment_configuration.rb