W3cubDocs

/Padrino

Module: Padrino

Extended by:
Configuration, Loader

Overview

This module is based on Sequel 4.27.0 sequel-4.27.0/lib/sequel/model/default_inflections.rb

Defined Under Namespace

Modules: Admin, ApplicationSetup, Cache, Configuration, Flash, Generators, Helpers, Inflections, Loader, Mailer, Module, ParamsProtection, PathRouter, Performance, Reloader, Rendering, Routing, Tasks, Utils Classes: Application, AuthenticityToken, Filter, Logger, Mounter, Router, SafeBuffer, Server

Constant Summary collapse

PADRINO_IGNORE_CALLERS =

List of callers in a Padrino application that should be ignored as part of a stack trace.

[
  %r{lib/padrino-.*$},
  %r{/padrino-.*/(lib|bin)},
  %r{/bin/padrino$},
  %r{/sinatra(/(base|main|show_?exceptions))?\.rb$},
  %r{lib/tilt.*\.rb$},
  %r{lib/rack.*\.rb$},
  %r{lib/mongrel.*\.rb$},
  %r{lib/shotgun.*\.rb$},
  %r{bin/shotgun$},
  %r{\(.*\)},
  %r{shoulda/context\.rb$},
  %r{mocha/integration},
  %r{test/unit},
  %r{rake_test_loader\.rb},
  %r{custom_require\.rb$},
  %r{active_support},
  %r{/thor},
  %r{/lib/bundler},
]
VERSION =

The version constant for the current version of Padrino.

'0.14.1.1'
DEFAULT_INFLECTIONS_PROC =

Proc that is instance evaled to create the default inflections for both the model inflector and the inflector extension.

proc do
  plural(/$/, 's')
  plural(/s$/i, 's')
  plural(/(alias|(?:stat|octop|vir|b)us)$/i, '\1es')
  plural(/(buffal|tomat)o$/i, '\1oes')
  plural(/([ti])um$/i, '\1a')
  plural(/sis$/i, 'ses')
  plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
  plural(/(hive)$/i, '\1s')
  plural(/([^aeiouy]|qu)y$/i, '\1ies')
  plural(/(x|ch|ss|sh)$/i, '\1es')
  plural(/(matr|vert|ind)ix|ex$/i, '\1ices')
  plural(/([m|l])ouse$/i, '\1ice')

  singular(/s$/i, '')
  singular(/([ti])a$/i, '\1um')
  singular(/(analy|ba|cri|diagno|parenthe|progno|synop|the)ses$/i, '\1sis')
  singular(/([^f])ves$/i, '\1fe')
  singular(/([h|t]ive)s$/i, '\1')
  singular(/([lr])ves$/i, '\1f')
  singular(/([^aeiouy]|qu)ies$/i, '\1y')
  singular(/(m)ovies$/i, '\1ovie')
  singular(/(x|ch|ss|sh)es$/i, '\1')
  singular(/([m|l])ice$/i, '\1ouse')
  singular(/buses$/i, 'bus')
  singular(/oes$/i, 'o')
  singular(/shoes$/i, 'shoe')
  singular(/(alias|(?:stat|octop|vir|b)us)es$/i, '\1')
  singular(/(vert|ind)ices$/i, '\1ex')
  singular(/matrices$/i, 'matrix')

  irregular('person', 'people')
  irregular('man', 'men')
  irregular('child', 'children')
  irregular('sex', 'sexes')
  irregular('move', 'moves')
  irregular('quiz', 'quizzes')
  irregular('testis', 'testes')

  uncountable(%w(equipment information rice money species series fish sheep news))
end

Class Attribute Summary

Class Method Summary

Instance Method Summary

Methods included from Loader

after_load, before_load, called_from, clear!, dependency_paths, load!, loaded?, precompile_all_routes!, reload!, require_dependencies

Methods included from Configuration

config, configure

Class Attribute Details

.mounted_root(*args) ⇒ String

Returns the root to the mounted apps base directory.

Parameters:

  • args (Array)

Returns:

  • (String) — the root to the mounted apps base directory.

Class Method Details

.add_middleware(router) ⇒ Object

Creates Rack stack with the router added to the middleware chain.

.after_load(&block) ⇒ Object

.application ⇒ Padrino::Router

The resulting rack builder mapping each 'mounted' application.

Returns:

Raises:

  • (ApplicationLoadError) — No applications were mounted.

.before_load(&block) ⇒ Object

.bin(*args) ⇒ Boolean

This method return the correct location of padrino bin or exec it using Kernel#system with the given args.

Examples:

Padrino.bin('start', '-e production')

Parameters:

  • args (Array) — command or commands to execute

Returns:

  • (Boolean)

.bin_gen(*args) ⇒ Object

This method return the correct location of padrino-gen bin or exec it using Kernel#system with the given args.

Examples:

Padrino.bin_gen(:app, name.to_s, "-r=#{destination_root}")

Parameters:

  • args. (Array<String>) — Splat of arguments to pass to padrino-gen.

.cache ⇒ Object

Returns the caching engine.

Examples:

# with: Padrino.cache = Padrino::Cache.new(:File, :dir => /my/cache/path)
Padrino.cache['val'] = 'test'
Padrino.cache['val'] # => 'test'
Padrino.cache.delete('val')
Padrino.cache.clear

