Module: Hanami

Defined in:
lib/hanami.rb,
lib/hanami/cli.rb,
lib/hanami/root.rb,
lib/hanami/loader.rb,
lib/hanami/routes.rb,
lib/hanami/static.rb,
lib/hanami/version.rb,
lib/hanami/welcome.rb,
lib/hanami/hanamirc.rb,
lib/hanami/container.rb,
lib/hanami/middleware.rb,
lib/hanami/application.rb,
lib/hanami/environment.rb,
lib/hanami/rake_helper.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/config/mapping.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/console.rb,
lib/hanami/commands/db/drop.rb,
lib/hanami/commands/new/app.rb,
lib/hanami/config/configure.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/commands/db/abstract.rb,
lib/hanami/generators/generator.rb,
lib/hanami/commands/generate/app.rb,
lib/hanami/commands/new/abstract.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/cli_sub_commands/generate.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/commands/generate/migration.rb,
lib/hanami/views/default_template_finder.rb,
lib/hanami/config/framework_configuration.rb

Overview

A complete web framework for Ruby

See Also:

Since:

  • 0.1.0

Defined Under Namespace

Modules: Action, Commands, Config, Generators, Mailer, Routing, Views Classes: Application, ApplicationName, Cli, CliSubCommands, Configuration, Container, Environment, Hanamirc, Loader, Middleware, RakeHelper, RenderingPolicy, Routes, Static, Welcome

Constant Summary collapse

DEFAULT_PUBLIC_DIRECTORY =

Since:

  • 0.1.0

'public'.freeze
VERSION =

Defines the version

Since:

  • 0.1.0

'0.7.3'.freeze

Class Method Summary collapse

Class Method Details

.envString

Return the current environment

Examples:

Hanami.env => "development"

Returns:

  • (String)

    the current environment

See Also:

Since:

  • 0.3.1



40
41
42
# File 'lib/hanami.rb', line 40

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.

Examples:

Single name

puts ENV['HANAMI_ENV'] # => "development"

Hanami.env?(:development)  # => true
Hanami.env?('development') # => true

Hanami.env?(:production)   # => false

Multiple names

puts ENV['HANAMI_ENV'] # => "development"

Hanami.env?(:development, :test)   # => true
Hanami.env?(:production, :staging) # => false

Returns:

  • (TrueClass, FalseClass)

    the result of the check

See Also:

Since:

  • 0.3.1



68
69
70
# File 'lib/hanami.rb', line 68

def self.env?(*names)
  environment.environment?(*names)
end

.environmentHanami::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.

Return environment

Returns:

Since:

  • 0.3.2



78
79
80
# File 'lib/hanami.rb', line 78

def self.environment
  Environment.new
end

.public_directoryObject

Since:

  • 0.1.0



26
27
28
# File 'lib/hanami.rb', line 26

def self.public_directory
  root.join(DEFAULT_PUBLIC_DIRECTORY)
end

.rootPathname

Return root of the project (top level directory).

Examples:

Hanami.root # => #<Pathname:/Users/luca/Code/bookshelf>

Returns:

  • (Pathname)

    root path

Since:

  • 0.3.2



22
23
24
# File 'lib/hanami.rb', line 22

def self.root
  environment.root
end