Module: Tennpipes
- Extended by:
- Loader
- Defined in:
- lib/tennpipes-base/version.rb,
lib/tennpipes-base.rb,
lib/tennpipes-base/tasks.rb,
lib/tennpipes-base/caller.rb,
lib/tennpipes-base/filter.rb,
lib/tennpipes-base/loader.rb,
lib/tennpipes-base/logger.rb,
lib/tennpipes-base/module.rb,
lib/tennpipes-base/router.rb,
lib/tennpipes-base/server.rb,
lib/tennpipes-base/command.rb,
lib/tennpipes-base/mounter.rb,
lib/tennpipes-base/cli/base.rb,
lib/tennpipes-base/reloader.rb,
lib/tennpipes-base/application.rb,
lib/tennpipes-base/cli/adapter.rb,
lib/tennpipes-base/path_router.rb,
lib/tennpipes-base/cli/launcher.rb,
lib/tennpipes-base/reloader/rack.rb,
lib/tennpipes-base/reloader/storage.rb,
lib/tennpipes-base/application/flash.rb,
lib/tennpipes-base/path_router/route.rb,
lib/tennpipes-base/application/routing.rb,
lib/tennpipes-base/path_router/matcher.rb,
lib/tennpipes-base/path_router/compiler.rb,
lib/tennpipes-base/path_router/error_handler.rb,
lib/tennpipes-base/application/show_exceptions.rb,
lib/tennpipes-base/application/application_setup.rb,
lib/tennpipes-base/application/params_protection.rb,
lib/tennpipes-base/application/authenticity_token.rb
Overview
Manages current Tennpipes version for use in gem generation.
We put this in a separate file so you can get tennpipes version without include full tennpipes core.
Defined Under Namespace
Modules: ApplicationSetup, Cli, Flash, Loader, Module, ParamsProtection, PathRouter, Reloader, Routing, Tasks Classes: Application, ApplicationLoadError, AuthenticityToken, Filter, Logger, Mounter, Router, Server, ShowExceptions
Constant Summary collapse
- TENNPIPES_IGNORE_CALLERS =
List of callers in a Tennpipes application that should be ignored as part of a stack trace.
[ %r{lib/tennpipes-.*$}, %r{/tennpipes-.*/(lib|bin)}, %r{/bin/tennpipes$}, %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} ]
- VERSION =
The version constant for the current version of Tennpipes.
'3.6.6'
Class Attribute Summary collapse
-
.mounted_root(*args) ⇒ String
The root to the mounted apps base directory.
Class Method Summary collapse
-
.add_middleware(router) ⇒ Object
Creates Rack stack with the router added to the middleware chain.
-
.application ⇒ Tennpipes::Router
The resulting rack builder mapping each ‘mounted’ application.
-
.bin(*args) ⇒ Boolean
This method return the correct location of tennpipes bin or exec it using Kernel#system with the given args.
-
.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 tennpipes.
- .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 ⇒ Tennpipes::Logger
-
.logger=(value) ⇒ Object
Set the tennpipes logger.
-
.middleware ⇒ Array<Array<Class, Array, Proc>>
A Rack::Builder object that allows to add middlewares in front of all Tennpipes applications.
- .modules ⇒ Object
-
.mount(name, options = {}) ⇒ Object
Mounts a new sub-application onto Tennpipes project.
-
.mounted_apps ⇒ Array
The mounted tennpipes applications (MountedApp objects).
-
.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 Tennpipes apps as a self-hosted server using: thin, mongrel, or WEBrick in that order.
-
.set_encoding ⇒ NilClass
Set
Encoding.default_internal
andEncoding.default_external
toEncoding::UFT_8
. -
.use(mw, *args) { ... } ⇒ Object
Convenience method for adding a Middleware to the whole tennpipes app.
-
.version ⇒ String
The current Tennpipes version.
Instance Method Summary collapse
-
#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
Class Attribute Details
Class Method Details
.add_middleware(router) ⇒ Object
Creates Rack stack with the router added to the middleware chain.
120 121 122 123 124 125 |
# File 'lib/tennpipes-base.rb', line 120 def add_middleware(router) builder = Rack::Builder.new middleware.each{ |mw,args,block| builder.use(mw, *args, &block) } builder.run(router) builder.to_app end |
.application ⇒ Tennpipes::Router
The resulting rack builder mapping each ‘mounted’ application.
68 69 70 71 72 73 |
# File 'lib/tennpipes-base.rb', line 68 def application warn 'WARNING! No apps are mounted. Please, mount apps in `config/apps.rb`' unless Tennpipes.mounted_apps.present? router = Tennpipes::Router.new Tennpipes.mounted_apps.each { |app| app.map_onto(router) } middleware.present? ? add_middleware(router) : router end |
.bin(*args) ⇒ Boolean
This method return the correct location of tennpipes bin or exec it using Kernel#system with the given args.
16 17 18 19 |
# File 'lib/tennpipes-base/command.rb', line 16 def self.bin(*args) @_tennpipes_bin ||= [self.ruby_command, File.("../../../bin/tennpipes", __FILE__)] args.empty? ? @_tennpipes_bin : system(args.unshift(@_tennpipes_bin).join(" ")) end |
.clear_middleware! ⇒ Array
Clears all previously configured middlewares.
144 145 146 |
# File 'lib/tennpipes-base.rb', line 144 def clear_middleware! @middleware = [] end |
.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:
88 89 90 91 |
# File 'lib/tennpipes-base.rb', line 88 def configure_apps(&block) return unless block_given? global_configurations << block end |
.env ⇒ Symbol
Helper method that return RACK_ENV.
55 56 57 |
# File 'lib/tennpipes-base.rb', line 55 def env @_env ||= RACK_ENV.to_s.downcase.to_sym end |
.gem(name, main_module) ⇒ Object
Registers a gem with tennpipes. This relieves the caller from setting up loadpaths by itself and enables Tennpipes to look up apps in gem folder.
The name given has to be the proper gem name as given in the gemspec.
177 178 179 180 181 182 |
# File 'lib/tennpipes-base.rb', line 177 def gem(name, main_module) _, spec = Gem.loaded_specs.find{|spec_pair| spec_pair[0] == name } gems << spec modules << main_module spec.full_gem_path end |
.gems ⇒ Object
186 187 188 |
# File 'lib/tennpipes-base.rb', line 186 def gems @gems ||= [] end |
.global_configurations ⇒ Object
Stores global configuration blocks.
96 97 98 |
# File 'lib/tennpipes-base.rb', line 96 def global_configurations @_global_configurations ||= [] end |
.insert_mounted_app(mounter) ⇒ Object
Inserts a Mounter object into the mounted applications (avoids duplicates).
292 293 294 |
# File 'lib/tennpipes-base/mounter.rb', line 292 def insert_mounted_app(mounter) Tennpipes.mounted_apps.push(mounter) unless Tennpipes.mounted_apps.include?(mounter) end |
.logger ⇒ Tennpipes::Logger
17 18 19 |
# File 'lib/tennpipes-base/logger.rb', line 17 def self.logger Tennpipes::Logger.logger end |
.logger=(value) ⇒ Object
Set the tennpipes logger.
38 39 40 |
# File 'lib/tennpipes-base/logger.rb', line 38 def self.logger=(value) Tennpipes::Logger.logger = value end |
.middleware ⇒ Array<Array<Class, Array, Proc>>
A Rack::Builder object that allows to add middlewares in front of all Tennpipes applications.
134 135 136 |
# File 'lib/tennpipes-base.rb', line 134 def middleware @middleware ||= [] end |
.modules ⇒ Object
192 193 194 |
# File 'lib/tennpipes-base.rb', line 192 def modules @modules ||= [] end |
.mount(name, options = {}) ⇒ Object
Mounts a new sub-application onto Tennpipes project.
304 305 306 |
# File 'lib/tennpipes-base/mounter.rb', line 304 def mount(name, ={}) Mounter.new(name, ) end |
.mounted_apps ⇒ Array
Returns the mounted tennpipes applications (MountedApp objects).
283 284 285 |
# File 'lib/tennpipes-base/mounter.rb', line 283 def mounted_apps @mounted_apps ||= [] end |
.root(*args) ⇒ String
Helper method for file references.
45 46 47 |
# File 'lib/tennpipes-base.rb', line 45 def root(*args) File.(File.join(TENNPIPES_ROOT, *args)) end |
.ruby_command ⇒ String
Return the path to the ruby interpreter taking into account multiple installations and windows extensions.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tennpipes-base/command.rb', line 28 def self.ruby_command @ruby_command ||= begin ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) ruby << RbConfig::CONFIG['EXEEXT'] # escape string in case path to ruby executable contain spaces. ruby.sub!(/.*\s.*/m, '"\&"') ruby end end |
.run!(options = {}) ⇒ Object
Runs the Tennpipes apps as a self-hosted server using: thin, mongrel, or WEBrick in that order.
10 11 12 13 |
# File 'lib/tennpipes-base/server.rb', line 10 def self.run!(={}) Tennpipes.load! Server.start(*detect_application()) end |
.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.
111 112 113 114 115 |
# File 'lib/tennpipes-base.rb', line 111 def set_encoding Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 nil end |
.use(mw, *args) { ... } ⇒ Object
Convenience method for adding a Middleware to the whole tennpipes app.
160 161 162 |
# File 'lib/tennpipes-base.rb', line 160 def use(mw, *args, &block) middleware << [mw, args, block] end |
.version ⇒ String
The current Tennpipes version.
17 18 19 |
# File 'lib/tennpipes-base/version.rb', line 17 def self.version VERSION end |
Instance Method Details
#RUBY_IGNORE_CALLERS ⇒ Object
Add rubinius (and hopefully other VM implementations) ignore patterns …
27 |
# File 'lib/tennpipes-base/caller.rb', line 27 TENNPIPES_IGNORE_CALLERS.concat(RUBY_IGNORE_CALLERS) |