Module: Padrino    Extended by: 
Configuration, Loader
   Overview This module is based on Sequel 5.4.0 sequel-5.4.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.15.0' 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 
   .mounted_root(*args) ⇒ String  The root to the mounted apps base directory.     Class Method Summary     .add_middleware(router) ⇒ Object  Creates Rack stack with the router added to the middleware chain.    .after_load(&block) ⇒ Object   .application ⇒ Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Router  The resulting rack builder mapping each 'mounted' application.    .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.    .bin_gen(*args) ⇒ Object  This method return the correct location of padrino-gen bin or exec it using Kernel#system with the given args.    .cache ⇒ Object  Returns the caching engine.    .cache=(value) ⇒ Object  Set the caching engine.    .clear_middleware! ⇒ Array  Clears all previously configured middlewares.    .configure_apps { ... } ⇒ Object  Configure Global Project Settings for mounted apps.    .env ⇒ Symbol  Helper method that return RACK_ENV.    .gem(name, main_module) ⇒ Object  Registers a gem with padrino.    .gems ⇒ Object   .global_configurations ⇒ Object  Stores global configuration blocks.    .insert_mounted_app(mounter) ⇒ Object  Inserts a Mounter object into the mounted applications (avoids duplicates).    .logger ⇒ Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger   .logger=(value) ⇒ Object  Set the padrino logger.    .middleware ⇒ Array<Array<Class, Array, Proc>>  A Rack8b7c:f320:99b9:690f:4595:cd17:293a:c069uilder object that allows to add middlewares in front of all Padrino applications.    .modules ⇒ Object   .mount(name, options = {}) ⇒ Object  Mounts a new sub-application onto Padrino project.    .mounted_apps ⇒ Array  The mounted padrino applications (MountedApp objects).    .perf_memusage_command ⇒ Object   .root(*args) ⇒ String  Helper method for file references.    .ruby_command ⇒ String  Return the path to the ruby interpreter taking into account multiple installations and windows extensions.    .run!(options = {}) ⇒ Object  Runs the Padrino apps as a self-hosted server using: thin, mongrel, or WEBrick in that order.    .set_encoding ⇒ NilClass  Set Encoding.default_internal and Encoding.default_external to Encoding8b7c:f320:99b9:690f:4595:cd17:293a:c069UFT_8.    .use(mw, *args) { ... } ⇒ Object  Convenience method for adding a Middleware to the whole padrino app.    .version ⇒ String  The current Padrino version.     Instance Method Summary     #RUBY_IGNORE_CALLERS ⇒ Object  Add rubinius (and hopefully other VM implementations) ignore patterns …    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 ⇒ Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Router  The resulting rack builder mapping each 'mounted' application.  Returns:   (Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Router) —  The router for the application.    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 = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.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 = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:LRUHash) # default choice
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:File, :dir => Padrino.root('tmp', app_name.to_s, 'cache')) # Keeps cached values in file
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Memcached) # Uses default server at localhost
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Memcached, :server => '7269639803:11211', :exception_retry_limit => 1)
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Memcached, :backend => memcached_or_dalli_instance)
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Redis) # Uses default server at localhost
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Redis, :host => '7269639803', :port => 6379, :db => 0)
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Redis, :backend => redis_instance)
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.new(:Mongo) # Uses default server at localhost
Padrino.cache = Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069he.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:   mounter (Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Mounter)       .logger ⇒ Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger    Examples: logger.debug "foo"
logger.warn "bar"  Returns:   (Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger)       .logger=(value) ⇒ Object  Set the padrino logger.   Examples:  using ruby default logger  require 'logger'
new_logger = 8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger.new(STDOUT)
new_logger.extend(Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger8b7c:f320:99b9:690f:4595:cd17:293a:c069xtensions)
Padrino.logger = new_logger  using ActiveSupport  require 'active_support/buffered_logger'
Padrino.logger = Buffered.new(STDOUT)  using custom logger class  require 'logger'
class CustomLogger < 8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger
  include Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Logger8b7c:f320:99b9:690f:4595:cd17:293a:c069xtensions
end
Padrino.logger = CustomLogger.new(STDOUT)  Parameters:   value (Object) —  an object that respond to <<, write, puts, debug, warn, devel, etc..    Returns:   (Object) —  The given value.        .middleware ⇒ Array<Array<Class, Array, Proc>>  A Rack8b7c:f320:99b9:690f:4595:cd17:293a:c069uilder 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:  Padrino8b7c:f320:99b9:690f:4595:cd17:293a:c069Mounter#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:   args (Array<String>) —  The directories to join to PADRINO_ROOT.    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: "7269639803", port: "3000", adapter: the first found
Padrino.run!("7269639803", "4000", "mongrel") # use => host: "7269639803", port: "4000", adapter: "mongrel"      .set_encoding ⇒ NilClass  Set Encoding.default_internal and Encoding.default_external to Encoding8b7c:f320:99b9:690f:4595:cd17:293a:c069UFT_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:  https://github.com/rtomayko/tilt/issues/75      .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 … 

    
{'path': 'public/docs/padrino/padrino.html', 'source': 'DevDocs.IO'}