Class: Incline::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- Incline::Engine
- Defined in:
- lib/incline/engine.rb
Overview
The Incline engine.
Class Method Summary collapse
-
.add_assets_to(app) ⇒ Object
Configures the application to include Incline assets.
-
.add_helpers_to(app) ⇒ Object
Configures the application to include Incline helpers.
-
.add_migrations_to(app) ⇒ Object
Configures the application to use Incline migrations as opposed to copying the Incline migrations locally.
-
.add_seeds_to(app) ⇒ Object
Configures the application to use Incline seeds.
-
.apply_email_config_to(app) ⇒ Object
Configures the application to use the Incline email configuration.
-
.configure_generators_for(app) ⇒ Object
Configures generators so they can use our templates and so they don’t create some redundant files.
-
.notify_on_exceptions_from(app) ⇒ Object
Configures the application to send messages when unhandled exceptions occur in production mode.
-
.set_date_formats ⇒ Object
Sets the date formats to default to US format (ie - m/d/y).
Instance Method Summary collapse
-
#show_valid_permissions ⇒ Object
If you want to report valid permissions on access denied, set this attribute to true.
Class Method Details
.add_assets_to(app) ⇒ Object
Configures the application to include Incline assets.
121 122 123 124 125 126 |
# File 'lib/incline/engine.rb', line 121 def self.add_assets_to(app) # Add our assets app.config.assets.precompile += %w( incline/barcode-B.svg ) end |
.add_helpers_to(app) ⇒ Object
Configures the application to include Incline helpers.
112 113 114 115 116 117 |
# File 'lib/incline/engine.rb', line 112 def self.add_helpers_to(app) # add our helper path to the search path. path = File.('../../../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 |
.add_migrations_to(app) ⇒ Object
Configures the application to use Incline migrations as opposed to copying the Incline migrations locally.
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/incline/engine.rb', line 179 def self.add_migrations_to(app) unless app.root.to_s.match root.to_s migrate_path = File.('../../../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 |
.add_seeds_to(app) ⇒ Object
Configures the application to use Incline seeds.
194 195 196 197 198 199 |
# File 'lib/incline/engine.rb', line 194 def self.add_seeds_to(app) seeds_path = File.('../../../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 |
.apply_email_config_to(app) ⇒ Object
Configures the application to use the Incline email configuration.
If the config/email.yml file is not configured correctly this does nothing.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/incline/engine.rb', line 132 def self.apply_email_config_to(app) if Incline::email_config.valid? app.config.action_mailer. = { host: Incline::email_config[:default_url] } app.config.action_mailer. = { 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 |
.configure_generators_for(app) ⇒ Object
Configures generators so they can use our templates and so they don’t create some redundant files.
203 204 205 206 207 208 209 210 |
# File 'lib/incline/engine.rb', line 203 def self.configure_generators_for(app) app.config.app_generators.templates << File.('../../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 |
.notify_on_exceptions_from(app) ⇒ Object
Configures the application to send messages when unhandled exceptions occur in production mode.
163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/incline/engine.rb', line 163 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 |
.set_date_formats ⇒ Object
Sets the date formats to default to US format (ie - m/d/y)
101 102 103 104 105 106 107 108 |
# File 'lib/incline/engine.rb', line 101 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 |
Instance Method Details
#show_valid_permissions ⇒ Object
If you want to report valid permissions on access denied, set this attribute to true.
67 |
# File 'lib/incline/engine.rb', line 67 cattr_accessor :show_valid_permissions |