Module: Web
- Defined in:
- lib/web.rb,
lib/web/cgi.rb,
lib/web/mime.rb,
lib/web/wiki.rb,
lib/web/forms.rb,
lib/web/action.rb,
lib/web/buffer.rb,
lib/web/parser.rb,
lib/web/upload.rb,
lib/web/session.rb,
lib/web/testing.rb,
lib/web/template.rb,
lib/web/unit/form.rb,
lib/web/unit/link.rb,
lib/web/wiki/page.rb,
lib/web/unit/frame.rb,
lib/web/unit/image.rb,
lib/web/unit/table.rb,
lib/web/unit/utils.rb,
lib/web/writableio.rb,
lib/web/traceoutput.rb,
lib/web/unit/assert.rb,
lib/web/unit/cookie.rb,
lib/web/unit/params.rb,
lib/web/unit/parser.rb,
lib/web/wiki/linker.rb,
lib/web/sapi/fastcgi.rb,
lib/web/sapi/webrick.rb,
lib/web/unit/jscript.rb,
lib/web/unit/runtest.rb,
lib/web/sapi/mod_ruby.rb,
lib/web/unit/htmlelem.rb,
lib/web/unit/response.rb,
lib/web/unit/testcase.rb,
lib/web/unit/domwalker.rb,
lib/web/unit/exception.rb,
lib/web/simpledispatcher.rb,
lib/web/unit/html-parser.rb,
lib/web/unit/sgml-parser.rb,
lib/web/unit/ui/cui/testrunner.rb
Overview
WebUnit::exception
Copyright(C) 2001 yuichi TAKAHASHI
$Id: exception.rb,v 1.1.1.1 2003/01/21 11:50:40 yuichi Exp $
Defined Under Namespace
Modules: Parser, Request, SimpleDispatcher, TemplatePrinter, Testing, Unit, WritableIO Classes: Action, Buffer, CGD, CGI, CaseInsensitiveHash, Error, Mime, NarfHandler, Narflates, Node, Scope, Session, TemplateException, Upload, Wiki
Constant Summary collapse
- RFC822_DAYS =
%w[ Sun Mon Tue Wed Thu Fri Sat ]
- RFC822_MONTHS =
%w[ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ]
- HTTP_STATUS =
{"200" => "OK", "206" => "Partial Content", "300" => "Multiple Choices", "301" => "Moved Permanently", "302" => "Found", "304" => "Not Modified", "400" => "Bad Request", "401" => "Authorization Required", "403" => "Forbidden", "404" => "Not Found", "405" => "Method Not Allowed", "406" => "Not Acceptable", "411" => "Length Required", "412" => "Precondition Failed", "500" => "Internal Server Error", "501" => "Method Not Implemented", "502" => "Bad Gateway", "506" => "Variant Also Negotiates" }
- TRACE_STYLESHEET =
<<-EOF <style type="text/css"> span.tracecontent { background-color:white; color:black;font: 10pt verdana, arial; } span.tracecontent table { font: 10pt verdana, arial; cellspacing:0; cellpadding:0; margin-bottom:25} span.tracecontent tr.subhead { background-color:cccccc;} span.tracecontent th { padding:0,3,0,3 } span.tracecontent th.alt { background-color:black; color:white; padding:3,3,2,3; } span.tracecontent td { padding:0,3,0,3 } span.tracecontent tr.alt { background-color:eeeeee } span.tracecontent h1 { font: 24pt verdana, arial; margin:0,0,0,0} span.tracecontent h2 { font: 18pt verdana, arial; margin:0,0,0,0} span.tracecontent h3 { font: 12pt verdana, arial; margin:0,0,0,0} span.tracecontent th a { color:darkblue; font: 8pt verdana, arial; } span.tracecontent a { color:darkblue;text-decoration:none } span.tracecontent a:hover { color:darkblue;text-decoration:underline; } span.tracecontent div.outer { width:90%; margin:15,15,15,15} span.tracecontent table.viewmenu td { background-color:006699; color:white; padding:0,5,0,5; } span.tracecontent table.viewmenu td.end { padding:0,0,0,0; } span.tracecontent table.viewmenu a {color:white; font: 8pt verdana, arial; } span.tracecontent table.viewmenu a:hover {color:white; font: 8pt verdana, arial; } span.tracecontent a.tinylink {color:darkblue; font: 8pt verdana, arial;text-decoration:underline;} span.tracecontent a.link {color:darkblue; text-decoration:underline;} span.tracecontent div.buffer {padding-top:7; padding-bottom:17;} span.tracecontent .small { font: 8pt verdana, arial } span.tracecontent table td { padding-right:20 } span.tracecontent table td.nopad { padding-right:5 } </style> EOF
- NODE =
/^([\w?_]+)/
- SEPARATOR =
/^\./
- ARRAY_VAR =
/^\[(\d+)\]$/
- ARRAY =
/^\[(\d+)\]/
- VAR =
/^([\w?_]+)$/
- @@docroot =
nil
Class Method Summary collapse
- .encode_objects(hash) ⇒ Object
-
.escape(string) ⇒ Object
Escape URL encode url_encoded_string = Web::escape(“string”).
- .get_cgi ⇒ Object
- .get_docroot ⇒ Object
- .get_mime_type(filename) ⇒ Object
-
.html_encode(string) ⇒ Object
this is a bit incomplete – only encodes ampersands.
-
.method_missing(method, *args, &block) ⇒ Object
Web delegates to the current cgi object.
- .process(options = {}, &block) ⇒ Object
-
.rfc1123_date(time) ⇒ Object
Make RFC1123 date string Web::rfc1123_date(Time.now) # => Sat, 01 Jan 2000 00:00:00 GMT.
- .set_cgi(cgi) ⇒ Object
-
.set_docroot(docroot) ⇒ Object
When testing, this is a useful method to tell NARF where to find your scripts.
- .typed_params ⇒ Object
-
.unescape(string) ⇒ Object
Unescape URL encoded string = Web::unescape(“url encoded string”).
Class Method Details
.encode_objects(hash) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/web/forms.rb', line 46 def encode_objects hash newhash = {} hash.each do |k,v| v = ([] << v).flatten v.each { |v| if v.kind_of?(String) newhash[k] = v elsif newhash[k] = Web.escape(v.encode) newhash["#{k}-type"] = v.class.name end } end newhash end |
.escape(string) ⇒ Object
Escape URL encode
url_encoded_string = Web::escape("string")
191 192 193 194 195 196 |
# File 'lib/web.rb', line 191 def Web::escape(string) return nil unless string string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do '%' + $1.unpack('H2' * $1.size).join('%').upcase end.tr(' ', '+') end |
.get_docroot ⇒ Object
10 11 12 |
# File 'lib/web/testing.rb', line 10 def Web.get_docroot @@docroot end |
.get_mime_type(filename) ⇒ Object
78 79 80 |
# File 'lib/web/mime.rb', line 78 def Web.get_mime_type( filename ) Mime.get_mime_type( filename ) end |
.html_encode(string) ⇒ Object
this is a bit incomplete – only encodes ampersands
180 181 182 183 184 185 186 187 |
# File 'lib/web.rb', line 180 def Web::html_encode(string) return nil unless string newstring = string.dup { /&/ => '&' }.each{ |char, entity| newstring.gsub!( char, entity ) } newstring end |
.method_missing(method, *args, &block) ⇒ Object
Web delegates to the current cgi object. This is the recommended way to use narf:
Web["param"]
Web << "hello world"
Web.set_redirect( "http://www.narf-lib.org" )
...
The documentation for these methods is on the Web::CGI object.
162 163 164 |
# File 'lib/web.rb', line 162 def method_missing(method, *args, &block) CGI.get_cgi.send(method,*args, &block) end |
.process(options = {}, &block) ⇒ Object
174 175 176 |
# File 'lib/web.rb', line 174 def process(={}, &block) CGI.process(, &block) end |
.rfc1123_date(time) ⇒ Object
Make RFC1123 date string
Web::rfc1123_date(Time.now) # => Sat, 01 Jan 2000 00:00:00 GMT
211 212 213 214 215 216 |
# File 'lib/web.rb', line 211 def Web::rfc1123_date(time) t = time.clone.gmtime return format("%s, %.2d %s %.4d %.2d:%.2d:%.2d GMT", RFC822_DAYS[t.wday], t.day, RFC822_MONTHS[t.month-1], t.year, t.hour, t.min, t.sec) end |
.set_cgi(cgi) ⇒ Object
166 167 168 |
# File 'lib/web.rb', line 166 def set_cgi( cgi ) CGI.set_cgi( cgi ) end |
.set_docroot(docroot) ⇒ Object
When testing, this is a useful method to tell NARF where to find your scripts
6 7 8 |
# File 'lib/web/testing.rb', line 6 def Web.set_docroot docroot @@docroot = docroot end |
.typed_params ⇒ Object
62 63 64 |
# File 'lib/web/forms.rb', line 62 def typed_params $__web__cgi.typed_params end |