Module: Hanami
- Defined in:
- lib/hanami.rb,
lib/hanami/app.rb,
lib/hanami/cli.rb,
lib/hanami/env.rb,
lib/hanami/root.rb,
lib/hanami/routes.rb,
lib/hanami/server.rb,
lib/hanami/static.rb,
lib/hanami/version.rb,
lib/hanami/welcome.rb,
lib/hanami/cli_base.rb,
lib/hanami/hanamirc.rb,
lib/hanami/components.rb,
lib/hanami/middleware.rb,
lib/hanami/application.rb,
lib/hanami/environment.rb,
lib/hanami/rake_helper.rb,
lib/hanami/assets/asset.rb,
lib/hanami/assets/static.rb,
lib/hanami/commands/apps.rb,
lib/hanami/config/logger.rb,
lib/hanami/config/mapper.rb,
lib/hanami/config/routes.rb,
lib/hanami/configuration.rb,
lib/hanami/views/default.rb,
lib/hanami/config/cookies.rb,
lib/hanami/commands/routes.rb,
lib/hanami/commands/server.rb,
lib/hanami/config/security.rb,
lib/hanami/config/sessions.rb,
lib/hanami/routing/default.rb,
lib/hanami/views/null_view.rb,
lib/hanami/application_name.rb,
lib/hanami/commands/command.rb,
lib/hanami/commands/console.rb,
lib/hanami/commands/db/drop.rb,
lib/hanami/commands/new/app.rb,
lib/hanami/rendering_policy.rb,
lib/hanami/commands/db/apply.rb,
lib/hanami/config/load_paths.rb,
lib/hanami/commands/db/create.rb,
lib/hanami/cli_sub_commands/db.rb,
lib/hanami/commands/db/console.rb,
lib/hanami/commands/db/migrate.rb,
lib/hanami/commands/db/prepare.rb,
lib/hanami/commands/db/version.rb,
lib/hanami/components/app/view.rb,
lib/hanami/components/component.rb,
lib/hanami/generators/generator.rb,
lib/hanami/application_namespace.rb,
lib/hanami/commands/generate/app.rb,
lib/hanami/commands/new/abstract.rb,
lib/hanami/components/app/assets.rb,
lib/hanami/components/app/logger.rb,
lib/hanami/components/app/routes.rb,
lib/hanami/components/components.rb,
lib/hanami/action/csrf_protection.rb,
lib/hanami/action/routing_helpers.rb,
lib/hanami/commands/new/container.rb,
lib/hanami/generators/generatable.rb,
lib/hanami/cli_sub_commands/assets.rb,
lib/hanami/commands/generate/model.rb,
lib/hanami/cli_sub_commands/destroy.rb,
lib/hanami/commands/generate/action.rb,
lib/hanami/commands/generate/mailer.rb,
lib/hanami/application_configuration.rb,
lib/hanami/cli_sub_commands/generate.rb,
lib/hanami/components/app/controller.rb,
lib/hanami/generators/test_framework.rb,
lib/hanami/commands/assets/precompile.rb,
lib/hanami/commands/generate/abstract.rb,
lib/hanami/generators/database_config.rb,
lib/hanami/generators/template_engine.rb,
lib/hanami/commands/generate/migration.rb,
lib/hanami/components/routes_inspector.rb,
lib/hanami/views/default_template_finder.rb,
lib/hanami/commands/generate/secret_token.rb,
lib/hanami/config/framework_configuration.rb,
lib/hanami/environment_application_configurations.rb
Overview
Copyright notice
This file contains a method copied from Rack::Static (rack gem).
Rack - Copyright © 2007 Christian Neukirchen Released under the MIT License
Defined Under Namespace
Modules: Action, Assets, CliBase, Commands, Components, Config, Generators, Mailer, Routing, Version, Views Classes: App, Application, ApplicationConfiguration, ApplicationName, ApplicationNamespace, Cli, CliSubCommands, Configuration, Env, Environment, EnvironmentApplicationConfigurations, Hanamirc, Middleware, RakeHelper, RenderingPolicy, Routes, Server, Static, Welcome
Constant Summary collapse
- DEFAULT_PUBLIC_DIRECTORY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'public'.freeze
- VERSION =
Defines the full version
Version.version
Class Method Summary collapse
-
.app ⇒ Hanami::App
private
Main application that mounts many Rack and/or Hanami applications.
-
.boot ⇒ Object
private
Boot your Hanami project.
-
.configuration ⇒ Hanami::Configuration
private
Hanami configuration.
-
.configure(&blk) ⇒ Object
Configure Hanami project.
-
.env ⇒ String
Return the current environment.
-
.env?(*names) ⇒ TrueClass, FalseClass
Check to see if specified environment(s) matches the current environment.
-
.environment ⇒ Hanami::Environment
private
Current environment.
-
.public_directory ⇒ Pathname
private
Project public directory.
-
.root ⇒ Pathname
Return root of the project (top level directory).
Class Method Details
.app ⇒ Hanami::App
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Main application that mounts many Rack and/or Hanami applications.
This is used as integration point for:
* `config.ru` (`run Hanami.app`)
* Feature tests (`Capybara.app = Hanami.app`)
It lazily loads your Hanami project, in case it wasn’t booted on before. This is the case when ‘hanami server` isn’t invoked, but we use different ways to run the project (eg. ‘rackup`).
115 116 117 118 |
# File 'lib/hanami.rb', line 115 def self.app boot App.new(configuration, environment) end |
.boot ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Boot your Hanami project
NOTE: In case this is invoked many times, it guarantees that the boot
process happens only once.
NOTE: There is no reason to cache the result with ‘@_booted`, because it
already caches it internally.
NOTE: This MUST NOT be wrapped by a Mutex, because it would cause a deadlock.
92 93 94 |
# File 'lib/hanami.rb', line 92 def self.boot Components.resolve('all') end |
.configuration ⇒ Hanami::Configuration
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hanami configuration
73 74 75 76 77 78 |
# File 'lib/hanami.rb', line 73 def self.configuration @_mutex.synchronize do raise "Hanami not configured" unless defined?(@_configuration) @_configuration end end |
.configure(&blk) ⇒ Object
Configure Hanami project
Please note that the code for this method is generated by ‘hanami new`.
59 60 61 62 63 |
# File 'lib/hanami.rb', line 59 def self.configure(&blk) @_mutex.synchronize do @_configuration = Hanami::Configuration.new(&blk) end end |
.env ⇒ String
Return the current environment
155 156 157 |
# File 'lib/hanami.rb', line 155 def self.env environment.environment end |
.env?(*names) ⇒ TrueClass, FalseClass
Check to see if specified environment(s) matches the current environment.
If multiple names are given, it returns true, if at least one of them matches the current environment.
183 184 185 |
# File 'lib/hanami.rb', line 183 def self.env?(*names) environment.environment?(*names) end |
.environment ⇒ Hanami::Environment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Current environment
193 194 195 196 197 |
# File 'lib/hanami.rb', line 193 def self.environment Components.resolved('environment') do Environment.new end end |
.public_directory ⇒ Pathname
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Project public directory
141 142 143 |
# File 'lib/hanami.rb', line 141 def self.public_directory root.join(DEFAULT_PUBLIC_DIRECTORY) end |
.root ⇒ Pathname
Return root of the project (top level directory).
128 129 130 |
# File 'lib/hanami.rb', line 128 def self.root environment.root end |