foreman/config/application.rb @ 9ef39dd6
22ae257b | Ohad Levy | require File.expand_path('../boot', __FILE__)
|
|
fb7f0f19 | Ohad Levy | require 'rails/all'
|
|
41402094 | Ohad Levy | ||
a8c74a6b | Lukas Zapletal | if File.exist?(File.expand_path('../../Gemfile.in', __FILE__))
|
|
# If there is a Gemfile.in file, we will not use Bundler but BundlerExt
|
|||
# gem which parses this file and loads all dependencies from the system
|
|||
# rathern then trying to download them from rubygems.org. It always
|
|||
# loads all gemfile groups.
|
|||
require 'bundler_ext'
|
|||
BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :all)
|
|||
else
|
|||
32bf6e02 | Dmitri Dolguikh | # If you have a Gemfile, require the gems listed there
|
|
# Note that :default, :test, :development, :production, and :assets groups
|
|||
# will be included by default (and dependending on the current environment)
|
|||
a8c74a6b | Lukas Zapletal | if defined?(Bundler)
|
|
Class.new Rails::Railtie do
|
|||
console {Foreman.setup_console}
|
|||
end
|
|||
feacea35 | Amos Benari | Bundler.require(*Rails.groups(:assets => %w(development test)))
|
|
d31ea09f | Lukas Zapletal | if SETTINGS[:unattended]
|
|
%w[fog libvirt ovirt vmware gce].each do |group|
|
|||
begin
|
|||
Bundler.require(group)
|
|||
rescue LoadError
|
|||
# ignoring intentionally
|
|||
end
|
|||
end
|
|||
32bf6e02 | Dmitri Dolguikh | end
|
|
22335095 | Ohad Levy | end
|
|
end
|
|||
017e1049 | Ohad Levy | ||
d31ea09f | Lukas Zapletal | SETTINGS[:libvirt] = defined?(::Fog) && defined?(::Libvirt)
|
|
SETTINGS[:ovirt] = defined?(::Fog) && defined?(::OVIRT)
|
|||
SETTINGS[:vmware] = defined?(::Fog) && defined?(::RbVmomi)
|
|||
SETTINGS[:gce] = defined?(::Fog) && defined?(::Google::APIClient::VERSION)
|
|||
SETTINGS[:openstack] = SETTINGS[:rackspace] = SETTINGS[:ec2] = !! defined?(::Fog)
|
|||
32bf6e02 | Dmitri Dolguikh | ||
017e1049 | Ohad Levy | require File.expand_path('../../lib/timed_cached_store.rb', __FILE__)
|
|
require File.expand_path('../../lib/core_extensions', __FILE__)
|
|||
2b8cdec1 | Oved Ourfali | Bundler.require(:jsonp) if SETTINGS[:support_jsonp]
|
|
017e1049 | Ohad Levy | module Foreman
|
|
class Application < Rails::Application
|
|||
2807589b | Corey Osman | # Setup additional routes by loading all routes file from routes directory
|
|
feacea35 | Amos Benari | config.paths["config/routes"] += Dir[Rails.root.join("config/routes/**/*.rb")]
|
|
2807589b | Corey Osman | ||
017e1049 | Ohad Levy | # Settings in config/environments/* take precedence over those specified here.
|
|
# Application configuration should go into files in config/initializers
|
|||
# -- all .rb files in that directory are automatically loaded.
|
|||
# Custom directories with classes and modules you want to be autoloadable.
|
|||
# config.autoload_paths += %W(#{config.root}/extras)
|
|||
40df7dfb | Daniel Lobato | config.autoload_paths += Dir["#{config.root}/lib"]
|
|
e1a1fa81 | Joseph Mitchell Magen | config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
|
40df7dfb | Daniel Lobato | config.autoload_paths += Dir[ Rails.root.join('app', 'models', 'power_manager') ]
|
|
911c9a36 | Joseph Mitchell Magen | config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
|
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
|||
c1452df6 | Marek Hulan | config.autoload_paths += Dir["#{config.root}/app/services"]
|
|
config.autoload_paths += Dir["#{config.root}/app/observers"]
|
|||
config.autoload_paths += Dir["#{config.root}/app/mailers"]
|
|||
911c9a36 | Joseph Mitchell Magen | ||
config.autoload_paths += %W(#{config.root}/app/models/auth_sources)
|
|||
config.autoload_paths += %W(#{config.root}/app/models/compute_resources)
|
|||
config.autoload_paths += %W(#{config.root}/app/models/operatingsystems)
|
|||
config.autoload_paths += %W(#{config.root}/app/models/parameters)
|
|||
config.autoload_paths += %W(#{config.root}/app/models/trends)
|
|||
config.autoload_paths += %W(#{config.root}/app/models/taxonomies)
|
|||
9ef39dd6 | Amos Benari | # Load the following paths only once in development environment
|
|
# this is useful to keep singletons from reloading.
|
|||
if Rails.env.development?
|
|||
config.autoload_once_paths += Dir["#{config.root}/app/services/foreman"]
|
|||
config.autoload_once_paths += Dir["#{config.root}/app/services/menu"]
|
|||
end
|
|||
017e1049 | Ohad Levy | ||
# Only load the plugins named here, in the order given (default is alphabetical).
|
|||
# :all can be used as a placeholder for all plugins not explicitly named.
|
|||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
|||
# Activate observers that should always be running.
|
|||
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
|||
config.active_record.observers = :host_observer
|
|||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|||
# config.time_zone = 'Central Time (US & Canada)'
|
|||
config.time_zone = 'UTC'
|
|||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|||
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|||
# config.i18n.default_locale = :de
|
|||
# Disable fieldWithErrors divs
|
|||
337da65d | Ohad Levy | config.action_view.field_error_proc = Proc.new {|html_tag, instance| "#{html_tag}".html_safe }
|
|
017e1049 | Ohad Levy | ||
# Configure the default encoding used in templates for Ruby 1.9.
|
|||
config.encoding = "utf-8"
|
|||
# Configure sensitive parameters which will be filtered from the log file.
|
|||
dd42df0a | Ohad Levy | config.filter_parameters += [:password, :account_password, :facts, :root_pass, :value, :report, :password_confirmation, :secret]
|
|
017e1049 | Ohad Levy | ||
feacea35 | Amos Benari | # Enable escaping HTML in JSON.
|
|
config.active_support.escape_html_entities_in_json = true
|
|||
# Use SQL instead of Active Record's schema dumper when creating the database.
|
|||
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
|||
# like if you have constraints or database-specific column types
|
|||
# config.active_record.schema_format = :sql
|
|||
# Enforce whitelist mode for mass assignment.
|
|||
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
|||
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
|||
# parameters by using an attr_accessible or attr_protected declaration.
|
|||
config.active_record.whitelist_attributes = false
|
|||
017e1049 | Ohad Levy | ||
# enables in memory cache store with ttl
|
|||
dd42df0a | Ohad Levy | #config.cache_store = TimedCachedStore.new
|
|
88824e07 | Ohad Levy | config.cache_store = :file_store, Rails.root.join("tmp", "cache")
|
|
2b8cdec1 | Oved Ourfali | ||
# enables JSONP support in the Rack middleware
|
|||
config.middleware.use Rack::JSONP if SETTINGS[:support_jsonp]
|
|||
feacea35 | Amos Benari | ||
# Enable the asset pipeline
|
|||
config.assets.enabled = true
|
|||
# Version of your assets, change this if you want to expire all your assets
|
|||
config.assets.version = '1.0'
|
|||
b18c3a35 | Ohad Levy | ||
# Catching Invalid JSON Parse Errors with Rack Middleware
|
|||
config.middleware.insert_before ActionDispatch::ParamsParser, "Middleware::CatchJsonParseErrors"
|
|||
017e1049 | Ohad Levy | end
|
|
46ec8354 | Ohad Levy | ||
def self.setup_console
|
|||
Bundler.require(:console)
|
|||
Wirb.start
|
|||
Hirb.enable
|
|||
rescue => e
|
|||
88824e07 | Ohad Levy | warn "Failed to load console gems, starting anyway"
|
|
46ec8354 | Ohad Levy | ensure
|
|
puts "For some operations a user must be set, try User.current = User.first"
|
|||
end
|
|||
017e1049 | Ohad Levy | end
|