.cache=(value) ⇒ Object

Set the caching engine.

Examples:

Padrino.cache = Padrino::Cache.new(:LRUHash) # default choice
Padrino.cache = Padrino::Cache.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # Keeps cached values in file
Padrino.cache = Padrino::Cache.new(:Memcached) # Uses default server at localhost
Padrino.cache = Padrino::Cache.new(:Memcached, :server => '127.0.0.1:11211', :exception_retry_limit => 1)
Padrino.cache = Padrino::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
Padrino.cache = Padrino::Cache.new(:Redis) # Uses default server at localhost
Padrino.cache = Padrino::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
Padrino.cache = Padrino::Cache.new(:Redis, :backend => redis_instance)
Padrino.cache = Padrino::Cache.new(:Mongo) # Uses default server at localhost
Padrino.cache = Padrino::Cache.new(:Mongo, :backend => mongo_client_instance)

# You can manage your cache from anywhere in your app:

Padrino.cache['val'] = 'test'
Padrino.cache['val'] # => 'test'
Padrino.cache.delete('val')
Padrino.cache.clear

Parameters:

  • value — Instance of Moneta store

.clear_middleware! ⇒ Array

Clears all previously configured middlewares.

Returns:

  • (Array) — An empty array

.configure_apps { ... } ⇒ Object

Configure Global Project Settings for mounted apps. These can be overloaded in each individual app's own personal configuration. This can be used like:

Examples:

Padrino.configure_apps do
  enable  :sessions
  disable :raise_errors
end

Yields:

  • The given block will be called to configure each application.

.env ⇒ Symbol

Helper method that return RACK_ENV.

Returns:

  • (Symbol) — The Padrino Environment.

.gem(name, main_module) ⇒ Object

Registers a gem with padrino. This relieves the caller from setting up loadpaths by itself and enables Padrino to look up apps in gem folder.

The name given has to be the proper gem name as given in the gemspec.

Parameters:

  • name (String) — The name of the gem being registered.
  • main_module (Module) — The main module of the gem.

.gems ⇒ Object

.global_configurations ⇒ Object

Stores global configuration blocks.

.insert_mounted_app(mounter) ⇒ Object

Inserts a Mounter object into the mounted applications (avoids duplicates).

Parameters:

.logger ⇒ Padrino::Logger

Examples:

logger.debug "foo"
logger.warn "bar"

Returns:

.logger=(value) ⇒ Object

Set the padrino logger.

Examples:

using ruby default logger
require 'logger'
Padrino.logger = Logger.new(STDOUT)
using ActiveSupport
require 'active_support/buffered_logger'
Padrino.logger = Buffered.new(STDOUT)

Parameters:

  • value (Object) — an object that respond to <<, write, puts, debug, warn etc..

Returns:

  • (Object) — The given value.

.middleware ⇒ Array<Array<Class, Array, Proc>>

A Rack::Builder object that allows to add middlewares in front of all Padrino applications.

Returns:

  • (Array<Array<Class, Array, Proc>>) — The middleware classes.

.modules ⇒ Object

.mount(name, options = {}) ⇒ Object

Mounts a new sub-application onto Padrino project.

Examples:

Padrino.mount("blog_app").to("/blog")

See Also:

  • Padrino::Mounter#new

.mounted_apps ⇒ Array

Returns the mounted padrino applications (MountedApp objects)

Returns:

  • (Array) — the mounted padrino applications (MountedApp objects)

.perf_memusage_command ⇒ Object

.root(*args) ⇒ String

Helper method for file references.

Examples:

# Referencing a file in config called settings.yml
Padrino.root("config", "settings.yml")
# returns PADRINO_ROOT + "/config/setting.yml"

Parameters:

Returns:

  • (String) — The absolute path.

.ruby_command ⇒ String

Return the path to the ruby interpreter taking into account multiple installations and windows extensions.

Returns:

  • (String) — path to ruby bin executable

.run!(options = {}) ⇒ Object

Runs the Padrino apps as a self-hosted server using: thin, mongrel, or WEBrick in that order.

Examples:

Padrino.run! # with these defaults => host: "127.0.0.1", port: "3000", adapter: the first found
Padrino.run!("0.0.0.0", "4000", "mongrel") # use => host: "0.0.0.0", port: "4000", adapter: "mongrel"

.set_encoding ⇒ NilClass

Set Encoding.default_internal and Encoding.default_external to Encoding::UFT_8.

Please note that in 1.9.2 with some template engines like haml you should turn off Encoding.default_internal to prevent problems.

Returns:

  • (NilClass)

See Also:

.use(mw, *args) { ... } ⇒ Object

Convenience method for adding a Middleware to the whole padrino app.

Parameters:

  • m (Class) — The middleware class.
  • args (Array) — The arguments for the middleware.

Yields:

  • The given block will be passed to the initialized middleware.

.version ⇒ String

The current Padrino version.

Returns:

  • (String) — The version number.

Instance Method Details

#RUBY_IGNORE_CALLERS ⇒ Object

Add rubinius (and hopefully other VM implementations) ignore patterns …

© 2010–2019 Padrino
Licensed under the MIT License.
https://www.rubydoc.info/github/padrino/padrino-framework/Padrino