Module Hobix
In: lib/hobix.rb
lib/hobix/commandline.rb
lib/hobix/comments.rb
lib/hobix/webapp.rb
lib/hobix/weblog.rb
lib/hobix/article.rb
lib/hobix/entry.rb
lib/hobix/linklist.rb
lib/hobix/bixwik.rb
lib/hobix/trackbacks.rb
lib/hobix/datamarsh.rb
lib/hobix/config.rb
lib/hobix/base.rb
lib/hobix/api.rb

hobix/api.rb

Hobix API, used by any external service (DRb or REST, etc.)

Copyright (c) 2003-2004 why the lucky stiff

Written & maintained by why the lucky stiff <why@ruby-lang.org>

This program is free software, released under a BSD license. See COPYING for details.

Methods

WebApp   const_find  

Classes and Modules

Module Hobix::BaseProperties
Module Hobix::BixWik
Module Hobix::CommandLine
Module Hobix::EntryEnum
Module Hobix::Enumerable
Module Hobix::Facets
Module Hobix::Out
Module Hobix::UriStr
Class Hobix::API
Class Hobix::Article
Class Hobix::BaseContent
Class Hobix::BaseEntry
Class Hobix::BaseFacet
Class Hobix::BaseOutput
Class Hobix::BasePlugin
Class Hobix::BasePublish
Class Hobix::BaseStorage
Class Hobix::BixWikPlugin
Class Hobix::Comment
Class Hobix::Config
Class Hobix::DataMarsh
Class Hobix::Entry
Class Hobix::LinkList
Class Hobix::Page
Class Hobix::Trackback
Class Hobix::WebApp
Class Hobix::Weblog

Constants

VERSION = '0.5'   Version used to compare installations
CVS_ID = "$Id: hobix.rb 145 2006-09-23 19:08:19Z mental $"   CVS information
CVS_REV = "$Revision: 145 $"[11..-3]
SHARE_PATH = share_path
SHARE_PATH = "#{ ::Config::CONFIG['datadir'] }/hobix/"

Public Class methods

WebApp is a main routine of web application. It should be called from a toplevel of a CGI/FastCGI/mod_ruby/WEBrick script.

WebApp is used as follows.

  #!/usr/bin/env ruby

  require 'webapp'

  ... class/method definitions ... # run once per process.

  WebApp {|webapp| # This block runs once per request.
    ... process a request ...
  }

WebApp yields with an object of the class WebApp. The object contains request and response.

WebApp rise $SAFE to 1.

WebApp catches all kind of exception raised in the block. If HTTP connection is made from localhost or a developper host, the backtrace is sent back to the browser. Otherwise, the backtrace is sent to stderr usually which is redirected to error.log. The developper hosts are specified by the environment variable WEBAPP_DEVELOP_HOST. It may be an IP address such as "111.222.333.444" or an network address such as "111.222.333.0/24". (An environment variable for CGI can be set by SetEnv directive in Apache.)

[Source]

     # File lib/hobix/webapp.rb, line 693
693: def self.WebApp(&block) # :yields: webapp
694:   $SAFE = 1 if $SAFE < 1
695:   manager = WebApp::Manager.new(block)
696:   if defined?(Apache::Request) && Apache.request.kind_of?(Apache::Request)
697:     run = lambda { manager.run_rbx }
698:   elsif Thread.current[:webrick_load_servlet]
699:     run = lambda { manager.run_webrick }
700:   elsif STDIN.respond_to?(:stat) && STDIN.stat.socket? &&
701:         begin
702:           # getpeername(FCGI_LISTENSOCK_FILENO) causes ENOTCONN on FastCGI
703:           # cf. http://www.fastcgi.com/devkit/doc/fcgi-spec.html
704:           require 'socket'
705:           sock = Socket.for_fd(0)
706:           sock.getpeername
707:           false
708:         rescue Errno::ENOTCONN
709:           true
710:         rescue SystemCallError
711:           false
712:         end
713:     run = lambda { manager.run_fcgi }
714:   elsif ENV.include?('REQUEST_METHOD')
715:     run = lambda { manager.run_cgi }
716:   else
717:     require 'hobix/webapp/cli'
718:     run = lambda { manager.run_cli }
719:   end
720:   if Thread.current[:webapp_delay]
721:     Thread.current[:webapp_proc] = run
722:   else
723:     run.call
724:   end
725: end

Get a top-level constant from a string

[Source]

     # File lib/hobix.rb, line 223
223:     def self.const_find( tclass )
224:         obj_class = Object
225:         tclass.split( "::" ).each { |c| obj_class = obj_class.const_get( c ) }
226:         obj_class
227:     end

[Validate]