Module: Incline
- Defined in:
- lib/incline.rb,
lib/incline/cli.rb,
lib/incline/log.rb,
lib/incline/engine.rb,
lib/incline/errors.rb,
lib/incline/version.rb,
lib/incline/cli/usage.rb,
lib/incline/recaptcha.rb,
lib/incline/work_path.rb,
lib/incline/cli/errors.rb,
app/models/incline/user.rb,
lib/incline/cli/prepare.rb,
lib/incline/cli/version.rb,
lib/incline/json_logger.rb,
lib/incline/user_manager.rb,
lib/incline/global_status.rb,
lib/incline/number_formats.rb,
lib/incline/auth_engine_base.rb,
lib/incline/cli/helpers/yaml.rb,
lib/incline/date_time_formats.rb,
lib/incline/json_log_formatter.rb,
app/mailers/incline/user_mailer.rb,
app/models/incline/access_group.rb,
app/models/incline/action_group.rb,
app/models/incline/disable_info.rb,
lib/incline/data_tables_request.rb,
app/mailers/incline/contact_form.rb,
app/models/incline/password_reset.rb,
app/models/incline/action_security.rb,
app/models/incline/contact_message.rb,
lib/incline/cli/prepare/config_ssh.rb,
lib/incline/cli/prepare/install_db.rb,
lib/incline/cli/prepare/ssh_copy_id.rb,
lib/incline/cli/prepare/extend_shell.rb,
lib/incline/cli/prepare/install_ruby.rb,
app/models/incline/user_login_history.rb,
lib/incline/cli/prepare/install_rails.rb,
lib/incline/cli/prepare/install_rbenv.rb,
lib/incline/cli/prepare/restart_nginx.rb,
lib/incline/cli/prepare/update_system.rb,
lib/incline/extensions/current_request.rb,
lib/incline/validators/email_validator.rb,
lib/incline/cli/prepare/add_deploy_user.rb,
lib/incline/cli/prepare/install_flytrap.rb,
lib/incline/cli/prepare/install_prereqs.rb,
app/controllers/incline/users_controller.rb,
lib/generators/incline/install_generator.rb,
lib/incline/cli/prepare/config_passenger.rb,
app/models/incline/password_reset_request.rb,
lib/incline/cli/prepare/install_passenger.rb,
app/controllers/incline/contact_controller.rb,
app/controllers/incline/welcome_controller.rb,
lib/incline/cli/prepare/create_nginx_utils.rb,
lib/incline/validators/recaptcha_validator.rb,
lib/incline/validators/safe_name_validator.rb,
app/controllers/incline/security_controller.rb,
app/controllers/incline/sessions_controller.rb,
app/mailers/incline/application_mailer_base.rb,
app/models/incline/access_group_user_member.rb,
lib/incline/validators/ip_address_validator.rb,
app/models/incline/access_group_group_member.rb,
app/controllers/incline/access_test_controller.rb,
app/controllers/incline/application_controller.rb,
app/controllers/incline/access_groups_controller.rb,
app/controllers/incline/password_resets_controller.rb,
app/controllers/incline/account_activations_controller.rb
Overview
require_dependency “incline/application_controller”
Defined Under Namespace
Modules: CliHelpers, DateTimeFormats, Extensions, Helpers, NumberFormats Classes: AccessGroup, AccessGroupGroupMember, AccessGroupUserMember, AccessGroupsController, AccessTestController, AccountActivationsController, ActionGroup, ActionSecurity, ApplicationController, ApplicationMailerBase, AuthEngineBase, CLI, ContactController, ContactForm, ContactMessage, DataTablesRequest, DisableInfo, EmailValidator, Engine, GlobalStatus, InstallGenerator, IpAddressValidator, JsonLogFormatter, JsonLogger, Log, PasswordReset, PasswordResetRequest, PasswordResetsController, Recaptcha, RecaptchaValidator, SafeNameValidator, SecurityController, SessionsController, User, UserLoginHistory, UserMailer, UserManager, UsersController, WelcomeController, WorkPath
Constant Summary collapse
- NotLoggedIn =
An exception used to indicate when a user is not logged in.
Class.new(StandardError)
- NotAuthorized =
An exception used to indicate when a user is not authorized.
Class.new(StandardError)
- InvalidApiCall =
An exception used to indicate an invalid API call.
Class.new(StandardError)
- VERSION =
"0.2.13"
Class Method Summary collapse
- .current_request ⇒ Object
-
.email_config ⇒ Object
Gets the automatic email configuration for the Incline application.
-
.gem_list(*patterns) ⇒ Object
Gets a list of key gems with their versions.
-
.migrate! ⇒ Object
Performs a database migration against the configured database.
-
.route_list ⇒ Object
Gets a list of routes for the current application.
Class Method Details
.current_request ⇒ Object
18 19 20 21 |
# File 'lib/incline/extensions/current_request.rb', line 18 def self.current_request th = ::Thread.current th.thread_variable?(:incline_current_request) ? th.thread_variable_get(:incline_current_request) : nil end |
.email_config ⇒ Object
Gets the automatic email configuration for the Incline application.
The primary configuration should be stored in config/email.yml
. If this file is missing, automatic email configuration is skipped and must be manually specified in your application’s environment initializer (eg - config/environment/production.rb).
test:
...
development:
...
production:
default_url: www.example.com
default_recipient: [email protected]
sender: [email protected]
auth: :plain
start_tls: true
ssl: false
server: smtp.example.com
port: 587
You shouldn’t use an open relay, a warning will be thrown if you do. But you don’t want your login credentials stored in config/email.yml
either. Instead, credentials (if any) should be stored in config/secrets.yml
.
test:
...
development:
...
production:
email:
user: [email protected]
password: super-secret-password
secret_key_base: ...
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/incline.rb', line 44 def self.email_config @email_config ||= begin yaml = Rails.root.join('config', 'email.yml') if File.exist?(yaml) cfg = File.exist?(yaml) ? YAML.load(ERB.new(File.read(yaml)).result) : { } cfg = (cfg[Rails.env] || {}).symbolize_keys cfg = { port: 25, auth: :plain, start_tls: true, ssl: false }.merge(cfg) Incline::Log::warn 'The email configuration is missing the "user" key.' if cfg[:user].blank? Incline::Log::warn 'The email configuration is missing the "password" key.' if cfg[:password].blank? Incline::Log::error 'The email configuration is missing the "server" key.' if cfg[:server].blank? Incline::Log::error 'The email configuration is missing the "sender" key.' if cfg[:sender].blank? Incline::Log::error 'The email configuration is missing the "default_url" key.' if cfg[:default_url].blank? Incline::Log::error 'The email configuration is missing the "default_recipient" key.' if cfg[:default_recipient].blank? def cfg.valid? return false if self[:sender].blank? || self[:server].blank? || self[:default_url].blank? || self[:default_recipient].blank? true end cfg.freeze else Incline::Log::info 'The configuration file "email.yml" does not exist, automatic email configuration disabled.' cfg = {} def cfg.valid? false end cfg.freeze end end end |
.gem_list(*patterns) ⇒ Object
Gets a list of key gems with their versions.
This is useful for informational displays.
Supply one or more patterns for gem names. If you supply none, then the default pattern list is used.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/incline.rb', line 93 def self.gem_list(*patterns) patterns = if patterns.blank? default_gem_patterns elsif patterns.first.is_a?(::TrueClass) default_gem_patterns + patterns[1..-1] else patterns end patterns = patterns.flatten.inject([]) { |m,v| m << v unless m.include?(v); m } gems = Gem::Specification.to_a.sort{ |a,b| a.name <=> b.name } patterns.inject([]) do |ret,pat| gems .select { |g| (pat.is_a?(::String) && g.name == pat) || (pat.is_a?(::Regexp) && g.name =~ pat) } .each do |g| ret << [ g.name, g.version.to_s ] unless ret.find { |(name,_)| name == g.name } end ret end end |
.migrate! ⇒ Object
Performs a database migration against the configured database.
146 147 148 |
# File 'lib/incline.rb', line 146 def self.migrate! ActiveRecord::Migrator.migrate File.('../../db/migrate', __FILE__), nil end |
.route_list ⇒ Object
Gets a list of routes for the current application.
The returned list contains hashes with :engine, :controller, :action, :name, :verb, and :path keys.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/incline.rb', line 122 def self.route_list @route_list ||= begin require 'action_dispatch/routing/inspector' get_routes(Rails.application.routes.routes).sort do |a,b| if a[:engine] == b[:engine] if a[:controller] == b[:controller] if a[:action] == b[:action] a[:path] <=> b[:path] else a[:action] <=> b[:action] end else a[:controller] <=> b[:controller] end else a[:engine] <=> b[:engine] end end end end |