class Incline::Engine
The Incline
engine.
Public Class Methods
Configures the application to include Incline
assets.
# File lib/incline/engine.rb, line 123 def self.add_assets_to(app) # Add our assets app.config.assets.precompile += %w( incline/barcode-B.svg ) end
Configures the application to include Incline
helpers.
# File lib/incline/engine.rb, line 114 def self.add_helpers_to(app) # add our helper path to the search path. path = File.expand_path('../../../app/helpers', __FILE__) app.helpers_paths << path unless app.helpers_paths.include?(path) app.config.paths['app/helpers'] << path unless app.config.paths['app/helpers'].include?(path) end
Configures the application to use Incline
migrations as opposed to copying the Incline
migrations locally.
# File lib/incline/engine.rb, line 181 def self.add_migrations_to(app) unless app.root.to_s.match root.to_s migrate_path = File.expand_path('../../../db/migrate', __FILE__) # this should be all that's required. app.config.paths['db/migrate'] << migrate_path unless app.config.paths['db/migrate'].include?(migrate_path) # however this gets set before the config is updated. # so we'll add it here as well to ensure it gets set correctly. ActiveRecord::Tasks::DatabaseTasks.migrations_paths << migrate_path unless ActiveRecord::Tasks::DatabaseTasks.migrations_paths.include?(migrate_path) end end
Configures the application to use Incline
seeds.
# File lib/incline/engine.rb, line 196 def self.add_seeds_to(app) seeds_path = File.expand_path('../../../db/seeds.rb', __FILE__) # Once again, this should be all that's required. app.config.paths['db/seeds.rb'] << seeds_path unless app.config.paths['db/seeds.rb'].include?(seeds_path) end
Configures the application to use the Incline
email configuration.
If the config/email.yml
file is not configured correctly this does nothing.
# File lib/incline/engine.rb, line 134 def self.apply_email_config_to(app) if Incline::email_config.valid? app.config.action_mailer.default_url_options = { host: Incline::email_config[:default_url] } app.config.action_mailer.default_options = { from: Incline::email_config[:sender], to: Incline::email_config[:default_recipient] } app.config.action_mailer.smtp_settings = { address: Incline::email_config[:server], port: Incline::email_config[:port], user_name: Incline::email_config[:user], password: Incline::email_config[:password], authentication: Incline::email_config[:user].blank? ? nil : Incline::email_config[:auth], enable_start_tls_auto: Incline::email_config[:start_tls], ssl: Incline::email_config[:ssl], openssl_verify_mode: 'none' } if Rails.env.test? app.config.action_mailer.delivery_method = :test else app.config.action_mailer.delivery_method = :smtp app.config.action_mailer.raise_delivery_errors = true app.config.perform_deliveries = true end end end
Configures generators so they can use our templates and so they don't create some redundant files.
# File lib/incline/engine.rb, line 205 def self.configure_generators_for(app) app.config.app_generators.templates << File.expand_path('../../templates', __FILE__) app.config.generators do |g| g.scaffold_stylesheet false # we depend on the application.css, no need for a scaffold.css g.stylesheets false # no need for a stylesheet for every controller. g.javascripts false # no need for a javascript file for every controller. end end
Configures the application to send messages when unhandled exceptions occur in production mode.
# File lib/incline/engine.rb, line 165 def self.notify_on_exceptions_from(app) # Send emails for unhandled exceptions. if Rails.env.production? app.config.middleware.use( ExceptionNotification::Rack, email: { email_prefix: '[Incline ' + Rails.application.app_info + ']', sender_address: Incline::email_config[:sender], exception_recipients: [ Incline::email_config[:exception_recipient] || Incline::email_config[:default_recipient] ] } ) end end
Sets the date formats to default to US format (ie - m/d/y)
# File lib/incline/engine.rb, line 103 def self.set_date_formats # add American formats as default. Time::DATE_FORMATS[:default] = '%m/%d/%Y %H:%M' Time::DATE_FORMATS[:date] = '%m/%d/%y' Date::DATE_FORMATS[:default] = '%m/%d/%Y' Date::DATE_FORMATS[:date] = '%m/%d/%y' end
Public Instance Methods
If you want to report valid permissions on access denied, set this attribute to true.
# File lib/incline/engine.rb, line 69 cattr_accessor :show_valid_permissions