summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/English.rb10
-rw-r--r--lib/base64.rb16
-rw-r--r--lib/benchmark.rb164
-rw-r--r--lib/cgi.rb248
-rw-r--r--lib/cgi/session.rb52
-rw-r--r--lib/cgi/session/pstore.rb6
-rw-r--r--lib/complex.rb70
-rw-r--r--lib/csv.rb50
-rw-r--r--lib/debug.rb8
-rw-r--r--lib/delegate.rb32
-rw-r--r--lib/drb/drb.rb178
-rw-r--r--lib/drb/extserv.rb2
-rw-r--r--lib/drb/extservm.rb6
-rw-r--r--lib/drb/invokemethod.rb2
-rw-r--r--lib/drb/ssl.rb22
-rw-r--r--lib/drb/timeridconv.rb8
-rw-r--r--lib/drb/unix.rb4
-rw-r--r--lib/e2mmap.rb14
-rw-r--r--lib/erb.rb128
-rw-r--r--lib/fileutils.rb172
-rw-r--r--lib/finalize.rb2
-rw-r--r--lib/forwardable.rb12
-rw-r--r--lib/ftools.rb6
-rw-r--r--lib/generator.rb4
-rw-r--r--lib/getoptlong.rb38
-rw-r--r--lib/getopts.rb2
-rw-r--r--lib/gserver.rb10
-rw-r--r--lib/ipaddr.rb18
-rw-r--r--lib/irb.rb14
-rw-r--r--lib/irb/cmd/chws.rb4
-rw-r--r--lib/irb/cmd/fork.rb6
-rw-r--r--lib/irb/cmd/help.rb2
-rw-r--r--lib/irb/cmd/load.rb8
-rw-r--r--lib/irb/cmd/nop.rb6
-rw-r--r--lib/irb/cmd/pushws.rb4
-rw-r--r--lib/irb/cmd/subirb.rb4
-rw-r--r--lib/irb/completion.rb26
-rw-r--r--lib/irb/context.rb12
-rw-r--r--lib/irb/ext/change-ws.rb10
-rw-r--r--lib/irb/ext/history.rb8
-rw-r--r--lib/irb/ext/loader.rb10
-rw-r--r--lib/irb/ext/math-mode.rb4
-rw-r--r--lib/irb/ext/multi-irb.rb12
-rw-r--r--lib/irb/ext/save-history.rb4
-rw-r--r--lib/irb/ext/tracer.rb8
-rw-r--r--lib/irb/ext/use-loader.rb6
-rw-r--r--lib/irb/ext/workspaces.rb4
-rw-r--r--lib/irb/extend-command.rb16
-rw-r--r--lib/irb/frame.rb4
-rw-r--r--lib/irb/help.rb4
-rw-r--r--lib/irb/init.rb10
-rw-r--r--lib/irb/input-method.rb12
-rw-r--r--lib/irb/lc/error.rb4
-rw-r--r--lib/irb/lc/ja/error.rb4
-rw-r--r--lib/irb/locale.rb10
-rw-r--r--lib/irb/notifier.rb14
-rw-r--r--lib/irb/output-method.rb8
-rw-r--r--lib/irb/ruby-lex.rb90
-rw-r--r--lib/irb/ruby-token.rb16
-rw-r--r--lib/irb/slex.rb36
-rw-r--r--lib/irb/version.rb2
-rw-r--r--lib/irb/workspace.rb16
-rw-r--r--lib/irb/ws-for-case-2.rb4
-rw-r--r--lib/irb/xmp.rb2
-rw-r--r--lib/mailread.rb6
-rw-r--r--lib/mathn.rb42
-rw-r--r--lib/matrix.rb170
-rw-r--r--lib/monitor.rb46
-rw-r--r--lib/mutex_m.rb24
-rw-r--r--lib/net/ftp.rb120
-rw-r--r--lib/net/http.rb198
-rw-r--r--lib/net/https.rb2
-rw-r--r--lib/net/imap.rb366
-rw-r--r--lib/net/pop.rb102
-rw-r--r--lib/net/protocol.rb4
-rw-r--r--lib/net/smtp.rb110
-rw-r--r--lib/net/telnet.rb206
-rw-r--r--lib/observer.rb16
-rw-r--r--lib/open3.rb6
-rw-r--r--lib/optparse.rb68
-rw-r--r--lib/ostruct.rb8
-rw-r--r--lib/parsearg.rb2
-rw-r--r--lib/ping.rb8
-rw-r--r--lib/pp.rb52
-rw-r--r--lib/prettyprint.rb14
-rw-r--r--lib/pstore.rb106
-rw-r--r--lib/rdoc/code_objects.rb20
-rw-r--r--lib/rdoc/diagram.rb46
-rw-r--r--lib/rdoc/generators/chm_generator.rb8
-rw-r--r--lib/rdoc/generators/html_generator.rb126
-rw-r--r--lib/rdoc/generators/ri_generator.rb16
-rw-r--r--lib/rdoc/generators/template/html/hefss.rb16
-rw-r--r--lib/rdoc/generators/template/html/html.rb18
-rw-r--r--lib/rdoc/generators/template/html/kilmer.rb22
-rw-r--r--lib/rdoc/generators/template/html/old_html.rb32
-rw-r--r--lib/rdoc/generators/template/html/one_page_html.rb6
-rw-r--r--lib/rdoc/generators/template/xml/xml.rb4
-rw-r--r--lib/rdoc/generators/xml_generator.rb10
-rw-r--r--lib/rdoc/markup/sample/sample.rb4
-rw-r--r--lib/rdoc/markup/simple_markup.rb28
-rw-r--r--lib/rdoc/markup/simple_markup/fragments.rb14
-rw-r--r--lib/rdoc/markup/simple_markup/inline.rb14
-rw-r--r--lib/rdoc/markup/simple_markup/lines.rb4
-rw-r--r--lib/rdoc/markup/simple_markup/preprocess.rb6
-rw-r--r--lib/rdoc/markup/simple_markup/to_flow.rb2
-rw-r--r--lib/rdoc/markup/simple_markup/to_html.rb14
-rw-r--r--lib/rdoc/markup/simple_markup/to_latex.rb10
-rw-r--r--lib/rdoc/markup/test/TestInline.rb52
-rw-r--r--lib/rdoc/markup/test/TestParse.rb20
-rw-r--r--lib/rdoc/options.rb44
-rw-r--r--lib/rdoc/parsers/parse_c.rb100
-rw-r--r--lib/rdoc/parsers/parse_f95.rb72
-rw-r--r--lib/rdoc/parsers/parse_rb.rb208
-rw-r--r--lib/rdoc/parsers/parse_simple.rb14
-rw-r--r--lib/rdoc/parsers/parserfactory.rb14
-rw-r--r--lib/rdoc/rdoc.rb28
-rw-r--r--lib/rdoc/ri/ri_cache.rb4
-rw-r--r--lib/rdoc/ri/ri_descriptions.rb10
-rw-r--r--lib/rdoc/ri/ri_display.rb66
-rw-r--r--lib/rdoc/ri/ri_driver.rb24
-rw-r--r--lib/rdoc/ri/ri_formatter.rb60
-rw-r--r--lib/rdoc/ri/ri_options.rb30
-rw-r--r--lib/rdoc/ri/ri_paths.rb2
-rw-r--r--lib/rdoc/ri/ri_util.rb6
-rw-r--r--lib/rdoc/ri/ri_writer.rb2
-rw-r--r--lib/rdoc/template.rb16
-rw-r--r--lib/rdoc/usage.rb6
-rw-r--r--lib/readbytes.rb2
-rw-r--r--lib/rexml/attlistdecl.rb2
-rw-r--r--lib/rexml/attribute.rb16
-rw-r--r--lib/rexml/cdata.rb2
-rw-r--r--lib/rexml/child.rb6
-rw-r--r--lib/rexml/comment.rb6
-rw-r--r--lib/rexml/doctype.rb34
-rw-r--r--lib/rexml/document.rb14
-rw-r--r--lib/rexml/dtd/entitydecl.rb2
-rw-r--r--lib/rexml/dtd/notationdecl.rb2
-rw-r--r--lib/rexml/element.rb136
-rw-r--r--lib/rexml/encoding.rb2
-rw-r--r--lib/rexml/encodings/CP-1252.rb2
-rw-r--r--lib/rexml/encodings/ISO-8859-15.rb2
-rw-r--r--lib/rexml/encodings/UNILE.rb2
-rw-r--r--lib/rexml/encodings/UTF-16.rb2
-rw-r--r--lib/rexml/entity.rb4
-rw-r--r--lib/rexml/formatters/default.rb4
-rw-r--r--lib/rexml/formatters/pretty.rb2
-rw-r--r--lib/rexml/formatters/transitive.rb2
-rw-r--r--lib/rexml/functions.rb34
-rw-r--r--lib/rexml/instruction.rb4
-rw-r--r--lib/rexml/namespace.rb2
-rw-r--r--lib/rexml/node.rb2
-rw-r--r--lib/rexml/output.rb2
-rw-r--r--lib/rexml/parent.rb50
-rw-r--r--lib/rexml/parseexception.rb6
-rw-r--r--lib/rexml/parsers/baseparser.rb30
-rw-r--r--lib/rexml/parsers/pullparser.rb2
-rw-r--r--lib/rexml/parsers/sax2parser.rb30
-rw-r--r--lib/rexml/parsers/streamparser.rb4
-rw-r--r--lib/rexml/parsers/treeparser.rb4
-rw-r--r--lib/rexml/parsers/xpathparser.rb20
-rw-r--r--lib/rexml/quickpath.rb18
-rw-r--r--lib/rexml/rexml.rb8
-rw-r--r--lib/rexml/sax2listener.rb8
-rw-r--r--lib/rexml/source.rb10
-rw-r--r--lib/rexml/streamlistener.rb6
-rw-r--r--lib/rexml/text.rb42
-rw-r--r--lib/rexml/validation/relaxng.rb34
-rw-r--r--lib/rexml/validation/validation.rb6
-rw-r--r--lib/rexml/xpath.rb2
-rw-r--r--lib/rexml/xpath_parser.rb42
-rw-r--r--lib/rinda/rinda.rb18
-rw-r--r--lib/rinda/ring.rb8
-rw-r--r--lib/rinda/tuplespace.rb18
-rw-r--r--lib/rss/0.9.rb38
-rw-r--r--lib/rss/1.0.rb46
-rw-r--r--lib/rss/2.0.rb6
-rw-r--r--lib/rss/converter.rb26
-rw-r--r--lib/rss/dublincore.rb16
-rw-r--r--lib/rss/image.rb18
-rw-r--r--lib/rss/maker/0.9.rb28
-rw-r--r--lib/rss/maker/1.0.rb10
-rw-r--r--lib/rss/maker/2.0.rb22
-rw-r--r--lib/rss/maker/base.rb22
-rw-r--r--lib/rss/maker/dublincore.rb2
-rw-r--r--lib/rss/maker/image.rb2
-rw-r--r--lib/rss/maker/taxonomy.rb8
-rw-r--r--lib/rss/maker/trackback.rb2
-rw-r--r--lib/rss/parser.rb14
-rw-r--r--lib/rss/rexmlparser.rb10
-rw-r--r--lib/rss/rss.rb16
-rw-r--r--lib/rss/syndication.rb6
-rw-r--r--lib/rss/taxonomy.rb18
-rw-r--r--lib/rss/trackback.rb36
-rw-r--r--lib/rss/utils.rb4
-rw-r--r--lib/rss/xml-stylesheet.rb4
-rw-r--r--lib/rss/xmlparser.rb14
-rw-r--r--lib/rss/xmlscanner.rb10
-rw-r--r--lib/runit/cui/testrunner.rb12
-rw-r--r--lib/runit/testcase.rb12
-rw-r--r--lib/runit/testsuite.rb6
-rw-r--r--lib/scanf.rb16
-rw-r--r--lib/set.rb74
-rw-r--r--lib/shell.rb4
-rw-r--r--lib/shell/builtin-command.rb6
-rw-r--r--lib/shell/command-processor.rb40
-rw-r--r--lib/shell/error.rb4
-rw-r--r--lib/shell/filter.rb6
-rw-r--r--lib/shell/process-controller.rb18
-rw-r--r--lib/shell/system-command.rb10
-rw-r--r--lib/shell/version.rb2
-rw-r--r--lib/soap/mapping/registry.rb4
-rw-r--r--lib/soap/mapping/wsdlliteralregistry.rb2
-rw-r--r--lib/soap/netHttpClient.rb2
-rw-r--r--lib/soap/rpc/cgistub.rb2
-rw-r--r--lib/soap/rpc/httpserver.rb2
-rw-r--r--lib/soap/rpc/proxy.rb2
-rw-r--r--lib/soap/rpc/router.rb2
-rw-r--r--lib/soap/streamHandler.rb4
-rw-r--r--lib/soap/wsdlDriver.rb2
-rw-r--r--lib/sync.rb58
-rw-r--r--lib/tempfile.rb8
-rw-r--r--lib/test/unit.rb68
-rw-r--r--lib/test/unit/assertions.rb12
-rw-r--r--lib/test/unit/autorunner.rb2
-rw-r--r--lib/test/unit/collector/objectspace.rb6
-rw-r--r--lib/test/unit/failure.rb4
-rw-r--r--lib/test/unit/testcase.rb8
-rw-r--r--lib/test/unit/testsuite.rb6
-rw-r--r--lib/test/unit/ui/console/testrunner.rb24
-rw-r--r--lib/test/unit/ui/fox/testrunner.rb82
-rw-r--r--lib/test/unit/ui/gtk/testrunner.rb90
-rw-r--r--lib/test/unit/ui/gtk2/testrunner.rb8
-rw-r--r--lib/test/unit/ui/testrunnermediator.rb10
-rw-r--r--lib/test/unit/util/backtracefilter.rb2
-rw-r--r--lib/test/unit/util/observable.rb4
-rw-r--r--lib/thread.rb24
-rw-r--r--lib/thwait.rb24
-rw-r--r--lib/time.rb28
-rw-r--r--lib/tracer.rb32
-rw-r--r--lib/tsort.rb20
-rw-r--r--lib/uri.rb4
-rw-r--r--lib/uri/common.rb54
-rw-r--r--lib/uri/ftp.rb34
-rw-r--r--lib/uri/generic.rb78
-rw-r--r--lib/uri/http.rb26
-rw-r--r--lib/uri/ldap.rb6
-rw-r--r--lib/uri/mailto.rb20
-rw-r--r--lib/webrick/cgi.rb26
-rw-r--r--lib/webrick/config.rb2
-rw-r--r--lib/webrick/httpauth/authenticator.rb8
-rw-r--r--lib/webrick/httpauth/basicauth.rb2
-rw-r--r--lib/webrick/httpauth/digestauth.rb10
-rw-r--r--lib/webrick/httpauth/userdb.rb2
-rw-r--r--lib/webrick/httpproxy.rb6
-rw-r--r--lib/webrick/httprequest.rb2
-rw-r--r--lib/webrick/httpresponse.rb4
-rw-r--r--lib/webrick/httpserver.rb4
-rw-r--r--lib/webrick/httpservlet/cgihandler.rb12
-rw-r--r--lib/webrick/httpservlet/erbhandler.rb6
-rw-r--r--lib/webrick/httpservlet/filehandler.rb6
-rw-r--r--lib/webrick/httpservlet/prochandler.rb8
-rw-r--r--lib/webrick/httpstatus.rb2
-rw-r--r--lib/webrick/httputils.rb10
-rw-r--r--lib/webrick/log.rb2
-rw-r--r--lib/webrick/ssl.rb6
-rw-r--r--lib/webrick/utils.rb6
-rw-r--r--lib/wsdl/info.rb2
-rw-r--r--lib/wsdl/soap/classDefCreator.rb4
-rw-r--r--lib/wsdl/soap/complexType.rb2
-rw-r--r--lib/wsdl/soap/definitions.rb8
-rw-r--r--lib/wsdl/soap/methodDefCreator.rb4
-rw-r--r--lib/wsdl/soap/operation.rb2
-rw-r--r--lib/wsdl/xmlSchema/complexType.rb2
-rw-r--r--lib/wsdl/xmlSchema/simpleExtension.rb2
-rw-r--r--lib/wsdl/xmlSchema/simpleRestriction.rb2
-rw-r--r--lib/xmlrpc/base64.rb22
-rw-r--r--lib/xmlrpc/client.rb142
-rw-r--r--lib/xmlrpc/config.rb8
-rw-r--r--lib/xmlrpc/create.rb70
-rw-r--r--lib/xmlrpc/datetime.rb18
-rw-r--r--lib/xmlrpc/httpserver.rb44
-rw-r--r--lib/xmlrpc/marshal.rb6
-rw-r--r--lib/xmlrpc/parser.rb132
-rw-r--r--lib/xmlrpc/server.rb188
-rw-r--r--lib/xmlrpc/utils.rb30
-rw-r--r--lib/xsd/charset.rb2
-rw-r--r--lib/xsd/codegen/classdef.rb2
-rw-r--r--lib/xsd/codegen/moduledef.rb2
-rw-r--r--lib/xsd/namedelements.rb2
-rw-r--r--lib/xsd/qname.rb2
-rw-r--r--lib/yaml.rb36
-rw-r--r--lib/yaml/baseemitter.rb20
-rw-r--r--lib/yaml/constants.rb4
-rw-r--r--lib/yaml/dbm.rb4
-rw-r--r--lib/yaml/encoding.rb4
-rw-r--r--lib/yaml/error.rb2
-rw-r--r--lib/yaml/rubytypes.rb6
-rw-r--r--lib/yaml/stream.rb2
-rw-r--r--lib/yaml/stringio.rb2
-rw-r--r--lib/yaml/tag.rb8
-rw-r--r--lib/yaml/types.rb6
301 files changed, 3742 insertions, 3742 deletions
diff --git a/lib/English.rb b/lib/English.rb
index 1a0e11de74..4fd53c5ec6 100644
--- a/lib/English.rb
+++ b/lib/English.rb
@@ -11,7 +11,7 @@
# With English:
#
# require "English"
-#
+#
# $OUTPUT_FIELD_SEPARATOR = ' -- '
# "waterbuffalo" =~ /buff/
# print $LOADED_FEATURES, $POSTMATCH, $PID, "\n"
@@ -83,7 +83,7 @@ alias $DEFAULT_OUTPUT $>
# of the contents of all the files
# given as command-line arguments, or <tt>$stdin</tt>
# (in the case where there are no
-# arguments). <tt>$<</tt> supports methods similar to a
+# arguments). <tt>$<</tt> supports methods similar to a
# +File+ object:
# +inmode+, +close+,
# <tt>closed?</tt>, +each+,
@@ -91,7 +91,7 @@ alias $DEFAULT_OUTPUT $>
# +eof+, <tt>eof?</tt>, +file+,
# +filename+, +fileno+,
# +getc+, +gets+, +lineno+,
-# <tt>lineno=</tt>, +path+,
+# <tt>lineno=</tt>, +path+,
# +pos+, <tt>pos=</tt>,
# +read+, +readchar+,
# +readline+, +readlines+,
@@ -139,12 +139,12 @@ alias $ARGV $*
alias $MATCH $&
# The string preceding the match in the last
-# successful pattern match. This variable is local to
+# successful pattern match. This variable is local to
# the current scope. Read only. Thread local.
alias $PREMATCH $`
# The string following the match in the last
-# successful pattern match. This variable is local to
+# successful pattern match. This variable is local to
# the current scope. Read only. Thread local.
alias $POSTMATCH $'
diff --git a/lib/base64.rb b/lib/base64.rb
index 9b901a7597..d175ec158b 100644
--- a/lib/base64.rb
+++ b/lib/base64.rb
@@ -1,7 +1,7 @@
#
# = base64.rb: methods for base64-encoding and -decoding strings
#
-# Author:: Yukihiro Matsumoto
+# Author:: Yukihiro Matsumoto
# Documentation:: Dave Thomas and Gavin Sinclair
#
# Until Ruby 1.8.1, these methods were defined at the top-level. Now
@@ -16,7 +16,7 @@ require "kconv"
# The Base64 module provides for the encoding (#encode64) and decoding
# (#decode64) of binary data using a Base64 representation.
-#
+#
# The following particular features are also provided:
# - encode into lines of a given length (#b64encode)
# - decode the special format specified in RFC2047 for the
@@ -24,12 +24,12 @@ require "kconv"
#
# == Example
#
-# A simple encoding and decoding.
-#
+# A simple encoding and decoding.
+#
# require "base64"
#
# enc = Base64.encode64('Send reinforcements')
-# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
+# # -> "U2VuZCByZWluZm9yY2VtZW50cw==\n"
# plain = Base64.decode64(enc)
# # -> "Send reinforcements"
#
@@ -78,7 +78,7 @@ module Base64
decode64($1)
}
str = Kconv::toeuc(str)
- str.gsub!(/\n/, ' ')
+ str.gsub!(/\n/, ' ')
str.gsub!(/\0/, '')
str
end
@@ -135,7 +135,7 @@ module Base64
# +len+ (default 60) characters.
#
# require 'base64'
- # data = "Now is the time for all good coders\nto learn Ruby"
+ # data = "Now is the time for all good coders\nto learn Ruby"
# Base64.b64encode(data)
#
# <i>Generates:</i>
@@ -147,7 +147,7 @@ module Base64
encode64(bin).scan(/.{1,#{len}}/) do
print $&, "\n"
end
- end
+ end
module Deprecated # :nodoc:
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 380c364398..9a0bbef596 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -1,13 +1,13 @@
=begin
#
-# benchmark.rb - a performance benchmarking library
-#
+# benchmark.rb - a performance benchmarking library
+#
# $Id$
-#
-# Created by Gotoken ([email protected]).
+#
+# Created by Gotoken ([email protected]).
#
# Documentation by Gotoken (original RD), Lyle Johnson (RDoc conversion), and
-# Gavin Sinclair (editing).
+# Gavin Sinclair (editing).
#
=end
@@ -26,15 +26,15 @@
# require 'benchmark'
#
# puts Benchmark.measure { "a"*1_000_000 }
-#
+#
# On my machine (FreeBSD 3.2 on P5, 100MHz) this generates:
-#
+#
# 1.166667 0.050000 1.216667 ( 0.571355)
-#
+#
# This report shows the user CPU time, system CPU time, the sum of
# the user and system CPU times, and the elapsed real time. The unit
# of time is seconds.
-#
+#
# * Do some experiments sequentially using the #bm method:
#
# require 'benchmark'
@@ -45,7 +45,7 @@
# x.report { n.times do ; a = "1"; end }
# x.report { 1.upto(n) do ; a = "1"; end }
# end
-#
+#
# The result:
#
# user system total real
@@ -63,14 +63,14 @@
# x.report("times:") { n.times do ; a = "1"; end }
# x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# end
-#
+#
# The result:
-#
+#
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
-#
+#
#
# * The times for some benchmarks depend on the order in which items
# are run. These differences are due to the cost of memory
@@ -79,21 +79,21 @@
# sort an array of floats:
#
# require 'benchmark'
-#
+#
# array = (1..1000000).map { rand }
-#
+#
# Benchmark.bmbm do |x|
# x.report("sort!") { array.dup.sort! }
# x.report("sort") { array.dup.sort }
# end
-#
+#
# The result:
-#
+#
# Rehearsal -----------------------------------------
# sort! 11.928000 0.010000 11.938000 ( 12.756000)
# sort 13.048000 0.020000 13.068000 ( 13.857000)
# ------------------------------- total: 25.006000sec
-#
+#
# user system total real
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
# sort 12.007000 0.000000 12.007000 ( 12.791000)
@@ -103,7 +103,7 @@
# using the #benchmark method:
#
# require 'benchmark'
-# include Benchmark # we need the CAPTION and FMTSTR constants
+# include Benchmark # we need the CAPTION and FMTSTR constants
#
# n = 50000
# Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
@@ -112,9 +112,9 @@
# tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# [tf+tt+tu, (tf+tt+tu)/3]
# end
-#
+#
# The result:
-#
+#
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
@@ -145,10 +145,10 @@ module Benchmark
# suitable for nearly all benchmarking requirements. See the examples in
# Benchmark, and the #bm and #bmbm methods.
#
- # Example:
+ # Example:
#
# require 'benchmark'
- # include Benchmark # we need the CAPTION and FMTSTR constants
+ # include Benchmark # we need the CAPTION and FMTSTR constants
#
# n = 50000
# Benchmark.benchmark(" "*7 + CAPTION, 7, FMTSTR, ">total:", ">avg:") do |x|
@@ -157,16 +157,16 @@ module Benchmark
# tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# [tf+tt+tu, (tf+tt+tu)/3]
# end
- #
+ #
# <i>Generates:</i>
- #
+ #
# user system total real
# for: 1.016667 0.016667 1.033333 ( 0.485749)
# times: 1.450000 0.016667 1.466667 ( 0.681367)
# upto: 1.533333 0.000000 1.533333 ( 0.722166)
# >total: 4.000000 0.033333 4.033333 ( 1.889282)
# >avg: 1.333333 0.011111 1.344444 ( 0.629761)
- #
+ #
def benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) # :yield: report
sync = STDOUT.sync
@@ -177,7 +177,7 @@ module Benchmark
print caption
results = yield(Report.new(label_width, fmtstr))
Array === results and results.grep(Tms).each {|t|
- print((labels.shift || t.label || "").ljust(label_width),
+ print((labels.shift || t.label || "").ljust(label_width),
t.format(fmtstr))
}
STDOUT.sync = sync
@@ -186,7 +186,7 @@ module Benchmark
# A simple interface to the #benchmark method, #bm is generates sequential reports
# with labels. The parameters have the same meaning as for #benchmark.
- #
+ #
# require 'benchmark'
#
# n = 50000
@@ -195,9 +195,9 @@ module Benchmark
# x.report("times:") { n.times do ; a = "1"; end }
# x.report("upto:") { 1.upto(n) do ; a = "1"; end }
# end
- #
+ #
# <i>Generates:</i>
- #
+ #
# user system total real
# for: 1.050000 0.000000 1.050000 ( 0.503462)
# times: 1.533333 0.016667 1.550000 ( 0.735473)
@@ -224,21 +224,21 @@ module Benchmark
# calculate the required label width.
#
# require 'benchmark'
- #
+ #
# array = (1..1000000).map { rand }
- #
+ #
# Benchmark.bmbm do |x|
# x.report("sort!") { array.dup.sort! }
# x.report("sort") { array.dup.sort }
# end
- #
+ #
# <i>Generates:</i>
- #
+ #
# Rehearsal -----------------------------------------
# sort! 11.928000 0.010000 11.938000 ( 12.756000)
# sort 13.048000 0.020000 13.068000 ( 13.857000)
# ------------------------------- total: 25.006000sec
- #
+ #
# user system total real
# sort! 12.959000 0.010000 12.969000 ( 13.793000)
# sort 12.007000 0.000000 12.007000 ( 12.791000)
@@ -267,7 +267,7 @@ module Benchmark
ets = sum.format("total: %tsec")
printf("%s %s\n\n",
"-"*(width+CAPTION.length-ets.length-1), ets)
-
+
# take
print ' '*width, CAPTION
list = []
@@ -285,7 +285,7 @@ module Benchmark
ary
end
- #
+ #
# Returns the time used to execute the given block as a
# Benchmark::Tms object.
#
@@ -293,10 +293,10 @@ module Benchmark
t0, r0 = Benchmark.times, Time.now
yield
t1, r1 = Benchmark.times, Time.now
- Benchmark::Tms.new(t1.utime - t0.utime,
- t1.stime - t0.stime,
- t1.cutime - t0.cutime,
- t1.cstime - t0.cstime,
+ Benchmark::Tms.new(t1.utime - t0.utime,
+ t1.stime - t0.stime,
+ t1.cutime - t0.cutime,
+ t1.cstime - t0.cstime,
r1.to_f - r0.to_f,
label)
end
@@ -323,8 +323,8 @@ module Benchmark
# Usually, one doesn't call this method directly, as new
# Job objects are created by the #bmbm method.
# _width_ is a initial value for the label offset used in formatting;
- # the #bmbm method passes its _width_ argument to this constructor.
- #
+ # the #bmbm method passes its _width_ argument to this constructor.
+ #
def initialize(width)
@width = width
@list = []
@@ -343,11 +343,11 @@ module Benchmark
end
alias report item
-
+
# An array of 2-element arrays, consisting of label and block pairs.
attr_reader :list
-
- # Length of the widest label in the #list, plus one.
+
+ # Length of the widest label in the #list, plus one.
attr_reader :width
end
@@ -363,10 +363,10 @@ module Benchmark
#
# Returns an initialized Report instance.
# Usually, one doesn't call this method directly, as new
- # Report objects are created by the #benchmark and #bm methods.
- # _width_ and _fmtstr_ are the label offset and
- # format string used by Tms#format.
- #
+ # Report objects are created by the #benchmark and #bm methods.
+ # _width_ and _fmtstr_ are the label offset and
+ # format string used by Tms#format.
+ #
def initialize(width = 0, fmtstr = nil)
@width, @fmtstr = width, fmtstr
end
@@ -398,50 +398,50 @@ module Benchmark
# User CPU time
attr_reader :utime
-
+
# System CPU time
attr_reader :stime
-
+
# User CPU time of children
attr_reader :cutime
-
+
# System CPU time of children
attr_reader :cstime
-
+
# Elapsed real time
attr_reader :real
-
- # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_
+
+ # Total time, that is _utime_ + _stime_ + _cutime_ + _cstime_
attr_reader :total
-
+
# Label
attr_reader :label
#
# Returns an initialized Tms object which has
- # _u_ as the user CPU time, _s_ as the system CPU time,
+ # _u_ as the user CPU time, _s_ as the system CPU time,
# _cu_ as the children's user CPU time, _cs_ as the children's
# system CPU time, _real_ as the elapsed real time and _l_
- # as the label.
- #
+ # as the label.
+ #
def initialize(u = 0.0, s = 0.0, cu = 0.0, cs = 0.0, real = 0.0, l = nil)
@utime, @stime, @cutime, @cstime, @real, @label = u, s, cu, cs, real, l
@total = @utime + @stime + @cutime + @cstime
end
- #
+ #
# Returns a new Tms object whose times are the sum of the times for this
# Tms object, plus the time required to execute the code block (_blk_).
- #
+ #
def add(&blk) # :yield:
- self + Benchmark::measure(&blk)
+ self + Benchmark::measure(&blk)
end
- #
+ #
# An in-place version of #add.
- #
+ #
def add!
- t = Benchmark::measure(&blk)
+ t = Benchmark::measure(&blk)
@utime = utime + t.utime
@stime = stime + t.stime
@cutime = cutime + t.cutime
@@ -450,32 +450,32 @@ module Benchmark
self
end
- #
+ #
# Returns a new Tms object obtained by memberwise summation
# of the individual times for this Tms object with those of the other
# Tms object.
- # This method and #/() are useful for taking statistics.
- #
+ # This method and #/() are useful for taking statistics.
+ #
def +(other); memberwise(:+, other) end
-
+
#
# Returns a new Tms object obtained by memberwise subtraction
# of the individual times for the other Tms object from those of this
# Tms object.
#
def -(other); memberwise(:-, other) end
-
+
#
# Returns a new Tms object obtained by memberwise multiplication
# of the individual times for this Tms object by _x_.
#
def *(x); memberwise(:*, x) end
- #
+ #
# Returns a new Tms object obtained by memberwise division
# of the individual times for this Tms object by _x_.
- # This method and #+() are useful for taking statistics.
- #
+ # This method and #+() are useful for taking statistics.
+ #
def /(x); memberwise(:/, x) end
#
@@ -486,15 +486,15 @@ module Benchmark
#
# <tt>%u</tt>:: Replaced by the user CPU time, as reported by Tms#utime.
# <tt>%y</tt>:: Replaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem")
- # <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
+ # <tt>%U</tt>:: Replaced by the children's user CPU time, as reported by Tms#cutime
# <tt>%Y</tt>:: Replaced by the children's system CPU time, as reported by Tms#cstime
# <tt>%t</tt>:: Replaced by the total CPU time, as reported by Tms#total
# <tt>%r</tt>:: Replaced by the elapsed real time, as reported by Tms#real
# <tt>%n</tt>:: Replaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame")
- #
+ #
# If _fmtstr_ is not given, FMTSTR is used as default value, detailing the
# user, system and real elapsed time.
- #
+ #
def format(arg0 = nil, *args)
fmtstr = (arg0 || FMTSTR).dup
fmtstr.gsub!(/(%[-+\.\d]*)n/){"#{$1}s" % label}
@@ -507,19 +507,19 @@ module Benchmark
arg0 ? Kernel::format(fmtstr, *args) : fmtstr
end
- #
+ #
# Same as #format.
- #
+ #
def to_s
format
end
- #
+ #
# Returns a new 6-element array, consisting of the
# label, user CPU time, system CPU time, children's
# user CPU time, children's system CPU time and elapsed
# real time.
- #
+ #
def to_a
[@label, @utime, @stime, @cutime, @cstime, @real]
end
@@ -548,7 +548,7 @@ module Benchmark
# The default caption string (heading above the output times).
CAPTION = Benchmark::Tms::CAPTION
- # The default format string used to display times. See also Benchmark::Tms#format.
+ # The default format string used to display times. See also Benchmark::Tms#format.
FMTSTR = Benchmark::Tms::FMTSTR
end
diff --git a/lib/cgi.rb b/lib/cgi.rb
index deb3caaaf3..418a18c6e2 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -1,14 +1,14 @@
-#
+#
# cgi.rb - cgi support library
-#
+#
# Copyright (C) 2000 Network Applied Communication Laboratory, Inc.
-#
+#
# Copyright (C) 2000 Information-technology Promotion Agency, Japan
#
# Author: Wakou Aoyama <[email protected]>
#
-# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber)
-#
+# Documentation: Wakou Aoyama (RDoc'd and embellished by William Webber)
+#
# == Overview
#
# The Common Gateway Interface (CGI) is a simple protocol
@@ -18,7 +18,7 @@
# parameters of the request passed in either in the
# environment (GET) or via $stdin (POST), and everything
# it prints to $stdout is returned to the client.
-#
+#
# This file holds the +CGI+ class. This class provides
# functionality for retrieving HTTP request parameters,
# managing cookies, and generating HTML output. See the
@@ -77,18 +77,18 @@ require 'English'
#
#
# For each of these variables, there is a corresponding attribute with the
-# same name, except all lower case and without a preceding HTTP_.
+# same name, except all lower case and without a preceding HTTP_.
# +content_length+ and +server_port+ are integers; the rest are strings.
#
# === Parameters
#
# The method #params() returns a hash of all parameters in the request as
# name/value-list pairs, where the value-list is an Array of one or more
-# values. The CGI object itself also behaves as a hash of parameter names
-# to values, but only returns a single value (as a String) for each
+# values. The CGI object itself also behaves as a hash of parameter names
+# to values, but only returns a single value (as a String) for each
# parameter name.
#
-# For instance, suppose the request contains the parameter
+# For instance, suppose the request contains the parameter
# "favourite_colours" with the multiple values "blue" and "green". The
# following behaviour would occur:
#
@@ -107,7 +107,7 @@ require 'English'
#
# === Multipart requests
#
-# If a request's method is POST and its content type is multipart/form-data,
+# If a request's method is POST and its content type is multipart/form-data,
# then it may contain uploaded files. These are stored by the QueryExtension
# module in the parameters of the request. The parameter name is the name
# attribute of the file input field, as usual. However, the value is not
@@ -138,7 +138,7 @@ require 'English'
#
# Each HTML element has a corresponding method for generating that
# element as a String. The name of this method is the same as that
-# of the element, all lowercase. The attributes of the element are
+# of the element, all lowercase. The attributes of the element are
# passed in as a hash, and the body as a no-argument block that evaluates
# to a String. The HTML generation module knows which elements are
# always empty, and silently drops any passed-in body. It also knows
@@ -152,57 +152,57 @@ require 'English'
# as arguments, rather than via a hash.
#
# == Examples of use
-#
+#
# === Get form values
-#
+#
# require "cgi"
# cgi = CGI.new
# value = cgi['field_name'] # <== value string for 'field_name'
# # if not 'field_name' included, then return "".
# fields = cgi.keys # <== array of field names
-#
+#
# # returns true if form has 'field_name'
# cgi.has_key?('field_name')
# cgi.has_key?('field_name')
# cgi.include?('field_name')
-#
-# CAUTION! cgi['field_name'] returned an Array with the old
+#
+# CAUTION! cgi['field_name'] returned an Array with the old
# cgi.rb(included in ruby 1.6)
-#
+#
# === Get form values as hash
-#
+#
# require "cgi"
# cgi = CGI.new
# params = cgi.params
-#
+#
# cgi.params is a hash.
-#
+#
# cgi.params['new_field_name'] = ["value"] # add new param
# cgi.params['field_name'] = ["new_value"] # change value
# cgi.params.delete('field_name') # delete param
# cgi.params.clear # delete all params
-#
-#
+#
+#
# === Save form values to file
-#
+#
# require "pstore"
# db = PStore.new("query.db")
# db.transaction do
# db["params"] = cgi.params
# end
-#
-#
+#
+#
# === Restore form values from file
-#
+#
# require "pstore"
# db = PStore.new("query.db")
# db.transaction do
# cgi.params = db["params"]
# end
-#
-#
+#
+#
# === Get multipart form values
-#
+#
# require "cgi"
# cgi = CGI.new
# value = cgi['field_name'] # <== value string for 'field_name'
@@ -210,37 +210,37 @@ require 'English'
# value.local_path # <== path to local file of value
# value.original_filename # <== original filename of value
# value.content_type # <== content_type of value
-#
+#
# and value has StringIO or Tempfile class methods.
-#
+#
# === Get cookie values
-#
+#
# require "cgi"
# cgi = CGI.new
# values = cgi.cookies['name'] # <== array of 'name'
# # if not 'name' included, then return [].
# names = cgi.cookies.keys # <== array of cookie names
-#
+#
# and cgi.cookies is a hash.
-#
+#
# === Get cookie objects
-#
+#
# require "cgi"
# cgi = CGI.new
# for name, cookie in cgi.cookies
# cookie.expires = Time.now + 30
# end
# cgi.out("cookie" => cgi.cookies) {"string"}
-#
+#
# cgi.cookies # { "name1" => cookie1, "name2" => cookie2, ... }
-#
+#
# require "cgi"
# cgi = CGI.new
# cgi.cookies['name'].expires = Time.now + 30
# cgi.out("cookie" => cgi.cookies['name']) {"string"}
-#
+#
# === Print http header and html string to $DEFAULT_OUTPUT ($>)
-#
+#
# require "cgi"
# cgi = CGI.new("html3") # add HTML generation methods
# cgi.out() do
@@ -264,7 +264,7 @@ require 'English'
# end
# end
# end
-#
+#
# # add HTML generation methods
# CGI.new("html3") # html3.2
# CGI.new("html4") # html4.01 (Strict)
@@ -286,7 +286,7 @@ class CGI
REVISION = '$Id$' #:nodoc:
- NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
+ NEEDS_BINMODE = true if /WIN/ni.match(RUBY_PLATFORM)
# Path separators in different environments.
PATH_SEPARATOR = {'UNIX'=>'/', 'WINDOWS'=>'\\', 'MACINTOSH'=>':'}
@@ -321,7 +321,7 @@ class CGI
# :startdoc:
- def env_table
+ def env_table
ENV
end
@@ -431,7 +431,7 @@ class CGI
# print CGI::unescapeElement(
# CGI::escapeHTML('<BR><A HREF="url"></A>'), "A", "IMG")
# # "&lt;BR&gt;<A HREF="url"></A>"
- #
+ #
# print CGI::unescapeElement(
# CGI::escapeHTML('<BR><A HREF="url"></A>'), ["A", "IMG"])
# # "&lt;BR&gt;<A HREF="url"></A>"
@@ -475,7 +475,7 @@ class CGI
# status:: the HTTP status code, returned as the Status header. See the
# list of available status codes below.
# server:: the server software, returned as the Server header.
- # connection:: the connection type, returned as the Connection header (for
+ # connection:: the connection type, returned as the Connection header (for
# instance, "close".
# length:: the length of the content that will be sent, returned as the
# Content-Length header.
@@ -485,19 +485,19 @@ class CGI
# object, returned as the Expires header.
# cookie:: a cookie or cookies, returned as one or more Set-Cookie headers.
# The value can be the literal string of the cookie; a CGI::Cookie
- # object; an Array of literal cookie strings or Cookie objects; or a
+ # object; an Array of literal cookie strings or Cookie objects; or a
# hash all of whose values are literal cookie strings or Cookie objects.
# These cookies are in addition to the cookies held in the
# @output_cookies field.
#
# Other header lines can also be set; they are appended as key: value.
- #
+ #
# header
# # Content-Type: text/html
- #
+ #
# header("text/plain")
# # Content-Type: text/plain
- #
+ #
# header("nph" => true,
# "status" => "OK", # == "200 OK"
# # "status" => "200 GOOD",
@@ -512,9 +512,9 @@ class CGI
# "cookie" => [cookie1, cookie2],
# "my_header1" => "my_value"
# "my_header2" => "my_value")
- #
+ #
# The status codes are:
- #
+ #
# "OK" --> "200 OK"
# "PARTIAL_CONTENT" --> "206 Partial Content"
# "MULTIPLE_CHOICES" --> "300 Multiple Choices"
@@ -533,8 +533,8 @@ class CGI
# "NOT_IMPLEMENTED" --> "501 Method Not Implemented"
# "BAD_GATEWAY" --> "502 Bad Gateway"
# "VARIANT_ALSO_VARIES" --> "506 Variant Also Negotiates"
- #
- # This method does not perform charset conversion.
+ #
+ # This method does not perform charset conversion.
#
def header(options = "text/html")
@@ -670,13 +670,13 @@ class CGI
# # Content-Length: 6
# #
# # string
- #
+ #
# cgi.out("text/plain") { "string" }
# # Content-Type: text/plain
# # Content-Length: 6
# #
# # string
- #
+ #
# cgi.out("nph" => true,
# "status" => "OK", # == "200 OK"
# "server" => ENV['SERVER_SOFTWARE'],
@@ -689,16 +689,16 @@ class CGI
# "cookie" => [cookie1, cookie2],
# "my_header1" => "my_value",
# "my_header2" => "my_value") { "string" }
- #
+ #
# Content-Length is automatically calculated from the size of
# the String returned by the content block.
#
# If ENV['REQUEST_METHOD'] == "HEAD", then only the header
# is outputted (the content block is still required, but it
# is ignored).
- #
+ #
# If the charset is "iso-2022-jp" or "euc-jp" or "shift_jis" then
- # the content is converted to this charset, and the language is set
+ # the content is converted to this charset, and the language is set
# to "ja".
def out(options = "text/html") # :yield:
@@ -755,16 +755,16 @@ class CGI
# 'expires' => Time.now, # optional
# 'secure' => true # optional
# )
- #
+ #
# cgi.out("cookie" => [cookie1, cookie2]) { "string" }
- #
+ #
# name = cookie1.name
# values = cookie1.value
# path = cookie1.path
# domain = cookie1.domain
# expires = cookie1.expires
# secure = cookie1.secure
- #
+ #
# cookie1.name = 'name'
# cookie1.value = ['value1', 'value2', ...]
# cookie1.path = 'path'
@@ -787,7 +787,7 @@ class CGI
# domain:: the domain for which this cookie applies.
# expires:: the time at which this cookie expires, as a +Time+ object.
# secure:: whether this cookie is a secure cookie or not (default to
- # false). Secure cookies are only transmitted to HTTPS
+ # false). Secure cookies are only transmitted to HTTPS
# servers.
#
# These keywords correspond to attributes of the cookie object.
@@ -914,7 +914,7 @@ class CGI
# Mixin module. It provides the follow functionality groups:
#
- # 1. Access to CGI environment variables as methods. See
+ # 1. Access to CGI environment variables as methods. See
# documentation to the CGI class for a list of these variables.
#
# 2. Access to cookies, including the cookies attribute.
@@ -1050,7 +1050,7 @@ class CGI
(not /MSIE/ni.match(env_table['HTTP_USER_AGENT']))
filename = CGI::unescape(filename)
end
-
+
/Content-Type: ([^\s]*)/ni.match(head)
content_type = ($1 or "")
@@ -1169,7 +1169,7 @@ class CGI
# Get the value for the parameter with a given key.
#
- # If the parameter has multiple values, only the first will be
+ # If the parameter has multiple values, only the first will be
# retrieved; use #params() to get the array of values.
def [](key)
params = @params[key]
@@ -1216,7 +1216,7 @@ class CGI
# # <BODY>
# # </BODY>
# # </HTML>
- #
+ #
# print CGI::pretty("<HTML><BODY></BODY></HTML>", "\t")
# # <HTML>
# # <BODY>
@@ -1301,7 +1301,7 @@ class CGI
# Modules Http3, Http4, etc., contain more basic HTML-generation methods
# (:title, :center, etc.).
#
- # See class CGI for a detailed example.
+ # See class CGI for a detailed example.
#
module HtmlExtension
@@ -1334,7 +1334,7 @@ class CGI
end
end
- # Generate a Document Base URI element as a String.
+ # Generate a Document Base URI element as a String.
#
# +href+ can either by a string, giving the base URL for the HREF
# attribute, or it can be a has of the element's attributes.
@@ -1414,10 +1414,10 @@ class CGI
#
# checkbox("name")
# # = checkbox("NAME" => "name")
- #
+ #
# checkbox("name", "value")
# # = checkbox("NAME" => "name", "VALUE" => "value")
- #
+ #
# checkbox("name", "value", true)
# # = checkbox("NAME" => "name", "VALUE" => "value", "CHECKED" => true)
def checkbox(name = "", value = nil, checked = nil)
@@ -1455,23 +1455,23 @@ class CGI
# # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
# # <INPUT TYPE="checkbox" NAME="name" VALUE="bar">bar
# # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
- #
+ #
# checkbox_group("name", ["foo"], ["bar", true], "baz")
# # <INPUT TYPE="checkbox" NAME="name" VALUE="foo">foo
# # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="bar">bar
# # <INPUT TYPE="checkbox" NAME="name" VALUE="baz">baz
- #
+ #
# checkbox_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
# # <INPUT TYPE="checkbox" NAME="name" VALUE="1">Foo
# # <INPUT TYPE="checkbox" CHECKED NAME="name" VALUE="2">Bar
# # <INPUT TYPE="checkbox" NAME="name" VALUE="Baz">Baz
- #
+ #
# checkbox_group("NAME" => "name",
# "VALUES" => ["foo", "bar", "baz"])
- #
+ #
# checkbox_group("NAME" => "name",
# "VALUES" => [["foo"], ["bar", true], "baz"])
- #
+ #
# checkbox_group("NAME" => "name",
# "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
def checkbox_group(name = "", *values)
@@ -1507,13 +1507,13 @@ class CGI
#
# file_field("name")
# # <INPUT TYPE="file" NAME="name" SIZE="20">
- #
+ #
# file_field("name", 40)
# # <INPUT TYPE="file" NAME="name" SIZE="40">
- #
+ #
# file_field("name", 40, 100)
# # <INPUT TYPE="file" NAME="name" SIZE="40" MAXLENGTH="100">
- #
+ #
# file_field("NAME" => "name", "SIZE" => 40)
# # <INPUT TYPE="file" NAME="name" SIZE="40">
def file_field(name = "", size = 20, maxlength = nil)
@@ -1533,7 +1533,7 @@ class CGI
#
# +method+ should be either "get" or "post", and defaults to the latter.
# +action+ defaults to the current CGI script name. +enctype+
- # defaults to "application/x-www-form-urlencoded".
+ # defaults to "application/x-www-form-urlencoded".
#
# Alternatively, the attributes can be specified as a hash.
#
@@ -1541,19 +1541,19 @@ class CGI
#
# form{ "string" }
# # <FORM METHOD="post" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
- #
+ #
# form("get") { "string" }
# # <FORM METHOD="get" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
- #
+ #
# form("get", "url") { "string" }
# # <FORM METHOD="get" ACTION="url" ENCTYPE="application/x-www-form-urlencoded">string</FORM>
- #
+ #
# form("METHOD" => "post", "ENCTYPE" => "enctype") { "string" }
# # <FORM METHOD="post" ENCTYPE="enctype">string</FORM>
def form(method = "post", action = script_name, enctype = "application/x-www-form-urlencoded")
attributes = if method.kind_of?(String)
{ "METHOD" => method, "ACTION" => action,
- "ENCTYPE" => enctype }
+ "ENCTYPE" => enctype }
else
unless method.has_key?("METHOD")
method["METHOD"] = "post"
@@ -1585,10 +1585,10 @@ class CGI
#
# hidden("name")
# # <INPUT TYPE="hidden" NAME="name">
- #
+ #
# hidden("name", "value")
# # <INPUT TYPE="hidden" NAME="name" VALUE="value">
- #
+ #
# hidden("NAME" => "name", "VALUE" => "reset", "ID" => "foo")
# # <INPUT TYPE="hidden" NAME="name" VALUE="value" ID="foo">
def hidden(name = "", value = nil)
@@ -1611,36 +1611,36 @@ class CGI
# should include the entire text of this tag, including angle brackets.
#
# The body of the html element is supplied as a block.
- #
+ #
# html{ "string" }
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML>string</HTML>
- #
+ #
# html("LANG" => "ja") { "string" }
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><HTML LANG="ja">string</HTML>
- #
+ #
# html("DOCTYPE" => false) { "string" }
# # <HTML>string</HTML>
- #
+ #
# html("DOCTYPE" => '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">') { "string" }
# # <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>string</HTML>
- #
+ #
# html("PRETTY" => " ") { "<BODY></BODY>" }
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
# # <HTML>
# # <BODY>
# # </BODY>
# # </HTML>
- #
+ #
# html("PRETTY" => "\t") { "<BODY></BODY>" }
# # <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
# # <HTML>
# # <BODY>
# # </BODY>
# # </HTML>
- #
+ #
# html("PRETTY") { "<BODY></BODY>" }
# # = html("PRETTY" => " ") { "<BODY></BODY>" }
- #
+ #
# html(if $VERBOSE then "PRETTY" end) { "HTML string" }
#
def html(attributes = {}) # :yield:
@@ -1679,17 +1679,17 @@ class CGI
# Generate an Image Button Input element as a string.
#
- # +src+ is the URL of the image to use for the button. +name+
+ # +src+ is the URL of the image to use for the button. +name+
# is the input name. +alt+ is the alternative text for the image.
#
# Alternatively, the attributes can be specified as a hash.
- #
+ #
# image_button("url")
# # <INPUT TYPE="image" SRC="url">
- #
+ #
# image_button("url", "name", "string")
# # <INPUT TYPE="image" SRC="url" NAME="name" ALT="string">
- #
+ #
# image_button("SRC" => "url", "ATL" => "string")
# # <INPUT TYPE="image" SRC="url" ALT="string">
def image_button(src = "", name = nil, alt = nil)
@@ -1715,7 +1715,7 @@ class CGI
#
# img("src", "alt", 100, 50)
# # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
- #
+ #
# img("SRC" => "src", "ALT" => "alt", "WIDTH" => 100, "HEIGHT" => 50)
# # <IMG SRC="src" ALT="alt" WIDTH="100" HEIGHT="50">
def img(src = "", alt = "", width = nil, height = nil)
@@ -1741,15 +1741,15 @@ class CGI
#
# multipart_form{ "string" }
# # <FORM METHOD="post" ENCTYPE="multipart/form-data">string</FORM>
- #
+ #
# multipart_form("url") { "string" }
# # <FORM METHOD="post" ACTION="url" ENCTYPE="multipart/form-data">string</FORM>
def multipart_form(action = nil, enctype = "multipart/form-data")
attributes = if action == nil
- { "METHOD" => "post", "ENCTYPE" => enctype }
+ { "METHOD" => "post", "ENCTYPE" => enctype }
elsif action.kind_of?(String)
{ "METHOD" => "post", "ACTION" => action,
- "ENCTYPE" => enctype }
+ "ENCTYPE" => enctype }
else
unless action.has_key?("METHOD")
action["METHOD"] = "post"
@@ -1777,13 +1777,13 @@ class CGI
#
# password_field("name")
# # <INPUT TYPE="password" NAME="name" SIZE="40">
- #
+ #
# password_field("name", "value")
# # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="40">
- #
+ #
# password_field("password", "value", 80, 200)
# # <INPUT TYPE="password" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
- #
+ #
# password_field("NAME" => "name", "VALUE" => "value")
# # <INPUT TYPE="password" NAME="name" VALUE="value">
def password_field(name = "", value = nil, size = 40, maxlength = nil)
@@ -1819,21 +1819,21 @@ class CGI
# # <OPTION VALUE="bar">bar</OPTION>
# # <OPTION VALUE="baz">baz</OPTION>
# # </SELECT>
- #
+ #
# popup_menu("name", ["foo"], ["bar", true], "baz")
# # <SELECT NAME="name">
# # <OPTION VALUE="foo">foo</OPTION>
# # <OPTION VALUE="bar" SELECTED>bar</OPTION>
# # <OPTION VALUE="baz">baz</OPTION>
# # </SELECT>
- #
+ #
# popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
# # <SELECT NAME="name">
# # <OPTION VALUE="1">Foo</OPTION>
# # <OPTION SELECTED VALUE="2">Bar</OPTION>
# # <OPTION VALUE="Baz">Baz</OPTION>
# # </SELECT>
- #
+ #
# popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
# "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
# # <SELECT NAME="name" MULTIPLE SIZE="2">
@@ -1884,10 +1884,10 @@ class CGI
#
# radio_button("name", "value")
# # <INPUT TYPE="radio" NAME="name" VALUE="value">
- #
+ #
# radio_button("name", "value", true)
# # <INPUT TYPE="radio" NAME="name" VALUE="value" CHECKED>
- #
+ #
# radio_button("NAME" => "name", "VALUE" => "value", "ID" => "foo")
# # <INPUT TYPE="radio" NAME="name" VALUE="value" ID="foo">
def radio_button(name = "", value = nil, checked = nil)
@@ -1905,28 +1905,28 @@ class CGI
#
# This works the same as #checkbox_group(). However, it is not valid
# to have more than one radiobutton in a group checked.
- #
+ #
# radio_group("name", "foo", "bar", "baz")
# # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
# # <INPUT TYPE="radio" NAME="name" VALUE="bar">bar
# # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
- #
+ #
# radio_group("name", ["foo"], ["bar", true], "baz")
# # <INPUT TYPE="radio" NAME="name" VALUE="foo">foo
# # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="bar">bar
# # <INPUT TYPE="radio" NAME="name" VALUE="baz">baz
- #
+ #
# radio_group("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
# # <INPUT TYPE="radio" NAME="name" VALUE="1">Foo
# # <INPUT TYPE="radio" CHECKED NAME="name" VALUE="2">Bar
# # <INPUT TYPE="radio" NAME="name" VALUE="Baz">Baz
- #
+ #
# radio_group("NAME" => "name",
# "VALUES" => ["foo", "bar", "baz"])
- #
+ #
# radio_group("NAME" => "name",
# "VALUES" => [["foo"], ["bar", true], "baz"])
- #
+ #
# radio_group("NAME" => "name",
# "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
def radio_group(name = "", *values)
@@ -1958,10 +1958,10 @@ class CGI
#
# reset
# # <INPUT TYPE="reset">
- #
+ #
# reset("reset")
# # <INPUT TYPE="reset" VALUE="reset">
- #
+ #
# reset("VALUE" => "reset", "ID" => "foo")
# # <INPUT TYPE="reset" VALUE="reset" ID="foo">
def reset(value = nil, name = nil)
@@ -1985,13 +1985,13 @@ class CGI
#
# submit
# # <INPUT TYPE="submit">
- #
+ #
# submit("ok")
# # <INPUT TYPE="submit" VALUE="ok">
- #
+ #
# submit("ok", "button1")
# # <INPUT TYPE="submit" VALUE="ok" NAME="button1">
- #
+ #
# submit("VALUE" => "ok", "NAME" => "button1", "ID" => "foo")
# # <INPUT TYPE="submit" VALUE="ok" NAME="button1" ID="foo">
def submit(value = nil, name = nil)
@@ -2014,16 +2014,16 @@ class CGI
#
# text_field("name")
# # <INPUT TYPE="text" NAME="name" SIZE="40">
- #
+ #
# text_field("name", "value")
# # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="40">
- #
+ #
# text_field("name", "value", 80)
# # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80">
- #
+ #
# text_field("name", "value", 80, 200)
# # <INPUT TYPE="text" NAME="name" VALUE="value" SIZE="80" MAXLENGTH="200">
- #
+ #
# text_field("NAME" => "name", "VALUE" => "value")
# # <INPUT TYPE="text" NAME="name" VALUE="value">
def text_field(name = "", value = nil, size = 40, maxlength = nil)
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index 2dea08cf75..0d7bfcbdae 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -13,7 +13,7 @@
#
# This file provides the +CGI::Session+ class, which provides session
# support for CGI scripts. A session is a sequence of HTTP requests
-# and responses linked together and associated with a single client.
+# and responses linked together and associated with a single client.
# Information associated with the session is stored
# on the server between requests. A session id is passed between client
# and server with every request and response, transparently
@@ -28,7 +28,7 @@ require 'tmpdir'
class CGI
- # Class representing an HTTP session. See documentation for the file
+ # Class representing an HTTP session. See documentation for the file
# cgi/session.rb for an introduction to HTTP sessions.
#
# == Lifecycle
@@ -47,7 +47,7 @@ class CGI
# == Setting and retrieving session data.
#
# The Session class associates data with a session as key-value pairs.
- # This data can be set and retrieved by indexing the Session instance
+ # This data can be set and retrieved by indexing the Session instance
# using '[]', much the same as hashes (although other hash methods
# are not supported).
#
@@ -60,21 +60,21 @@ class CGI
#
# == Storing session state
#
- # The caller can specify what form of storage to use for the session's
+ # The caller can specify what form of storage to use for the session's
# data with the +database_manager+ option to CGI::Session::new. The
# following storage classes are provided as part of the standard library:
#
- # CGI::Session::FileStore:: stores data as plain text in a flat file. Only
- # works with String data. This is the default
+ # CGI::Session::FileStore:: stores data as plain text in a flat file. Only
+ # works with String data. This is the default
# storage type.
- # CGI::Session::MemoryStore:: stores data in an in-memory hash. The data
- # only persists for as long as the current ruby
+ # CGI::Session::MemoryStore:: stores data in an in-memory hash. The data
+ # only persists for as long as the current ruby
# interpreter instance does.
# CGI::Session::PStore:: stores data in Marshalled format. Provided by
- # cgi/session/pstore.rb. Supports data of any type,
+ # cgi/session/pstore.rb. Supports data of any type,
# and provides file-locking and transaction support.
#
- # Custom storage types can also be created by defining a class with
+ # Custom storage types can also be created by defining a class with
# the following methods:
#
# new(session, options)
@@ -99,14 +99,14 @@ class CGI
# The simplest way to do this is via cookies. The CGI::Session class
# provides transparent support for session id communication via cookies
# if the client has cookies enabled.
- #
+ #
# If the client has cookies disabled, the session id must be included
# as a parameter of all requests sent by the client to the server. The
# CGI::Session class in conjunction with the CGI class will transparently
# add the session id as a hidden input field to all forms generated
# using the CGI#form() HTML generation method. No built-in support is
# provided for other mechanisms, such as URL re-writing. The caller is
- # responsible for extracting the session id from the session_id
+ # responsible for extracting the session id from the session_id
# attribute and manually encoding it in URLs and adding it as a hidden
# input to HTML forms created by other mechanisms. Also, session expiry
# is not automatically handled.
@@ -124,10 +124,10 @@ class CGI
# session = CGI::Session.new(cgi,
# 'database_manager' => CGI::Session::PStore, # use PStore
# 'session_key' => '_rb_sess_id', # custom session key
- # 'session_expires' => Time.now + 30 * 60, # 30 minute timeout
+ # 'session_expires' => Time.now + 30 * 60, # 30 minute timeout
# 'prefix' => 'pstore_sid_') # PStore option
# if cgi.has_key?('user_name') and cgi['user_name'] != ''
- # # coerce to String: cgi[] returns the
+ # # coerce to String: cgi[] returns the
# # string-like CGI::QueryExtension::Value
# session['user_name'] = cgi['user_name'].to_s
# elsif !session['user_name']
@@ -143,11 +143,11 @@ class CGI
# cgi = CGI.new("html4")
#
# # We make sure to delete an old session if one exists,
- # # not just to free resources, but to prevent the session
+ # # not just to free resources, but to prevent the session
# # from being maliciously hijacked later on.
# begin
- # session = CGI::Session.new(cgi, 'new_session' => false)
- # session.delete
+ # session = CGI::Session.new(cgi, 'new_session' => false)
+ # session.delete
# rescue ArgumentError # if no old session
# end
# session = CGI::Session.new(cgi, 'new_session' => true)
@@ -172,7 +172,7 @@ class CGI
# The session id is an MD5 hash based upon the time,
# a random number, and a constant string. This routine
# is used internally for automatically generated
- # session ids.
+ # session ids.
def create_new_id
require 'securerandom'
begin
@@ -205,7 +205,7 @@ class CGI
# it is retrieved from the +session_key+ parameter
# of the request, or automatically generated for
# a new session.
- # new_session:: if true, force creation of a new session. If not set,
+ # new_session:: if true, force creation of a new session. If not set,
# a new session is only created if none currently
# exists. If false, a new session is never created,
# and if none currently exists and the +session_id+
@@ -220,7 +220,7 @@ class CGI
# The following options are also recognised, but only apply if the
# session id is stored in a cookie.
#
- # session_expires:: the time the current session expires, as a
+ # session_expires:: the time the current session expires, as a
# +Time+ object. If not set, the session will terminate
# when the user's browser is closed.
# session_domain:: the hostname domain for which this session is valid.
@@ -232,10 +232,10 @@ class CGI
# +option+ is also passed on to the session storage class initializer; see
# the documentation for each session storage class for the options
# they support.
- #
+ #
# The retrieved or created session is automatically added to +request+
# as a cookie, and also to its +output_hidden+ table, which is used
- # to add hidden input elements to forms.
+ # to add hidden input elements to forms.
#
# *WARNING* the +output_hidden+
# fields are surrounded by a <fieldset> tag in HTML 4 generation, which
@@ -322,11 +322,11 @@ class CGI
# Store session data on the server. For some session storage types,
# this is a no-op.
- def update
+ def update
@dbman.update
end
- # Store session data on the server and close the session storage.
+ # Store session data on the server and close the session storage.
# For some session storage types, this is a no-op.
def close
@dbman.close
@@ -358,7 +358,7 @@ class CGI
# created. The session id must only contain alphanumeric
# characters; automatically generated session ids observe
# this requirement.
- #
+ #
# +option+ is a hash of options for the initializer. The
# following options are recognised:
#
@@ -450,7 +450,7 @@ class CGI
# In-memory session storage class.
#
# Implements session storage as a global in-memory hash. Session
- # data will only persist for as long as the ruby interpreter
+ # data will only persist for as long as the ruby interpreter
# instance does.
class MemoryStore
GLOBAL_HASH_TABLE = {} #:nodoc:
diff --git a/lib/cgi/session/pstore.rb b/lib/cgi/session/pstore.rb
index 3d204d5dc0..7a9e68f6e5 100644
--- a/lib/cgi/session/pstore.rb
+++ b/lib/cgi/session/pstore.rb
@@ -2,7 +2,7 @@
# cgi/session/pstore.rb - persistent storage of marshalled session data
#
# Documentation: William Webber ([email protected])
-#
+#
# == Overview
#
# This file provides the CGI::Session::PStore class, which builds
@@ -29,7 +29,7 @@ class CGI
# created. The session id must only contain alphanumeric
# characters; automatically generated session ids observe
# this requirement.
- #
+ #
# +option+ is a hash of options for the initializer. The
# following options are recognised:
#
@@ -77,7 +77,7 @@ class CGI
end
# Save session state to the session's PStore file.
- def update
+ def update
@p.transaction do
@p['hash'] = @hash
end
diff --git a/lib/complex.rb b/lib/complex.rb
index 808cecc95d..b79e8262af 100644
--- a/lib/complex.rb
+++ b/lib/complex.rb
@@ -1,5 +1,5 @@
#
-# complex.rb -
+# complex.rb -
# $Release Version: 0.5 $
# $Revision: 1.3 $
# $Date: 1998/07/08 10:05:28 $
@@ -14,7 +14,7 @@
# Complex numbers can be created in the following manner:
# - <tt>Complex(a, b)</tt>
# - <tt>Complex.polar(radius, theta)</tt>
-#
+#
# Additionally, note the following:
# - <tt>Complex::I</tt> (the mathematical constant <i>i</i>)
# - <tt>Numeric#im</tt> (e.g. <tt>5.im -> 0+5i</tt>)
@@ -38,14 +38,14 @@ class Numeric
def im
Complex(0, self)
end
-
+
#
# The real part of a complex number, i.e. <i>self</i>.
#
def real
self
end
-
+
#
# The imaginary part of a complex number, i.e. 0.
#
@@ -53,7 +53,7 @@ class Numeric
0
end
alias imag image
-
+
#
# See Complex#arg.
#
@@ -61,14 +61,14 @@ class Numeric
Math.atan2!(0, self)
end
alias angle arg
-
+
#
# See Complex#polar.
#
def polar
return abs, arg
end
-
+
#
# See Complex#conjugate (short answer: returns <i>self</i>).
#
@@ -145,7 +145,7 @@ class Complex < Numeric
x + y
end
end
-
+
#
# Subtraction with real or complex number.
#
@@ -161,7 +161,7 @@ class Complex < Numeric
x - y
end
end
-
+
#
# Multiplication with real or complex number.
#
@@ -177,7 +177,7 @@ class Complex < Numeric
x * y
end
end
-
+
#
# Division by real or complex number.
#
@@ -191,7 +191,7 @@ class Complex < Numeric
x/y
end
end
-
+
def quo(other)
Complex(@real.quo(1), @image.quo(1)) / other
end
@@ -240,7 +240,7 @@ class Complex < Numeric
x**y
end
end
-
+
#
# Remainder after division by a real or complex number.
#
@@ -254,7 +254,7 @@ class Complex < Numeric
x % y
end
end
-
+
#--
# def divmod(other)
# if other.kind_of?(Complex)
@@ -269,7 +269,7 @@ class Complex < Numeric
# end
# end
#++
-
+
#
# Absolute value (aka modulus): distance from the zero point on the complex
# plane.
@@ -277,14 +277,14 @@ class Complex < Numeric
def abs
Math.hypot(@real, @image)
end
-
+
#
# Square of the absolute value.
#
def abs2
@real*@real + @image*@image
end
-
+
#
# Argument (angle from (1,0) on the complex plane).
#
@@ -292,14 +292,14 @@ class Complex < Numeric
Math.atan2!(@image, @real)
end
alias angle arg
-
+
#
# Returns the absolute value _and_ the argument.
#
def polar
return abs, arg
end
-
+
#
# Complex conjugate (<tt>z + z.conjugate = 2 * z.real</tt>).
#
@@ -307,14 +307,14 @@ class Complex < Numeric
Complex(@real, -@image)
end
alias conj conjugate
-
+
#
# Compares the absolute values of the two numbers.
#
def <=> (other)
self.abs <=> other.abs
end
-
+
#
# Test for numerical equality (<tt>a == a + 0<i>i</i></tt>).
#
@@ -345,7 +345,7 @@ class Complex < Numeric
def denominator
@real.denominator.lcm(@image.denominator)
end
-
+
#
# FIXME
#
@@ -354,7 +354,7 @@ class Complex < Numeric
Complex(@real.numerator*(cd/@real.denominator),
@image.numerator*(cd/@image.denominator))
end
-
+
#
# Standard string representation of the complex number.
#
@@ -381,14 +381,14 @@ class Complex < Numeric
end
end
end
-
+
#
# Returns a hash code for the complex number.
#
def hash
@real.hash ^ @image.hash
end
-
+
#
# Returns "<tt>Complex(<i>real</i>, <i>image</i>)</tt>".
#
@@ -396,19 +396,19 @@ class Complex < Numeric
sprintf("Complex(%s, %s)", @real.inspect, @image.inspect)
end
-
+
#
# +I+ is the imaginary number. It exists at point (0,1) on the complex plane.
#
I = Complex(0,1)
-
+
# The real part of a complex number.
attr :real
# The imaginary part of a complex number.
attr :image
alias imag image
-
+
end
class Integer
@@ -457,7 +457,7 @@ module Math
alias atan2! atan2
alias acosh! acosh
alias asinh! asinh
- alias atanh! atanh
+ alias atanh! atanh
# Redefined to handle a Complex argument.
def sqrt(z)
@@ -477,7 +477,7 @@ module Math
end
end
end
-
+
# Redefined to handle a Complex argument.
def exp(z)
if Complex.generic?(z)
@@ -486,7 +486,7 @@ module Math
Complex(exp!(z.real) * cos!(z.image), exp!(z.real) * sin!(z.image))
end
end
-
+
# Redefined to handle a Complex argument.
def cos(z)
if Complex.generic?(z)
@@ -496,7 +496,7 @@ module Math
-sin!(z.real)*sinh!(z.image))
end
end
-
+
# Redefined to handle a Complex argument.
def sin(z)
if Complex.generic?(z)
@@ -506,7 +506,7 @@ module Math
cos!(z.real)*sinh!(z.image))
end
end
-
+
# Redefined to handle a Complex argument.
def tan(z)
if Complex.generic?(z)
@@ -539,7 +539,7 @@ module Math
sinh(z)/cosh(z)
end
end
-
+
# Redefined to handle a Complex argument.
def log(z)
if Complex.generic?(z) and z >= 0
@@ -549,7 +549,7 @@ module Math
Complex(log!(r.abs), theta)
end
end
-
+
# Redefined to handle a Complex argument.
def log10(z)
if Complex.generic?(z)
@@ -649,7 +649,7 @@ module Math
module_function :asinh
module_function :atanh!
module_function :atanh
-
+
end
# Documentation comments:
diff --git a/lib/csv.rb b/lib/csv.rb
index f6c12fa285..66804b550e 100644
--- a/lib/csv.rb
+++ b/lib/csv.rb
@@ -1,13 +1,13 @@
# CSV -- module for generating/parsing CSV data.
# Copyright (C) 2000-2004 NAKAMURA, Hiroshi <[email protected]>.
-
+
# $Id$
-
+
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
# redistribute it and/or modify it under the same terms of Ruby's license;
# either the dual license version in 2003, or any later version.
-
-
+
+
class CSV
class IllegalFormatError < RuntimeError; end
@@ -97,7 +97,7 @@ class CSV
def CSV.read(path, length = nil, offset = nil)
CSV.parse(IO.read(path, length, offset))
end
-
+
def CSV.readlines(path, rs = nil)
reader = open_reader(path, 'r', ',', rs)
begin
@@ -181,7 +181,7 @@ class CSV
end
result_str
end
-
+
# Parse a line from string. Consider using CSV.parse_line instead.
# To parse lines in CSV string, see EXAMPLE below.
#
@@ -239,7 +239,7 @@ class CSV
end
return parsed_cells, idx
end
-
+
# Convert a line from cells data to string. Consider using CSV.generate_line
# instead. To generate multi-row CSV string, see EXAMPLE below.
#
@@ -299,7 +299,7 @@ class CSV
end
parsed_cells
end
-
+
# Private class methods.
class << self
private
@@ -334,7 +334,7 @@ class CSV
end
nil
else
- writer = CSV::Writer.create(file, fs, rs)
+ writer = CSV::Writer.create(file, fs, rs)
writer.close_on_terminate
writer
end
@@ -480,7 +480,7 @@ class CSV
last_idx = idx
return :DT_EOS, idx, cell
end
-
+
def generate_body(cell, out_dev, fs, rs)
if cell.nil?
# empty
@@ -498,7 +498,7 @@ class CSV
end
end
end
-
+
def generate_separator(type, out_dev, fs, rs)
case type
when :DT_COLSEP
@@ -586,7 +586,7 @@ class CSV
# Define if needed.
end
end
-
+
class StringReader < Reader
def initialize(string, fs = ',', rs = nil)
@@ -800,7 +800,7 @@ private
# returns char at idx if n == nil.
# returns a partial string, from idx to (idx + n) if n != nil. at EOF,
# the string size could not equal to arg n.
- def [](idx, n = nil)
+ def [](idx, n = nil)
if idx < 0
return nil
end
@@ -846,7 +846,7 @@ private
end
end
alias get []
-
+
# drop a string from the stream.
# returns dropped size. at EOF, dropped size might not equals to arg n.
# Once you drop the head of the stream, access to the dropped part via []
@@ -878,11 +878,11 @@ private
end
size_dropped
end
-
+
def is_eos?
return idx_is_eos?(0)
end
-
+
# WARN: Do not instantiate this class directly. Define your own class
# which derives this class and define 'read' instance method.
def initialize
@@ -893,13 +893,13 @@ private
add_buf
@cur_buf = @buf_tail_idx
end
-
+
protected
def terminate
while (rel_buf); end
end
-
+
# protected method 'read' must be defined in derived classes.
# CAUTION: Returning a string which size is not equal to 'size' means
# EnfOfStream. When it is not at EOS, you must block the callee, try to
@@ -907,9 +907,9 @@ private
def read(size) # raise EOFError
raise NotImplementedError.new('Method read must be defined in a derived class.')
end
-
+
private
-
+
def buf_size(idx)
@buf_list[idx].size
end
@@ -937,7 +937,7 @@ private
true
end
end
-
+
def rel_buf
if (@cur_buf < 0)
return false
@@ -951,11 +951,11 @@ private
return true
end
end
-
+
def idx_is_eos?(idx)
(@is_eos and ((@cur_buf < 0) or (@cur_buf == @buf_tail_idx)))
end
-
+
BufSize = 1024 * 8
end
@@ -974,7 +974,7 @@ private
@s = s
super()
end
-
+
def close
terminate
end
@@ -984,7 +984,7 @@ private
def read(size)
@s.read(size)
end
-
+
def terminate
super()
end
diff --git a/lib/debug.rb b/lib/debug.rb
index 9ae119f8fb..0c0b1d86d0 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -256,7 +256,7 @@ class Context
def debug_command(file, line, id, binding)
MUTEX.lock
unless defined?($debugger_restart) and $debugger_restart
- callcc{|c| $debugger_restart = c}
+ callcc{|c| $debugger_restart = c}
end
set_last_thread(Thread.current)
frame_pos = 0
@@ -335,7 +335,7 @@ class Context
stdout.print "Breakpoints:\n"
for b in break_points
if b[0] and b[1] == 0
- stdout.printf " %d %s:%s\n", n, b[2], b[3]
+ stdout.printf " %d %s:%s\n", n, b[2], b[3]
end
n += 1
end
@@ -751,7 +751,7 @@ EOHELP
when 'end'
@frames.shift
- when 'raise'
+ when 'raise'
excn_handle(file, line, id, binding)
end
@@ -921,7 +921,7 @@ class << DEBUGGER__
@stdout.print "Already stopped.\n"
else
thread_list(@thread_list[th])
- context(th).suspend
+ context(th).suspend
end
when /^resume\s+(\d+)/
diff --git a/lib/delegate.rb b/lib/delegate.rb
index 43549946c9..9a4f76f164 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -37,16 +37,16 @@
# def initialize
# @source = SimpleDelegator.new([])
# end
-#
+#
# def stats( records )
# @source.__setobj__(records)
-#
+#
# "Elements: #{@source.size}\n" +
# " Non-Nil: #{@source.compact.size}\n" +
# " Unique: #{@source.uniq.size}\n"
# end
# end
-#
+#
# s = Stats.new
# puts s.stats(%w{James Edward Gray II})
# puts
@@ -57,7 +57,7 @@
# Elements: 4
# Non-Nil: 4
# Unique: 4
-#
+#
# Elements: 8
# Non-Nil: 7
# Unique: 6
@@ -72,19 +72,19 @@
#
# class Tempfile < DelegateClass(File)
# # constant and class member data initialization...
-#
+#
# def initialize(basename, tmpdir=Dir::tmpdir)
# # build up file path/name in var tmpname...
-#
+#
# @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL, 0600)
-#
+#
# # ...
-#
+#
# super(@tmpfile)
-#
+#
# # below this point, all methods of File are supported...
# end
-#
+#
# # ...
# end
#
@@ -97,15 +97,15 @@
# super # pass obj to Delegator constructor, required
# @_sd_obj = obj # store obj for future use
# end
-#
+#
# def __getobj__
# @_sd_obj # return object we are delegating to, required
# end
-#
+#
# def __setobj__(obj)
# @_sd_obj = obj # change delegation object, a feature we're providing
# end
-#
+#
# # ...
# end
@@ -159,10 +159,10 @@ class Delegator
target.__send__(m, *args, &block)
end
- #
- # Checks for a method provided by this the delegate object by fowarding the
+ #
+ # Checks for a method provided by this the delegate object by fowarding the
# call through \_\_getobj\_\_.
- #
+ #
def respond_to?(m, include_private = false)
return true if super
return self.__getobj__.respond_to?(m, include_private)
diff --git a/lib/drb/drb.rb b/lib/drb/drb.rb
index 795dc1ac4b..90a68d831e 100644
--- a/lib/drb/drb.rb
+++ b/lib/drb/drb.rb
@@ -18,7 +18,7 @@
#
# The Ruby standard library contains the core classes of the dRuby package.
# However, the full package also includes access control lists and the
-# Rinda tuple-space distributed task management system, as well as a
+# Rinda tuple-space distributed task management system, as well as a
# large number of samples. The full dRuby package can be downloaded from
# the dRuby home page (see *References*).
#
@@ -121,7 +121,7 @@ require 'drb/eq'
# are forwarded to the local object, as described in the discussion of
# DRbObjects. This has semantics similar to the normal Ruby
# pass-by-reference.
-#
+#
# The easiest way to signal that we want an otherwise marshallable
# object to be passed or returned as a DRbObject reference, rather
# than marshalled and sent as a copy, is to include the
@@ -135,7 +135,7 @@ require 'drb/eq'
# passed back to the remote execution context to be collected, before
# the collected values are finally returned to the local context as
# the return value of the method invocation.
-#
+#
# == Examples of usage
#
# For more dRuby samples, see the +samples+ directory in the full
@@ -148,33 +148,33 @@ require 'drb/eq'
# starting the server code first.
#
# ==== Server code
-#
+#
# require 'drb/drb'
-#
+#
# # The URI for the server to connect to
-# URI="druby://localhost:8787"
-#
+# URI="druby://localhost:8787"
+#
# class TimeServer
-#
+#
# def get_current_time
# return Time.now
# end
-#
+#
# end
-#
+#
# # The object that handles requests on the server
# FRONT_OBJECT=TimeServer.new
#
# $SAFE = 1 # disable eval() and friends
-#
+#
# DRb.start_service(URI, FRONT_OBJECT)
# # Wait for the drb server thread to finish before exiting.
# DRb.thread.join
#
# ==== Client code
-#
+#
# require 'drb/drb'
-#
+#
# # The URI to connect to
# SERVER_URI="druby://localhost:8787"
#
@@ -184,43 +184,43 @@ require 'drb/eq'
# # as soon as we pass a non-marshallable object as an argument
# # to a dRuby call.
# DRb.start_service
-#
+#
# timeserver = DRbObject.new_with_uri(SERVER_URI)
-# puts timeserver.get_current_time
+# puts timeserver.get_current_time
#
# === Remote objects under dRuby
#
# This example illustrates returning a reference to an object
# from a dRuby call. The Logger instances live in the server
# process. References to them are returned to the client process,
-# where methods can be invoked upon them. These methods are
+# where methods can be invoked upon them. These methods are
# executed in the server process.
#
# ==== Server code
-#
+#
# require 'drb/drb'
-#
+#
# URI="druby://localhost:8787"
-#
+#
# class Logger
#
# # Make dRuby send Logger instances as dRuby references,
# # not copies.
# include DRb::DRbUndumped
-#
+#
# def initialize(n, fname)
# @name = n
# @filename = fname
# end
-#
+#
# def log(message)
# File.open(@filename, "a") do |f|
# f.puts("#{Time.now}: #{@name}: #{message}")
# end
# end
-#
+#
# end
-#
+#
# # We have a central object for creating and retrieving loggers.
# # This retains a local reference to all loggers created. This
# # is so an existing logger can be looked up by name, but also
@@ -228,12 +228,12 @@ require 'drb/eq'
# # reference to an object is not sufficient to prevent it being
# # garbage collected!
# class LoggerFactory
-#
+#
# def initialize(bdir)
# @basedir = bdir
# @loggers = {}
# end
-#
+#
# def get_logger(name)
# if [email protected]_key? name
# # make the filename safe, then declare it to be so
@@ -242,34 +242,34 @@ require 'drb/eq'
# end
# return @loggers[name]
# end
-#
+#
# end
-#
+#
# FRONT_OBJECT=LoggerFactory.new("/tmp/dlog")
#
# $SAFE = 1 # disable eval() and friends
-#
+#
# DRb.start_service(URI, FRONT_OBJECT)
# DRb.thread.join
#
# ==== Client code
#
# require 'drb/drb'
-#
+#
# SERVER_URI="druby://localhost:8787"
#
# DRb.start_service
-#
+#
# log_service=DRbObject.new_with_uri(SERVER_URI)
-#
+#
# ["loga", "logb", "logc"].each do |logname|
-#
+#
# logger=log_service.get_logger(logname)
-#
+#
# logger.log("Hello, world!")
# logger.log("Goodbye, world!")
# logger.log("=== EOT ===")
-#
+#
# end
#
# == Security
@@ -288,9 +288,9 @@ require 'drb/eq'
# ro.instance_eval("`rm -rf *`")
#
# The dangers posed by instance_eval and friends are such that a
-# DRbServer should generally be run with $SAFE set to at least
-# level 1. This will disable eval() and related calls on strings
-# passed across the wire. The sample usage code given above follows
+# DRbServer should generally be run with $SAFE set to at least
+# level 1. This will disable eval() and related calls on strings
+# passed across the wire. The sample usage code given above follows
# this practice.
#
# A DRbServer can be configured with an access control list to
@@ -360,7 +360,7 @@ module DRb
#
# This, the default implementation, uses an object's local ObjectSpace
# __id__ as its id. This means that an object's identification over
- # drb remains valid only while that object instance remains alive
+ # drb remains valid only while that object instance remains alive
# within the server runtime.
#
# For alternative mechanisms, see DRb::TimerIdConv in rdb/timeridconv.rb
@@ -374,7 +374,7 @@ module DRb
def to_obj(ref)
ObjectSpace._id2ref(ref)
end
-
+
# Convert an object into a reference id.
#
# This implementation returns the object's __id__ in the local
@@ -390,7 +390,7 @@ module DRb
# called over drb, then the object remains in the server space
# and a reference to the object is returned, rather than the
# object being marshalled and moved into the client space.
- module DRbUndumped
+ module DRbUndumped
def _dump(dummy) # :nodoc:
raise TypeError, 'can\'t dump'
end
@@ -424,7 +424,7 @@ module DRb
def self._load(s) # :nodoc:
Marshal::load(s)
end
-
+
def _dump(lv) # :nodoc:
Marshal::dump(@unknown)
end
@@ -456,11 +456,11 @@ module DRb
# +name+ attribute. The marshalled object is held in the +buf+
# attribute.
class DRbUnknown
-
+
# Create a new DRbUnknown object.
#
# +buf+ is a string containing a marshalled object that could not
- # be unmarshalled. +err+ is the error message that was raised
+ # be unmarshalled. +err+ is the error message that was raised
# when the unmarshalling failed. It is used to determine the
# name of the unmarshalled object.
def initialize(err, buf)
@@ -499,7 +499,7 @@ module DRb
# Attempt to load the wrapped marshalled object again.
#
# If the class of the object is now known locally, the object
- # will be unmarshalled and returned. Otherwise, a new
+ # will be unmarshalled and returned. Otherwise, a new
# but identical DRbUnknown object will be returned.
def reload
self.class._load(@buf)
@@ -513,7 +513,7 @@ module DRb
class DRbArray
def initialize(ary)
- @ary = ary.collect { |obj|
+ @ary = ary.collect { |obj|
if obj.kind_of? DRbUndumped
DRbObject.new(obj)
else
@@ -607,7 +607,7 @@ module DRb
rescue
raise(DRbConnError, $!.message, $!.backtrace)
end
-
+
def recv_request(stream) # :nodoc:
ref = load(stream)
ro = DRb.to_obj(ref)
@@ -656,10 +656,10 @@ module DRb
# using configuration +config+. Return a
# protocol instance for this listener.
# [uri_option(uri, config)] Take a URI, possibly containing an option
- # component (e.g. a trailing '?param=val'),
+ # component (e.g. a trailing '?param=val'),
# and return a [uri, option] tuple.
#
- # All of these methods should raise a DRbBadScheme error if the URI
+ # All of these methods should raise a DRbBadScheme error if the URI
# does not identify the protocol they support (e.g. "druby:" for
# the standard Ruby protocol). This is how the DRbProtocol module,
# given a URI, determines which protocol implementation serves that
@@ -675,14 +675,14 @@ module DRb
#
# The protocol instance returned by #open must have the following methods:
#
- # [send_request (ref, msg_id, arg, b)]
+ # [send_request (ref, msg_id, arg, b)]
# Send a request to +ref+ with the given message id and arguments.
# This is most easily implemented by calling DRbMessage.send_request,
# providing a stream that sits on top of the current protocol.
# [recv_reply]
# Receive a reply from the server and return it as a [success-boolean,
# reply-value] pair. This is most easily implemented by calling
- # DRb.recv_reply, providing a stream that sits on top of the
+ # DRb.recv_reply, providing a stream that sits on top of the
# current protocol.
# [alive?]
# Is this connection still alive?
@@ -725,7 +725,7 @@ module DRb
# URI by raising a DRbBadScheme error. If no protocol recognises the
# URI, then a DRbBadURI error is raised. If a protocol accepts the
# URI, but an error occurs in opening it, a DRbConnError is raised.
- def open(uri, config, first=true)
+ def open(uri, config, first=true)
@protocol.each do |prot|
begin
return prot.open(uri, config)
@@ -744,14 +744,14 @@ module DRb
end
module_function :open
- # Open a server listening for connections at +uri+ with
+ # Open a server listening for connections at +uri+ with
# configuration +config+.
#
# The DRbProtocol module asks each registered protocol in turn to
- # try to open a server at the URI. Each protocol signals that it does
- # not handle that URI by raising a DRbBadScheme error. If no protocol
- # recognises the URI, then a DRbBadURI error is raised. If a protocol
- # accepts the URI, but an error occurs in opening it, the underlying
+ # try to open a server at the URI. Each protocol signals that it does
+ # not handle that URI by raising a DRbBadScheme error. If no protocol
+ # recognises the URI, then a DRbBadURI error is raised. If a protocol
+ # accepts the URI, but an error occurs in opening it, the underlying
# error is passed on to the caller.
def open_server(uri, config, first=true)
@protocol.each do |prot|
@@ -773,7 +773,7 @@ module DRb
# The DRbProtocol module asks each registered protocol in turn to
# try to parse the URI. Each protocol signals that it does not handle that
# URI by raising a DRbBadScheme error. If no protocol recognises the
- # URI, then a DRbBadURI error is raised.
+ # URI, then a DRbBadURI error is raised.
def uri_option(uri, config, first=true)
@protocol.each do |prot|
begin
@@ -837,9 +837,9 @@ module DRb
end
def self.open_server_inaddr_any(host, port)
- infos = Socket::getaddrinfo(host, nil,
+ infos = Socket::getaddrinfo(host, nil,
Socket::AF_UNSPEC,
- Socket::SOCK_STREAM,
+ Socket::SOCK_STREAM,
0,
Socket::AI_PASSIVE)
families = Hash[*infos.collect { |af, *_| af }.uniq.zip([]).flatten]
@@ -848,7 +848,7 @@ module DRb
return TCPServer.open(port)
end
- # Open a server listening for connections at +uri+ using
+ # Open a server listening for connections at +uri+ using
# configuration +config+.
def self.open_server(uri, config)
uri = 'druby://:0' unless uri
@@ -894,7 +894,7 @@ module DRb
def peeraddr
@socket.peeraddr
end
-
+
# Get the socket.
def stream; @socket; end
@@ -902,7 +902,7 @@ module DRb
def send_request(ref, msg_id, arg, b)
@msg.send_request(stream, ref, msg_id, arg, b)
end
-
+
# On the server side, receive a request from the client.
def recv_request
@msg.recv_request(stream)
@@ -932,14 +932,14 @@ module DRb
@socket = nil
end
end
-
- # On the server side, for an instance returned by #open_server,
+
+ # On the server side, for an instance returned by #open_server,
# accept a client connection and return a new instance to handle
# the server's side of this client-server session.
def accept
while true
s = @socket.accept
- break if (@acl ? @acl.allow_socket?(s) : true)
+ break if (@acl ? @acl.allow_socket?(s) : true)
s.close
end
if @config[:tcp_original_host].to_s.size == 0
@@ -976,16 +976,16 @@ module DRb
end
attr :option
def to_s; @option; end
-
+
def ==(other)
return false unless DRbURIOption === other
@option == other.option
end
-
+
def hash
@option.hash
end
-
+
alias eql? ==
end
@@ -1002,7 +1002,7 @@ module DRb
# created to act as a stub for the remote referenced object.
def self._load(s)
uri, ref = Marshal.load(s)
-
+
if DRb.here?(uri)
obj = DRb.to_obj(ref)
if ((! obj.tainted?) && Thread.current[:drb_untaint])
@@ -1052,7 +1052,7 @@ module DRb
end
# Get the URI of the remote object.
- def __drburi
+ def __drburi
@uri
end
@@ -1080,7 +1080,7 @@ module DRb
if DRb.here?(@uri)
obj = DRb.to_obj(@ref)
DRb.current_server.check_insecure_method(obj, msg_id)
- return obj.__send__(msg_id, *a, &b)
+ return obj.__send__(msg_id, *a, &b)
end
succ, result = self.class.with_friend(@uri) do
@@ -1103,7 +1103,7 @@ module DRb
def self.with_friend(uri)
friend = DRb.fetch_server(uri)
return yield() unless friend
-
+
save = Thread.current['DRb']
Thread.current['DRb'] = { 'server' => friend }
return yield
@@ -1115,7 +1115,7 @@ module DRb
prefix = "(#{uri}) "
bt = []
result.backtrace.each do |x|
- break if /`__send__'$/ =~ x
+ break if /`__send__'$/ =~ x
if /^\(druby:\/\// =~ x
bt.push(x)
else
@@ -1266,14 +1266,14 @@ module DRb
def self.verbose=(on)
@@verbose = on
end
-
+
# Get the default value of the :verbose option.
def self.verbose
@@verbose
end
def self.make_config(hash={}) # :nodoc:
- default_config = {
+ default_config = {
:idconv => @@idconv,
:verbose => @@verbose,
:tcp_acl => @@acl,
@@ -1363,7 +1363,7 @@ module DRb
attr_reader :thread
# The front object of the DRbServer.
- #
+ #
# This object receives remote method calls made on the server's
# URI alone, with an object id.
attr_reader :front
@@ -1456,7 +1456,7 @@ module DRb
def any_to_s(obj)
obj.to_s + ":#{obj.class}"
rescue
- sprintf("#<%s:0x%lx>", obj.class, obj.__id__)
+ sprintf("#<%s:0x%lx>", obj.class, obj.__id__)
end
# Check that a method is callable via dRuby.
@@ -1464,14 +1464,14 @@ module DRb
# +obj+ is the object we want to invoke the method on. +msg_id+ is the
# method name, as a Symbol.
#
- # If the method is an insecure method (see #insecure_method?) a
+ # If the method is an insecure method (see #insecure_method?) a
# SecurityError is thrown. If the method is private or undefined,
# a NameError is thrown.
def check_insecure_method(obj, msg_id)
return true if Proc === obj && msg_id == :__drb_yield
raise(ArgumentError, "#{any_to_s(msg_id)} is not a symbol") unless Symbol == msg_id.class
raise(SecurityError, "insecure method `#{msg_id}'") if insecure_method?(msg_id)
-
+
if obj.private_methods.include?(msg_id.to_s)
desc = any_to_s(obj)
raise NoMethodError, "private method `#{msg_id}' called for #{desc}"
@@ -1483,7 +1483,7 @@ module DRb
end
end
public :check_insecure_method
-
+
class InvokeMethod # :nodoc:
def initialize(drb_server, client)
@drb_server = drb_server
@@ -1505,7 +1505,7 @@ module DRb
perform_with_block
}.value
else
- @result = Thread.new {
+ @result = Thread.new {
Thread.current['DRb'] = info
$SAFE = @safe_level
perform_without_block
@@ -1520,7 +1520,7 @@ module DRb
end
@succ = true
if @msg_id == :to_ary && @result.class == Array
- @result = DRbArray.new(@result)
+ @result = DRbArray.new(@result)
end
return @succ, @result
rescue StandardError, ScriptError, Interrupt
@@ -1536,7 +1536,7 @@ module DRb
@argv = argv
@block = block
end
-
+
def check_insecure_method
@drb_server.check_insecure_method(@obj, @msg_id)
end
@@ -1545,7 +1545,7 @@ module DRb
init_with_client
check_insecure_method
end
-
+
def perform_without_block
if Proc === @obj && @msg_id == :__drb_yield
if @argv.size == 1
@@ -1633,7 +1633,7 @@ module DRb
# The primary local dRuby server.
#
- # This is the server created by the #start_service call.
+ # This is the server created by the #start_service call.
attr_accessor :primary_server
module_function :primary_server=, :primary_server
@@ -1648,8 +1648,8 @@ module DRb
# If the above rule fails to find a server, a DRbServerNotFound
# error is raised.
def current_server
- drb = Thread.current['DRb']
- server = (drb && drb['server']) ? drb['server'] : @primary_server
+ drb = Thread.current['DRb']
+ server = (drb && drb['server']) ? drb['server'] : @primary_server
raise DRbServerNotFound unless server
return server
end
@@ -1695,7 +1695,7 @@ module DRb
DRbServer.make_config
end
module_function :config
-
+
# Get the front object of the current server.
#
# This raises a DRbServerNotFound error if there is no current server.
@@ -1766,7 +1766,7 @@ module DRb
@server.delete(server.uri)
end
module_function :remove_server
-
+
def fetch_server(uri)
@server[uri]
end
diff --git a/lib/drb/extserv.rb b/lib/drb/extserv.rb
index 7da8130c2b..33edddd01b 100644
--- a/lib/drb/extserv.rb
+++ b/lib/drb/extserv.rb
@@ -1,6 +1,6 @@
=begin
external service
- Copyright (c) 2000,2002 Masatoshi SEKI
+ Copyright (c) 2000,2002 Masatoshi SEKI
=end
require 'drb/drb'
diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb
index be40aea9f5..46ffb331e5 100644
--- a/lib/drb/extservm.rb
+++ b/lib/drb/extservm.rb
@@ -1,6 +1,6 @@
=begin
external service manager
- Copyright (c) 2000 Masatoshi SEKI
+ Copyright (c) 2000 Masatoshi SEKI
=end
require 'drb/drb'
@@ -21,7 +21,7 @@ module DRb
def self.command=(cmd)
@@command = cmd
end
-
+
def initialize
super()
@cond = new_cond
@@ -51,7 +51,7 @@ module DRb
end
self
end
-
+
def unregist(name)
synchronize do
@servers.delete(name)
diff --git a/lib/drb/invokemethod.rb b/lib/drb/invokemethod.rb
index 412b2ab9b5..2bcd12f5f5 100644
--- a/lib/drb/invokemethod.rb
+++ b/lib/drb/invokemethod.rb
@@ -9,7 +9,7 @@ module DRb
end
block_value = @block.call(*x)
end
-
+
def perform_with_block
@obj.__send__(@msg_id, *@argv) do |*x|
jump_error = nil
diff --git a/lib/drb/ssl.rb b/lib/drb/ssl.rb
index 58d6b7d1e0..08f97f4bc6 100644
--- a/lib/drb/ssl.rb
+++ b/lib/drb/ssl.rb
@@ -15,7 +15,7 @@ module DRb
:SSLClientCA => nil,
:SSLCACertificatePath => nil,
:SSLCACertificateFile => nil,
- :SSLVerifyMode => ::OpenSSL::SSL::VERIFY_NONE,
+ :SSLVerifyMode => ::OpenSSL::SSL::VERIFY_NONE,
:SSLVerifyDepth => nil,
:SSLVerifyCallback => nil, # custom verification
:SSLCertificateStore => nil,
@@ -31,7 +31,7 @@ module DRb
@ssl_ctx = nil
end
- def [](key);
+ def [](key);
@config[key] || DEFAULT[key]
end
@@ -41,14 +41,14 @@ module DRb
ssl.connect
ssl
end
-
+
def accept(tcp)
ssl = OpenSSL::SSL::SSLSocket.new(tcp, @ssl_ctx)
ssl.sync = true
ssl.accept
ssl
end
-
+
def setup_certificate
if @cert && @pkey
return
@@ -77,7 +77,7 @@ module DRb
cert.not_before = Time.now
cert.not_after = Time.now + (365*24*60*60)
cert.public_key = rsa.public_key
-
+
ef = OpenSSL::X509::ExtensionFactory.new(nil,cert)
cert.extensions = [
ef.create_extension("basicConstraints","CA:FALSE"),
@@ -89,7 +89,7 @@ module DRb
cert.add_extension(ef.create_extension("nsComment", comment))
end
cert.sign(rsa, OpenSSL::Digest::SHA1.new)
-
+
@cert = cert
@pkey = rsa
end
@@ -143,7 +143,7 @@ module DRb
end
port = soc.addr[1] if port == 0
@uri = "drbssl://#{host}:#{port}"
-
+
ssl_conf = SSLConfig.new(config)
ssl_conf.setup_certificate
ssl_conf.setup_ssl_context
@@ -159,7 +159,7 @@ module DRb
@ssl = is_established ? soc : nil
super(uri, soc.to_io, config)
end
-
+
def stream; @ssl; end
def close
@@ -169,12 +169,12 @@ module DRb
end
super
end
-
+
def accept
begin
while true
soc = @socket.accept
- break if (@acl ? @acl.allow_socket?(soc) : true)
+ break if (@acl ? @acl.allow_socket?(soc) : true)
soc.close
end
ssl = @config.accept(soc)
@@ -185,6 +185,6 @@ module DRb
end
end
end
-
+
DRbProtocol.add_protocol(DRbSSLSocket)
end
diff --git a/lib/drb/timeridconv.rb b/lib/drb/timeridconv.rb
index bb2c48d528..6d8935b1ef 100644
--- a/lib/drb/timeridconv.rb
+++ b/lib/drb/timeridconv.rb
@@ -19,7 +19,7 @@ module DRb
end
def add(obj)
- synchronize do
+ synchronize do
key = obj.__id__
@curr[key] = obj
return key
@@ -27,7 +27,7 @@ module DRb
end
def fetch(key, dv=@sentinel)
- synchronize do
+ synchronize do
obj = peek(key)
if obj == @sentinel
return dv unless dv == @sentinel
@@ -39,7 +39,7 @@ module DRb
end
def include?(key)
- synchronize do
+ synchronize do
obj = peek(key)
return false if obj == @sentinel
true
@@ -47,7 +47,7 @@ module DRb
end
def peek(key)
- synchronize do
+ synchronize do
return @curr.fetch(key, @renew.fetch(key, @gc.fetch(key, @sentinel)))
end
end
diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb
index 57feed8301..ebecc22901 100644
--- a/lib/drb/unix.rb
+++ b/lib/drb/unix.rb
@@ -8,7 +8,7 @@ module DRb
class DRbUNIXSocket < DRbTCPSocket
def self.parse_uri(uri)
- if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
+ if /^drbunix:(.*?)(\?(.*))?$/ =~ uri
filename = $1
option = $3
[filename, option]
@@ -59,7 +59,7 @@ module DRb
@server_mode = server_mode
@acl = nil
end
-
+
# import from tempfile.rb
Max_try = 10
private
diff --git a/lib/e2mmap.rb b/lib/e2mmap.rb
index 8d1aba2969..813aa564df 100644
--- a/lib/e2mmap.rb
+++ b/lib/e2mmap.rb
@@ -59,7 +59,7 @@ module Exception2MessageMapper
super
cl.bind(self) unless cl == E2MM
end
-
+
# backward compatibility
def E2MM.extend_to(b)
c = eval("self", b)
@@ -91,7 +91,7 @@ module Exception2MessageMapper
# backward compatibility
alias fail! fail
def fail(err = nil, *rest)
- begin
+ begin
E2MM.Fail(self, err, *rest)
rescue E2MM::ErrNotRegisteredException
super
@@ -101,7 +101,7 @@ module Exception2MessageMapper
public :fail
end
-
+
# def_e2message(c, m)
# c: exception
# m: message_form
@@ -110,7 +110,7 @@ module Exception2MessageMapper
def def_e2message(c, m)
E2MM.def_e2message(self, c, m)
end
-
+
# def_exception(n, m, s)
# n: exception_name
# m: message_form
@@ -137,7 +137,7 @@ module Exception2MessageMapper
E2MM.instance_eval{@MessageMap[[k, c]] = m}
c
end
-
+
# E2MM.def_exception(k, n, m, s)
# k: class to define exception under.
# n: exception_name
@@ -187,8 +187,8 @@ module Exception2MessageMapper
alias message e2mm_message
end
- E2MM.def_exception(E2MM,
- :ErrNotRegisteredException,
+ E2MM.def_exception(E2MM,
+ :ErrNotRegisteredException,
"not registerd exception(%s)")
end
diff --git a/lib/erb.rb b/lib/erb.rb
index 3a474b9ea5..112cf1d55b 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -20,7 +20,7 @@
# purposes of generating document information details and/or flow control.
#
# A very simple example is this:
-#
+#
# require 'erb'
#
# x = 42
@@ -68,39 +68,39 @@
# <tt>%q{...}</tt> to avoid trouble with the backslash.
#
# require "erb"
-#
+#
# # Create template.
# template = %q{
# From: James Edward Gray II <[email protected]>
# To: <%= to %>
# Subject: Addressing Needs
-#
+#
# <%= to[/\w+/] %>:
-#
+#
# Just wanted to send a quick note assuring that your needs are being
# addressed.
-#
+#
# I want you to know that my team will keep working on the issues,
# especially:
-#
+#
# <%# ignore numerous minor requests -- focus on priorities %>
# % priorities.each do |priority|
# * <%= priority %>
# % end
-#
+#
# Thanks for your patience.
-#
+#
# James Edward Gray II
# }.gsub(/^ /, '')
-#
+#
# message = ERB.new(template, 0, "%<>")
-#
+#
# # Set up template data.
# to = "Community Spokesman <spokesman@ruby_community.org>"
# priorities = [ "Run Ruby Quiz",
# "Document Modules",
# "Answer Questions on Ruby Talk" ]
-#
+#
# # Produce result.
# email = message.result
# puts email
@@ -110,19 +110,19 @@
# From: James Edward Gray II <[email protected]>
# To: Community Spokesman <spokesman@ruby_community.org>
# Subject: Addressing Needs
-#
+#
# Community:
-#
+#
# Just wanted to send a quick note assuring that your needs are being addressed.
-#
+#
# I want you to know that my team will keep working on the issues, especially:
-#
+#
# * Run Ruby Quiz
# * Document Modules
# * Answer Questions on Ruby Talk
-#
+#
# Thanks for your patience.
-#
+#
# James Edward Gray II
#
# === Ruby in HTML
@@ -132,7 +132,7 @@
# variables in the Product object can be resolved.
#
# require "erb"
-#
+#
# # Build template data class.
# class Product
# def initialize( code, name, desc, cost )
@@ -140,37 +140,37 @@
# @name = name
# @desc = desc
# @cost = cost
-#
+#
# @features = [ ]
# end
-#
+#
# def add_feature( feature )
# @features << feature
# end
-#
+#
# # Support templating of member data.
# def get_binding
# binding
# end
-#
+#
# # ...
# end
-#
+#
# # Create template.
# template = %{
# <html>
# <head><title>Ruby Toys -- <%= @name %></title></head>
# <body>
-#
+#
# <h1><%= @name %> (<%= @code %>)</h1>
# <p><%= @desc %></p>
-#
+#
# <ul>
# <% @features.each do |f| %>
# <li><b><%= f %></b></li>
# <% end %>
# </ul>
-#
+#
# <p>
# <% if @cost < 10 %>
# <b>Only <%= @cost %>!!!</b>
@@ -178,13 +178,13 @@
# Call for a price, today!
# <% end %>
# </p>
-#
+#
# </body>
# </html>
# }.gsub(/^ /, '')
-#
+#
# rhtml = ERB.new(template)
-#
+#
# # Set up template data.
# toy = Product.new( "TZ-1002",
# "Rubysapien",
@@ -195,7 +195,7 @@
# toy.add_feature("Karate-Chop Action!!!")
# toy.add_feature("Matz signature on left leg.")
# toy.add_feature("Gem studded eyes... Rubies, of course!")
-#
+#
# # Produce result.
# rhtml.run(toy.get_binding)
#
@@ -204,10 +204,10 @@
# <html>
# <head><title>Ruby Toys -- Rubysapien</title></head>
# <body>
-#
+#
# <h1>Rubysapien (TZ-1002)</h1>
# <p>Geek's Best Friend! Responds to Ruby commands...</p>
-#
+#
# <ul>
# <li><b>Listens for verbal commands in the Ruby language!</b></li>
# <li><b>Ignores Perl, Java, and all C variants.</b></li>
@@ -215,15 +215,15 @@
# <li><b>Matz signature on left leg.</b></li>
# <li><b>Gem studded eyes... Rubies, of course!</b></li>
# </ul>
-#
+#
# <p>
# Call for a price, today!
# </p>
-#
+#
# </body>
# </html>
#
-#
+#
# == Notes
#
# There are a variety of templating solutions available in various Ruby projects:
@@ -300,7 +300,7 @@ class ERB
end
end
attr_accessor :stag
-
+
def scan(&block)
@stag = nil
if @percent
@@ -407,7 +407,7 @@ class ERB
end
end
end
-
+
Scanner.regist_scanner(SimpleScanner, nil, false)
begin
@@ -466,13 +466,13 @@ class ERB
def push(cmd)
@line << cmd
end
-
+
def cr
@script << (@line.join('; '))
@line = []
@script << "\n"
end
-
+
def close
return unless @line
@compiler.post_cmd.each do |x|
@@ -498,7 +498,7 @@ class ERB
content = ''
scanner = make_scanner(s)
scanner.scan do |token|
- next if token.nil?
+ next if token.nil?
next if token == ''
if scanner.stag.nil?
case token
@@ -598,19 +598,19 @@ end
class ERB
#
# Constructs a new ERB object with the template specified in _str_.
- #
+ #
# An ERB object works by building a chunk of Ruby code that will output
# the completed template when run. If _safe_level_ is set to a non-nil value,
# ERB code will be run in a separate thread with <b>$SAFE</b> set to the
# provided level.
- #
+ #
# If _trim_mode_ is passed a String containing one or more of the following
# modifiers, ERB will adjust its code generation as listed:
- #
+ #
# % enables Ruby code processing for lines beginning with %
# <> omit newline for lines starting with <% and ending in %>
# > omit newline for lines ending in %>
- #
+ #
# _eoutvar_ can be used to set the name of the variable ERB will build up
# its output in. This is useful when you need to run multiple ERB
# templates through the same binding and/or when you want to control where
@@ -619,20 +619,20 @@ class ERB
# === Example
#
# require "erb"
- #
+ #
# # build data class
# class Listings
# PRODUCT = { :name => "Chicken Fried Steak",
# :desc => "A well messages pattie, breaded and fried.",
# :cost => 9.95 }
- #
+ #
# attr_reader :product, :price
- #
+ #
# def initialize( product = "", price = "" )
# @product = product
# @price = price
# end
- #
+ #
# def build
# b = binding
# # create and run templates, filling member data variables
@@ -646,21 +646,21 @@ class ERB
# END_PRICE
# end
# end
- #
+ #
# # setup template data
# listings = Listings.new
# listings.build
- #
+ #
# puts listings.product + "\n" + listings.price
#
# _Generates_
#
# Chicken Fried Steak
# A well messages pattie, breaded and fried.
- #
+ #
# Chicken Fried Steak -- 9.95
# A well messages pattie, breaded and fried.
- #
+ #
def initialize(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout')
@safe_level = safe_level
compiler = ERB::Compiler.new(trim_mode)
@@ -687,7 +687,7 @@ class ERB
cmd = []
cmd.push "#{eoutvar} = ''"
-
+
compiler.pre_cmd = cmd
cmd = []
@@ -705,13 +705,13 @@ class ERB
# Executes the generated ERB code to produce a completed template, returning
# the results of that code. (See ERB#new for details on how this process can
# be affected by _safe_level_.)
- #
+ #
# _b_ accepts a Binding or Proc object which is used to set the context of
# code evaluation.
#
def result(b=TOPLEVEL_BINDING)
if @safe_level
- proc {
+ proc {
$SAFE = @safe_level
eval(@src, b, (@filename || '(erb)'), 1)
}.call
@@ -775,14 +775,14 @@ class ERB
public
#
# A utility method for escaping HTML tag characters in _s_.
- #
+ #
# require "erb"
# include ERB::Util
- #
+ #
# puts html_escape("is a > 0 & a < 10?")
- #
+ #
# _Generates_
- #
+ #
# is a &gt; 0 &amp; a &lt; 10?
#
def html_escape(s)
@@ -791,17 +791,17 @@ class ERB
alias h html_escape
module_function :h
module_function :html_escape
-
+
#
# A utility method for encoding the String _s_ as a URL.
- #
+ #
# require "erb"
# include ERB::Util
- #
+ #
# puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
- #
+ #
# _Generates_
- #
+ #
# Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide
#
def url_encode(s)
diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 5e5066ee3a..064baa6e25 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1,17 +1,17 @@
-#
+#
# = fileutils.rb
-#
+#
# Copyright (c) 2000-2006 Minero Aoki
-#
+#
# This program is free software.
# You can distribute/modify this program under the same terms of ruby.
-#
+#
# == module FileUtils
-#
+#
# Namespace for several file utility methods for copying, moving, removing, etc.
-#
+#
# === Module Functions
-#
+#
# cd(dir, options)
# cd(dir, options) {|dir| .... }
# pwd()
@@ -64,23 +64,23 @@
# uptodate?(file, cmp_list)
#
# == module FileUtils::Verbose
-#
+#
# This module has all methods of FileUtils module, but it outputs messages
# before acting. This equates to passing the <tt>:verbose</tt> flag to methods
# in FileUtils.
-#
+#
# == module FileUtils::NoWrite
-#
+#
# This module has all methods of FileUtils module, but never changes
# files/directories. This equates to passing the <tt>:noop</tt> flag to methods
# in FileUtils.
-#
+#
# == module FileUtils::DryRun
-#
+#
# This module has all methods of FileUtils module, but never changes
# files/directories. This equates to passing the <tt>:noop</tt> and
# <tt>:verbose</tt> flags to methods in FileUtils.
-#
+#
module FileUtils
@@ -107,14 +107,14 @@ module FileUtils
#
# Options: verbose
- #
+ #
# Changes the current directory to the directory +dir+.
- #
+ #
# If this method is called with block, resumes to the old
# working directory after the block execution finished.
- #
+ #
# FileUtils.cd('/', :verbose => true) # chdir and report it
- #
+ #
def cd(dir, options = {}, &block) # :yield: dir
fu_check_options options, OPT_TABLE['cd']
fu_output_message "cd #{dir}" if options[:verbose]
@@ -131,13 +131,13 @@ module FileUtils
#
# Options: (none)
- #
+ #
# Returns true if +newer+ is newer than all +old_list+.
# Non-existent files are older than any file.
- #
+ #
# FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
# system 'make hello.o'
- #
+ #
def uptodate?(new, old_list, options = nil)
raise ArgumentError, 'uptodate? does not accept any option' if options
@@ -154,14 +154,14 @@ module FileUtils
#
# Options: mode noop verbose
- #
+ #
# Creates one or more directories.
- #
+ #
# FileUtils.mkdir 'test'
# FileUtils.mkdir %w( tmp data )
# FileUtils.mkdir 'notexist', :noop => true # Does not really create.
# FileUtils.mkdir 'tmp', :mode => 0700
- #
+ #
def mkdir(list, options = {})
fu_check_options options, OPT_TABLE['mkdir']
list = fu_list(list)
@@ -178,12 +178,12 @@ module FileUtils
#
# Options: mode noop verbose
- #
+ #
# Creates a directory and all its parent directories.
# For example,
- #
+ #
# FileUtils.mkdir_p '/usr/local/lib/ruby'
- #
+ #
# causes to make following directories, if it does not exist.
# * /usr
# * /usr/local
@@ -191,7 +191,7 @@ module FileUtils
# * /usr/local/lib/ruby
#
# You can pass several directories at a time in a list.
- #
+ #
def mkdir_p(list, options = {})
fu_check_options options, OPT_TABLE['mkdir_p']
list = fu_list(list)
@@ -247,14 +247,14 @@ module FileUtils
#
# Options: noop, verbose
- #
+ #
# Removes one or more directories.
- #
+ #
# FileUtils.rmdir 'somedir'
# FileUtils.rmdir %w(somedir anydir otherdir)
# # Does not really remove directory; outputs message.
# FileUtils.rmdir 'somedir', :verbose => true, :noop => true
- #
+ #
def rmdir(list, options = {})
fu_check_options options, OPT_TABLE['rmdir']
list = fu_list(list)
@@ -277,19 +277,19 @@ module FileUtils
# If +new+ already exists and it is a directory, creates a link +new/old+.
# If +new+ already exists and it is not a directory, raises Errno::EEXIST.
# But if :force option is set, overwrite +new+.
- #
+ #
# FileUtils.ln 'gcc', 'cc', :verbose => true
# FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
- #
+ #
# <b><tt>ln(list, destdir, options = {})</tt></b>
- #
+ #
# Creates several hard links in a directory, with each one pointing to the
# item in +list+. If +destdir+ is not a directory, raises Errno::ENOTDIR.
- #
+ #
# include FileUtils
# cd '/sbin'
# FileUtils.ln %w(cp mv mkdir), '/bin' # Now /sbin/cp and /bin/cp are linked.
- #
+ #
def ln(src, dest, options = {})
fu_check_options options, OPT_TABLE['ln']
fu_output_message "ln#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
@@ -311,24 +311,24 @@ module FileUtils
# Options: force noop verbose
#
# <b><tt>ln_s(old, new, options = {})</tt></b>
- #
+ #
# Creates a symbolic link +new+ which points to +old+. If +new+ already
# exists and it is a directory, creates a symbolic link +new/old+. If +new+
# already exists and it is not a directory, raises Errno::EEXIST. But if
# :force option is set, overwrite +new+.
- #
+ #
# FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
# FileUtils.ln_s 'verylongsourcefilename.c', 'c', :force => true
- #
+ #
# <b><tt>ln_s(list, destdir, options = {})</tt></b>
- #
+ #
# Creates several symbolic links in a directory, with each one pointing to the
# item in +list+. If +destdir+ is not a directory, raises Errno::ENOTDIR.
#
# If +destdir+ is not a directory, raises Errno::ENOTDIR.
- #
+ #
# FileUtils.ln_s Dir.glob('bin/*.rb'), '/home/aamine/bin'
- #
+ #
def ln_s(src, dest, options = {})
fu_check_options options, OPT_TABLE['ln_s']
fu_output_message "ln -s#{options[:force] ? 'f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
@@ -348,10 +348,10 @@ module FileUtils
#
# Options: noop verbose
- #
+ #
# Same as
# #ln_s(src, dest, :force)
- #
+ #
def ln_sf(src, dest, options = {})
fu_check_options options, OPT_TABLE['ln_sf']
options = options.dup
@@ -374,7 +374,7 @@ module FileUtils
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :verbose => true
# FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
- #
+ #
def cp(src, dest, options = {})
fu_check_options options, OPT_TABLE['cp']
fu_output_message "cp#{options[:preserve] ? ' -p' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
@@ -393,17 +393,17 @@ module FileUtils
#
# Options: preserve noop verbose dereference_root remove_destination
- #
+ #
# Copies +src+ to +dest+. If +src+ is a directory, this method copies
# all its contents recursively. If +dest+ is a directory, copies
# +src+ to +dest/src+.
#
# +src+ can be a list of files.
- #
+ #
# # Installing ruby library "mylib" under the site_ruby
# FileUtils.rm_r site_ruby + '/mylib', :force
# FileUtils.cp_r 'lib/', site_ruby + '/mylib'
- #
+ #
# # Examples of copying several files to target directory.
# FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
# FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/ruby', :noop => true, :verbose => true
@@ -413,7 +413,7 @@ module FileUtils
# # use following code.
# FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest') makes src/dest,
# # but this doesn't.
- #
+ #
def cp_r(src, dest, options = {})
fu_check_options options, OPT_TABLE['cp_r']
fu_output_message "cp -r#{options[:preserve] ? 'p' : ''}#{options[:remove_destination] ? ' --remove-destination' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
@@ -477,17 +477,17 @@ module FileUtils
#
# Options: force noop verbose
- #
+ #
# Moves file(s) +src+ to +dest+. If +file+ and +dest+ exist on the different
# disk partition, the copied file is created on the +dest+ and the original
# file removed from +src+.
- #
+ #
# FileUtils.mv 'badname.rb', 'goodname.rb'
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true # no error
- #
+ #
# FileUtils.mv %w(junk.txt dust.txt), '/home/aamine/.trash/'
# FileUtils.mv Dir.glob('test*.rb'), 'test', :noop => true, :verbose => true
- #
+ #
def mv(src, dest, options = {})
fu_check_options options, OPT_TABLE['mv']
fu_output_message "mv#{options[:force] ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
@@ -532,14 +532,14 @@ module FileUtils
#
# Options: force noop verbose
- #
+ #
# Remove file(s) specified in +list+. This method cannot remove directories.
# All StandardErrors are ignored when the :force option is set.
- #
+ #
# FileUtils.rm %w( junk.txt dust.txt )
# FileUtils.rm Dir.glob('*.so')
# FileUtils.rm 'NotExistFile', :force => true # never raises exception
- #
+ #
def rm(list, options = {})
fu_check_options options, OPT_TABLE['rm']
list = fu_list(list)
@@ -560,7 +560,7 @@ module FileUtils
#
# Options: noop verbose
- #
+ #
# Equivalent to
#
# #rm(list, :force => true)
@@ -581,11 +581,11 @@ module FileUtils
#
# Options: force noop verbose secure
- #
+ #
# remove files +list+[0] +list+[1]... If +list+[n] is a directory,
# removes its all contents recursively. This method ignores
# StandardError when :force option is set.
- #
+ #
# FileUtils.rm_r Dir.glob('/tmp/*')
# FileUtils.rm_r '/', :force => true # :-)
#
@@ -599,7 +599,7 @@ module FileUtils
#
# NOTE: This method calls #remove_entry_secure if :secure option is set.
# See also #remove_entry_secure.
- #
+ #
def rm_r(list, options = {})
fu_check_options options, OPT_TABLE['rm_r']
# options[:secure] = true unless options.key?(:secure)
@@ -620,14 +620,14 @@ module FileUtils
#
# Options: noop verbose secure
- #
+ #
# Equivalent to
#
# #rm_r(list, :force => true)
#
# WARNING: This method causes local vulnerability.
# Read the documentation of #rm_r first.
- #
+ #
def rm_rf(list, options = {})
fu_check_options options, OPT_TABLE['rm_rf']
options = options.dup
@@ -786,7 +786,7 @@ module FileUtils
#
# Returns true if the contents of a file A and a file B are identical.
- #
+ #
# FileUtils.compare_file('somefile', 'somefile') #=> true
# FileUtils.compare_file('/bin/cp', '/bin/mv') #=> maybe false
#
@@ -826,14 +826,14 @@ module FileUtils
#
# Options: mode preserve noop verbose
- #
+ #
# If +src+ is not same as +dest+, copies it and changes the permission
# mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
# This method removes destination before copy.
- #
+ #
# FileUtils.install 'ruby', '/usr/local/bin/ruby', :mode => 0755, :verbose => true
# FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :verbose => true
- #
+ #
def install(src, dest, options = {})
fu_check_options options, OPT_TABLE['install']
fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
@@ -854,14 +854,14 @@ module FileUtils
#
# Options: noop verbose
- #
+ #
# Changes permission bits on the named files (in +list+) to the bit pattern
# represented by +mode+.
- #
+ #
# FileUtils.chmod 0755, 'somecommand'
# FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
# FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
- #
+ #
def chmod(mode, list, options = {})
fu_check_options options, OPT_TABLE['chmod']
list = fu_list(list)
@@ -877,12 +877,12 @@ module FileUtils
#
# Options: noop verbose force
- #
+ #
# Changes permission bits on the named files (in +list+)
# to the bit pattern represented by +mode+.
- #
+ #
# FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
- #
+ #
def chmod_R(mode, list, options = {})
fu_check_options options, OPT_TABLE['chmod_R']
list = fu_list(list)
@@ -906,16 +906,16 @@ module FileUtils
#
# Options: noop verbose
- #
+ #
# Changes owner and group on the named files (in +list+)
# to the user +user+ and the group +group+. +user+ and +group+
# may be an ID (Integer/String) or a name (String).
# If +user+ or +group+ is nil, this method does not change
# the attribute.
- #
+ #
# FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :verbose => true
- #
+ #
def chown(user, group, list, options = {})
fu_check_options options, OPT_TABLE['chown']
list = fu_list(list)
@@ -935,16 +935,16 @@ module FileUtils
#
# Options: noop verbose force
- #
+ #
# Changes owner and group on the named files (in +list+)
# to the user +user+ and the group +group+ recursively.
# +user+ and +group+ may be an ID (Integer/String) or
# a name (String). If +user+ or +group+ is nil, this
# method does not change the attribute.
- #
+ #
# FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :verbose => true
- #
+ #
def chown_R(user, group, list, options = {})
fu_check_options options, OPT_TABLE['chown_R']
list = fu_list(list)
@@ -1015,13 +1015,13 @@ module FileUtils
#
# Options: noop verbose
- #
+ #
# Updates modification time (mtime) and access time (atime) of file(s) in
# +list+. Files are created if they don't exist.
- #
+ #
# FileUtils.touch 'timestamp'
# FileUtils.touch Dir.glob('*.c'); system 'make'
- #
+ #
def touch(list, options = {})
fu_check_options options, OPT_TABLE['touch']
list = fu_list(list)
@@ -1520,11 +1520,11 @@ module FileUtils
METHODS = singleton_methods() - %w( private_module_function
commands options have_option? options_of collect_method )
- #
+ #
# This module has all methods of FileUtils module, but it outputs messages
# before acting. This equates to passing the <tt>:verbose</tt> flag to
# methods in FileUtils.
- #
+ #
module Verbose
include FileUtils
@fileutils_output = $stderr
@@ -1545,11 +1545,11 @@ module FileUtils
end
end
- #
+ #
# This module has all methods of FileUtils module, but never changes
# files/directories. This equates to passing the <tt>:noop</tt> flag
# to methods in FileUtils.
- #
+ #
module NoWrite
include FileUtils
@fileutils_output = $stderr
@@ -1570,12 +1570,12 @@ module FileUtils
end
end
- #
+ #
# This module has all methods of FileUtils module, but never changes
# files/directories, with printing message before acting.
# This equates to passing the <tt>:noop</tt> and <tt>:verbose</tt> flag
# to methods in FileUtils.
- #
+ #
module DryRun
include FileUtils
@fileutils_output = $stderr
diff --git a/lib/finalize.rb b/lib/finalize.rb
index 9b6b302cac..0451d2c9f0 100644
--- a/lib/finalize.rb
+++ b/lib/finalize.rb
@@ -1,5 +1,5 @@
#--
-# finalizer.rb -
+# finalizer.rb -
# $Release Version: 0.3$
# $Revision: 1.4 $
# $Date: 1998/02/27 05:34:33 $
diff --git a/lib/forwardable.rb b/lib/forwardable.rb
index cc6e4ee418..b9a135bf4b 100644
--- a/lib/forwardable.rb
+++ b/lib/forwardable.rb
@@ -33,28 +33,28 @@
#
# class Queue
# extend Forwardable
-#
+#
# def initialize
# @q = [ ] # prepare delegate object
# end
-#
+#
# # setup preferred interface, enq() and deq()...
# def_delegator :@q, :push, :enq
# def_delegator :@q, :shift, :deq
-#
+#
# # support some general Array methods that fit Queues well
# def_delegators :@q, :clear, :first, :push, :shift, :size
# end
-#
+#
# q = Queue.new
# q.enq 1, 2, 3, 4, 5
# q.push 6
-#
+#
# q.shift # => 1
# while q.size > 0
# puts q.deq
# end
-#
+#
# q.enq "Ruby", "Perl", "Python"
# puts q.first
# q.clear
diff --git a/lib/ftools.rb b/lib/ftools.rb
index 5f082331fb..09cd17c332 100644
--- a/lib/ftools.rb
+++ b/lib/ftools.rb
@@ -1,4 +1,4 @@
-#
+#
# = ftools.rb: Extra tools for the File class
#
# Author:: WATANABE, Hirofumi
@@ -16,7 +16,7 @@
# creating a directory path. See the File class for details.
#
# FileUtils contains all or nearly all the same functionality and more, and
-# is a recommended option over ftools
+# is a recommended option over ftools
#
# When you
#
@@ -39,7 +39,7 @@ class << File
# If +to+ is a valid directory, +from+ will be appended to +to+, adding
# and escaping backslashes as necessary. Otherwise, +to+ will be returned.
# Useful for appending +from+ to +to+ only if the filename was not specified
- # in +to+.
+ # in +to+.
#
def catname(from, to)
if directory? to
diff --git a/lib/generator.rb b/lib/generator.rb
index 8285c0c33e..0d682b5bf3 100644
--- a/lib/generator.rb
+++ b/lib/generator.rb
@@ -55,7 +55,7 @@
# while g.next?
# puts g.next
# end
-#
+#
class Generator
include Enumerable
@@ -189,7 +189,7 @@ class Enumerator
return g.next unless g.end?
g.rewind
- raise StopIteration, 'iteration reached at end'
+ raise StopIteration, 'iteration reached at end'
end
# :nodoc:
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index 4d004419b1..639e3ed106 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -12,10 +12,10 @@
# found at http://www.sra.co.jp/people/m-kasahr/ruby/getoptlong/
# The GetoptLong class allows you to parse command line options similarly to
-# the GNU getopt_long() C library call. Note, however, that GetoptLong is a
+# the GNU getopt_long() C library call. Note, however, that GetoptLong is a
# pure Ruby implementation.
#
-# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well
+# GetoptLong allows for POSIX-style options like <tt>--file</tt> as well
# as single letter options like <tt>-f</tt>
#
# The empty option <tt>--</tt> (two minus symbols) is used to end option
@@ -42,16 +42,16 @@
# # greet user by name, if name not supplied default is John
# #
# # DIR: The directory in which to issue the greeting.
-#
+#
# require 'getoptlong'
# require 'rdoc/usage'
-#
+#
# opts = GetoptLong.new(
# [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
# [ '--repeat', '-n', GetoptLong::REQUIRED_ARGUMENT ],
# [ '--name', GetoptLong::OPTIONAL_ARGUMENT ]
# )
-#
+#
# dir = nil
# name = nil
# repetitions = 1
@@ -69,14 +69,14 @@
# end
# end
# end
-#
+#
# if ARGV.length != 1
# puts "Missing dir argument (try --help)"
# exit 0
# end
-#
+#
# dir = ARGV.shift
-#
+#
# Dir.chdir(dir)
# for i in (1..repetitions)
# print "Hello"
@@ -120,7 +120,7 @@ class GetoptLong
# Set up option processing.
#
# The options to support are passed to new() as an array of arrays.
- # Each sub-array contains any number of String option names which carry
+ # Each sub-array contains any number of String option names which carry
# the same meaning, and one of the following flags:
#
# GetoptLong::NO_ARGUMENT :: Option does not take an argument.
@@ -200,23 +200,23 @@ class GetoptLong
# the processing of options as follows:
#
# <b>REQUIRE_ORDER</b> :
- #
+ #
# Options are required to occur before non-options.
#
# Processing of options ends as soon as a word is encountered that has not
# been preceded by an appropriate option flag.
#
# For example, if -a and -b are options which do not take arguments,
- # parsing command line arguments of '-a one -b two' would result in
- # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being
+ # parsing command line arguments of '-a one -b two' would result in
+ # 'one', '-b', 'two' being left in ARGV, and only ('-a', '') being
# processed as an option/arg pair.
#
# This is the default ordering, if the environment variable
# POSIXLY_CORRECT is set. (This is for compatibility with GNU getopt_long.)
#
# <b>PERMUTE</b> :
- #
- # Options can occur anywhere in the command line parsed. This is the
+ #
+ # Options can occur anywhere in the command line parsed. This is the
# default behavior.
#
# Every sequence of words which can be interpreted as an option (with or
@@ -233,7 +233,7 @@ class GetoptLong
#
# <b>RETURN_IN_ORDER</b> :
#
- # All words on the command line are processed as options. Words not
+ # All words on the command line are processed as options. Words not
# preceded by a short or long option flag are passed as arguments
# with an option of '' (empty string).
#
@@ -279,7 +279,7 @@ class GetoptLong
# The method is failed if option processing has already started.
#
if @status != STATUS_YET
- raise RuntimeError,
+ raise RuntimeError,
"invoke set_options, but option processing has already started"
end
@@ -331,7 +331,7 @@ class GetoptLong
end
#
- # Register the option (`i') to the `@canonical_names' and
+ # Register the option (`i') to the `@canonical_names' and
# `@canonical_names' Hashes.
#
if canonical_name == nil
@@ -463,7 +463,7 @@ class GetoptLong
return nil
end
argument = ARGV.shift
- elsif @ordering == REQUIRE_ORDER
+ elsif @ordering == REQUIRE_ORDER
if (ARGV[0] !~ /^-./)
terminate
return nil
@@ -600,7 +600,7 @@ class GetoptLong
#
# The block is called repeatedly with two arguments:
# The first is the option name.
- # The second is the argument which followed it (if any).
+ # The second is the argument which followed it (if any).
# Example: ('--opt', 'value')
#
# The option name is always converted to the first (preferred)
diff --git a/lib/getopts.rb b/lib/getopts.rb
index 7ff97c6ecd..593deb7535 100644
--- a/lib/getopts.rb
+++ b/lib/getopts.rb
@@ -1,5 +1,5 @@
#
-# getopts.rb -
+# getopts.rb -
# $Release Version: $
# $Revision$
# $Date$
diff --git a/lib/gserver.rb b/lib/gserver.rb
index 592e8661fe..2ab6e42bce 100644
--- a/lib/gserver.rb
+++ b/lib/gserver.rb
@@ -13,7 +13,7 @@ require "thread"
#
# GServer implements a generic server, featuring thread pool management,
-# simple logging, and multi-server management. See HttpServer in
+# simple logging, and multi-server management. See HttpServer in
# <tt>xmlrpc/httpserver.rb</tt> in the Ruby standard library for an example of
# GServer in action.
#
@@ -34,7 +34,7 @@ require "thread"
#
# #
# # A server that returns the time in seconds since 1970.
-# #
+# #
# class TimeServer < GServer
# def initialize(port=10001, *args)
# super(port, *args)
@@ -47,17 +47,17 @@ require "thread"
# # Run the server with logging enabled (it's a separate thread).
# server = TimeServer.new
# server.audit = true # Turn logging on.
-# server.start
+# server.start
#
# # *** Now point your browser to http://localhost:10001 to see it working ***
#
-# # See if it's still running.
+# # See if it's still running.
# GServer.in_service?(10001) # -> true
# server.stopped? # -> false
#
# # Shut the server down gracefully.
# server.shutdown
-#
+#
# # Alternatively, stop it immediately.
# GServer.stop(10001)
# # or, of course, "server.stop".
diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb
index 0f5fc0654b..4398b5adc0 100644
--- a/lib/ipaddr.rb
+++ b/lib/ipaddr.rb
@@ -66,19 +66,19 @@ end
# == Example
#
# require 'ipaddr'
-#
+#
# ipaddr1 = IPAddr.new "3ffe:505:2::1"
-#
+#
# p ipaddr1 #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>
-#
+#
# p ipaddr1.to_s #=> "3ffe:505:2::1"
-#
+#
# ipaddr2 = ipaddr1.mask(48) #=> #<IPAddr: IPv6:3ffe:0505:0002:0000:0000:0000:0000:0000/ffff:ffff:ffff:0000:0000:0000:0000:0000>
-#
+#
# p ipaddr2.to_s #=> "3ffe:505:2::"
-#
+#
# ipaddr3 = IPAddr.new "192.168.2.0/24"
-#
+#
# p ipaddr3 #=> #<IPAddr: IPv4:192.168.2.0/255.255.255.0>
class IPAddr
@@ -425,7 +425,7 @@ class IPAddr
# Creates a new ipaddr object either from a human readable IP
# address representation in string, or from a packed in_addr value
# followed by an address family.
- #
+ #
# In the former case, the following are the valid formats that will
# be recognized: "address", "address/prefixlen" and "address/mask",
# where IPv6 address may be enclosed in square brackets (`[' and
@@ -433,7 +433,7 @@ class IPAddr
# IP address. Although the address family is determined
# automatically from a specified string, you can specify one
# explicitly by the optional second argument.
- #
+ #
# Otherwise an IP address is generated from a packed in_addr value
# and an address family.
#
diff --git a/lib/irb.rb b/lib/irb.rb
index 71171a578e..ae3e2aab7a 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -93,7 +93,7 @@ module IRB
end
#
- # irb interpriter main routine
+ # irb interpriter main routine
#
class Irb
def initialize(workspace = nil, input_method = nil, output_method = nil)
@@ -134,7 +134,7 @@ module IRB
end
end
end
-
+
@scanner.set_input(@context.io) do
signal_status(:IN_INPUT) do
if l = @context.io.gets
@@ -166,11 +166,11 @@ module IRB
if exc
print exc.class, ": ", exc, "\n"
if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/
- irb_bug = true
+ irb_bug = true
else
irb_bug = false
end
-
+
messages = []
lasts = []
levels = 0
@@ -182,7 +182,7 @@ module IRB
else
lasts.push "\tfrom "+m
if lasts.size > @context.back_trace_limit
- lasts.shift
+ lasts.shift
levels += 1
end
end
@@ -287,13 +287,13 @@ module IRB
when "l"
ltype
when "i"
- if $1
+ if $1
format("%" + $1 + "d", indent)
else
indent.to_s
end
when "n"
- if $1
+ if $1
format("%" + $1 + "d", line_no)
else
line_no.to_s
diff --git a/lib/irb/cmd/chws.rb b/lib/irb/cmd/chws.rb
index 88585b778b..7e83d0d1ed 100644
--- a/lib/irb/cmd/chws.rb
+++ b/lib/irb/cmd/chws.rb
@@ -1,5 +1,5 @@
#
-# change-ws.rb -
+# change-ws.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "irb/cmd/nop.rb"
diff --git a/lib/irb/cmd/fork.rb b/lib/irb/cmd/fork.rb
index 2866b1373b..e3a7219715 100644
--- a/lib/irb/cmd/fork.rb
+++ b/lib/irb/cmd/fork.rb
@@ -1,5 +1,5 @@
#
-# fork.rb -
+# fork.rb -
# $Release Version: 0.9.5 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
@RCS_ID='-$Id$-'
@@ -18,7 +18,7 @@ module IRB
class Fork<Nop
def execute(&block)
pid = send ExtendCommand.irb_original_method_name("fork")
- unless pid
+ unless pid
class<<self
alias_method :exit, ExtendCommand.irb_original_method_name('exit')
end
diff --git a/lib/irb/cmd/help.rb b/lib/irb/cmd/help.rb
index 3e8d1388e0..3d5a92fff0 100644
--- a/lib/irb/cmd/help.rb
+++ b/lib/irb/cmd/help.rb
@@ -6,7 +6,7 @@
#
# --
#
-#
+#
#
require 'rdoc/ri/ri_driver'
diff --git a/lib/irb/cmd/load.rb b/lib/irb/cmd/load.rb
index cbc5d91d03..ef9933282c 100644
--- a/lib/irb/cmd/load.rb
+++ b/lib/irb/cmd/load.rb
@@ -1,5 +1,5 @@
#
-# load.rb -
+# load.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "irb/cmd/nop.rb"
@@ -26,7 +26,7 @@ module IRB
class Require<Nop
include IrbLoader
-
+
def execute(file_name)
# return ruby_require(file_name) unless IRB.conf[:USE_LOADER]
@@ -45,7 +45,7 @@ module IRB
when /\.(so|o|sl)$/
return ruby_require(file_name)
end
-
+
begin
irb_load(f = file_name + ".rb")
$".push f
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb
index aa553c959e..1009283589 100644
--- a/lib/irb/cmd/nop.rb
+++ b/lib/irb/cmd/nop.rb
@@ -1,5 +1,5 @@
#
-# nop.rb -
+# nop.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,12 +7,12 @@
#
# --
#
-#
+#
#
module IRB
module ExtendCommand
class Nop
-
+
@RCS_ID='-$Id$-'
def self.execute(conf, *opts)
diff --git a/lib/irb/cmd/pushws.rb b/lib/irb/cmd/pushws.rb
index eddaeae631..0677f671ad 100644
--- a/lib/irb/cmd/pushws.rb
+++ b/lib/irb/cmd/pushws.rb
@@ -1,5 +1,5 @@
#
-# change-ws.rb -
+# change-ws.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "irb/cmd/nop.rb"
diff --git a/lib/irb/cmd/subirb.rb b/lib/irb/cmd/subirb.rb
index 79d654b172..ad4679538a 100644
--- a/lib/irb/cmd/subirb.rb
+++ b/lib/irb/cmd/subirb.rb
@@ -1,6 +1,6 @@
#!/usr/local/bin/ruby
#
-# multi.rb -
+# multi.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -8,7 +8,7 @@
#
# --
#
-#
+#
#
require "irb/cmd/nop.rb"
diff --git a/lib/irb/completion.rb b/lib/irb/completion.rb
index 000658e2a3..a64e410c49 100644
--- a/lib/irb/completion.rb
+++ b/lib/irb/completion.rb
@@ -1,5 +1,5 @@
#
-# irb/completor.rb -
+# irb/completor.rb -
# $Release Version: 0.9$
# $Revision$
# $Date$
@@ -16,16 +16,16 @@ module IRB
ReservedWords = [
"BEGIN", "END",
- "alias", "and",
- "begin", "break",
+ "alias", "and",
+ "begin", "break",
"case", "class",
"def", "defined", "do",
"else", "elsif", "end", "ensure",
- "false", "for",
- "if", "in",
- "module",
+ "false", "for",
+ "if", "in",
+ "module",
"next", "nil", "not",
- "or",
+ "or",
"redo", "rescue", "retry", "return",
"self", "super",
"then", "true",
@@ -33,10 +33,10 @@ module IRB
"when", "while",
"yield",
]
-
+
CompletionProc = proc { |input|
bind = IRB.conf[:MAIN_CONTEXT].workspace.binding
-
+
# puts "input: #{input}"
case input
@@ -63,7 +63,7 @@ module IRB
candidates = Proc.instance_methods(true) | Hash.instance_methods(true)
select_message(receiver, message, candidates)
-
+
when /^(:[^:.]*)$/
# Symbol
if Symbol.respond_to?(:all_symbols)
@@ -135,7 +135,7 @@ module IRB
gv = eval("global_variables", bind)
lv = eval("local_variables", bind)
cv = eval("self.class.constants", bind)
-
+
if (gv | lv | cv).include?(receiver)
# foo.func and foo is local var.
candidates = eval("#{receiver}.methods", bind)
@@ -155,7 +155,7 @@ module IRB
rescue Exception
name = ""
end
- next if name != "IRB::Context" and
+ next if name != "IRB::Context" and
/^(IRB|SLex|RubyLex|RubyToken)/ =~ name
candidates.concat m.instance_methods(false)
}
@@ -175,7 +175,7 @@ module IRB
else
candidates = eval("methods | private_methods | local_variables | self.class.constants", bind)
-
+
(candidates|ReservedWords).grep(/^#{Regexp.quote(input)}/)
end
}
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index d01bd4aefa..b43eab2ff8 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "irb/workspace"
@@ -46,7 +46,7 @@ module IRB
@ignore_eof = IRB.conf[:IGNORE_EOF]
@back_trace_limit = IRB.conf[:BACK_TRACE_LIMIT]
-
+
self.prompt_mode = IRB.conf[:PROMPT_MODE]
if IRB.conf[:SINGLE_IRB] or !defined?(JobManager)
@@ -91,7 +91,7 @@ module IRB
@output_method = StdioOutputMethod.new
end
- @verbose = IRB.conf[:VERBOSE]
+ @verbose = IRB.conf[:VERBOSE]
@echo = IRB.conf[:ECHO]
if @echo.nil?
@echo = true
@@ -107,7 +107,7 @@ module IRB
attr_accessor :workspace
attr_reader :thread
attr_accessor :io
-
+
attr_accessor :irb
attr_accessor :ap_name
attr_accessor :rc
@@ -142,7 +142,7 @@ module IRB
def verbose?
if @verbose.nil?
- if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
+ if defined?(ReadlineInputMethod) && @io.kind_of?(ReadlineInputMethod)
false
elsif !STDIN.tty? or @io.kind_of?(FileInputMethod)
true
@@ -180,7 +180,7 @@ module IRB
@auto_indent_mode = IRB.conf[:AUTO_INDENT]
end
end
-
+
def inspect?
@inspect_mode.nil? or @inspect_mode
end
diff --git a/lib/irb/ext/change-ws.rb b/lib/irb/ext/change-ws.rb
index fff8f58fe5..eebb8b3de8 100644
--- a/lib/irb/ext/change-ws.rb
+++ b/lib/irb/ext/change-ws.rb
@@ -1,5 +1,5 @@
#
-# irb/ext/cb.rb -
+# irb/ext/cb.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
@@ -23,12 +23,12 @@ module IRB
def change_workspace(*_main)
if _main.empty?
- @workspace = home_workspace
+ @workspace = home_workspace
return main
end
-
+
@workspace = WorkSpace.new(_main[0])
-
+
if !(class<<main;ancestors;end).include?(ExtendCommandBundle)
main.extend ExtendCommandBundle
end
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
index 40f8692e8b..bf2c0222d0 100644
--- a/lib/irb/ext/history.rb
+++ b/lib/irb/ext/history.rb
@@ -1,5 +1,5 @@
#
-# history.rb -
+# history.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
@@ -57,7 +57,7 @@ module IRB
end
def size(size)
- if size != 0 && size < @size
+ if size != 0 && size < @size
@contents = @contents[@size - size .. @size]
end
@size = size
@@ -79,7 +79,7 @@ module IRB
@contents.push [no, val]
@contents.shift if @size != 0 && @contents.size > @size
end
-
+
alias real_inspect inspect
def inspect
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb
index 837e2553ac..64b784e651 100644
--- a/lib/irb/ext/loader.rb
+++ b/lib/irb/ext/loader.rb
@@ -1,5 +1,5 @@
#
-# loader.rb -
+# loader.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
@@ -45,7 +45,7 @@ module IRB
irb.suspend_name(path, File.basename(path)) do
irb.suspend_input_method(FileInputMethod.new(path)) do
|back_io|
- irb.signal_status(:IN_LOAD) do
+ irb.signal_status(:IN_LOAD) do
if back_io.kind_of?(FileInputMethod)
irb.eval_input
else
@@ -62,7 +62,7 @@ module IRB
def load_file(path, priv = nil)
irb.suspend_name(path, File.basename(path)) do
-
+
if priv
ws = WorkSpace.new(Module.new)
else
@@ -71,7 +71,7 @@ module IRB
irb.suspend_workspace(ws) do
irb.suspend_input_method(FileInputMethod.new(path)) do
|back_io|
- irb.signal_status(:IN_LOAD) do
+ irb.signal_status(:IN_LOAD) do
# p irb.conf
if back_io.kind_of?(FileInputMethod)
irb.eval_input
diff --git a/lib/irb/ext/math-mode.rb b/lib/irb/ext/math-mode.rb
index bd443b96ed..0c1ab0123f 100644
--- a/lib/irb/ext/math-mode.rb
+++ b/lib/irb/ext/math-mode.rb
@@ -1,5 +1,5 @@
#
-# math-mode.rb -
+# math-mode.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "mathn"
diff --git a/lib/irb/ext/multi-irb.rb b/lib/irb/ext/multi-irb.rb
index 634abbabf9..a36227c3de 100644
--- a/lib/irb/ext/multi-irb.rb
+++ b/lib/irb/ext/multi-irb.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
IRB.fail CantShiftToMultiIrbMode unless defined?(Thread)
require "thread"
@@ -67,7 +67,7 @@ module IRB
IRB.fail IrbAlreadyDead unless th.alive?
th.exit
end
- end
+ end
def search(key)
job = case key
@@ -124,8 +124,8 @@ module IRB
t_status = "exited"
end
ary.push format("#%d->%s on %s (%s: %s)",
- i,
- irb.context.irb_name,
+ i,
+ irb.context.irb_name,
irb.context.main,
th,
t_status)
@@ -144,14 +144,14 @@ module IRB
IRB.JobManager.irb(Thread.current).context
end
- # invoke multi-irb
+ # invoke multi-irb
def IRB.irb(file = nil, *main)
workspace = WorkSpace.new(*main)
parent_thread = Thread.current
Thread.start do
begin
irb = Irb.new(workspace, file)
- rescue
+ rescue
print "Subirb can't start with context(self): ", workspace.main.inspect, "\n"
print "return to main irb\n"
Thread.pass
diff --git a/lib/irb/ext/save-history.rb b/lib/irb/ext/save-history.rb
index 5ecc5f5027..e04466348e 100644
--- a/lib/irb/ext/save-history.rb
+++ b/lib/irb/ext/save-history.rb
@@ -1,6 +1,6 @@
#!/usr/local/bin/ruby
#
-# save-history.rb -
+# save-history.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -8,7 +8,7 @@
#
# --
#
-#
+#
#
require "readline"
diff --git a/lib/irb/ext/tracer.rb b/lib/irb/ext/tracer.rb
index 805f630a4d..1a0edd511e 100644
--- a/lib/irb/ext/tracer.rb
+++ b/lib/irb/ext/tracer.rb
@@ -1,5 +1,5 @@
#
-# irb/lib/tracer.rb -
+# irb/lib/tracer.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "tracer"
@@ -44,7 +44,7 @@ module IRB
alias __evaluate__ evaluate
def evaluate(context, statements, file = nil, line = nil)
if context.use_tracer? && file != nil && line != nil
- Tracer.on
+ Tracer.on
begin
__evaluate__(context, statements, file, line)
ensure
@@ -58,4 +58,4 @@ module IRB
IRB.initialize_tracer
end
-
+
diff --git a/lib/irb/ext/use-loader.rb b/lib/irb/ext/use-loader.rb
index 1b4d480fcd..1285846aeb 100644
--- a/lib/irb/ext/use-loader.rb
+++ b/lib/irb/ext/use-loader.rb
@@ -1,5 +1,5 @@
#
-# use-loader.rb -
+# use-loader.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "irb/cmd/load"
@@ -31,7 +31,7 @@ module IRB
class Context
IRB.conf[:USE_LOADER] = false
-
+
def use_loader
IRB.conf[:USE_LOADER]
end
diff --git a/lib/irb/ext/workspaces.rb b/lib/irb/ext/workspaces.rb
index 79098570dc..09a7d4cade 100644
--- a/lib/irb/ext/workspaces.rb
+++ b/lib/irb/ext/workspaces.rb
@@ -1,5 +1,5 @@
#
-# push-ws.rb -
+# push-ws.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index de797ab78b..36214b3cd6 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -1,5 +1,5 @@
#
-# irb/extend-command.rb - irb extend command
+# irb/extend-command.rb - irb extend command
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
#
@@ -90,15 +90,15 @@ module IRB
[:irb_load, :Load, "irb/cmd/load"],
[:irb_require, :Require, "irb/cmd/load"],
- [:irb_source, :Source, "irb/cmd/load",
+ [:irb_source, :Source, "irb/cmd/load",
[:source, NO_OVERRIDE]],
[:irb, :IrbCommand, "irb/cmd/subirb"],
- [:irb_jobs, :Jobs, "irb/cmd/subirb",
+ [:irb_jobs, :Jobs, "irb/cmd/subirb",
[:jobs, NO_OVERRIDE]],
- [:irb_fg, :Foreground, "irb/cmd/subirb",
+ [:irb_fg, :Foreground, "irb/cmd/subirb",
[:fg, NO_OVERRIDE]],
- [:irb_kill, :Kill, "irb/cmd/subirb",
+ [:irb_kill, :Kill, "irb/cmd/subirb",
[:kill, OVERRIDE_PRIVATE_ONLY]],
[:irb_help, :Help, "irb/cmd/help",
@@ -162,9 +162,9 @@ module IRB
(override == NO_OVERRIDE) && !respond_to?(to, true)
target = self
(class<<self;self;end).instance_eval{
- if target.respond_to?(to, true) &&
+ if target.respond_to?(to, true) &&
!target.respond_to?(EXCB.irb_original_method_name(to), true)
- alias_method(EXCB.irb_original_method_name(to), to)
+ alias_method(EXCB.irb_original_method_name(to), to)
end
alias_method to, from
}
diff --git a/lib/irb/frame.rb b/lib/irb/frame.rb
index f0b0a9abf3..ce6c0ebce5 100644
--- a/lib/irb/frame.rb
+++ b/lib/irb/frame.rb
@@ -1,5 +1,5 @@
#
-# frame.rb -
+# frame.rb -
# $Release Version: 0.9$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
diff --git a/lib/irb/help.rb b/lib/irb/help.rb
index 4921de6ec9..131e86b4dc 100644
--- a/lib/irb/help.rb
+++ b/lib/irb/help.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
@@ -23,7 +23,7 @@ module IRB
next
end
space_line = false
-
+
l.sub!(/#.*$/, "")
next if /^\s*$/ =~ l
lc.puts l
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 5bbcc9558b..af50620b71 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
@@ -21,7 +21,7 @@ module IRB
IRB.load_modules
unless @CONF[:PROMPT][@CONF[:PROMPT_MODE]]
- IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
+ IRB.fail(UndefinedPromptMode, @CONF[:PROMPT_MODE])
end
end
@@ -113,9 +113,9 @@ module IRB
# @CONF[:LC_MESSAGES] = "en"
@CONF[:LC_MESSAGES] = Locale.new
-
+
@CONF[:AT_EXIT] = []
-
+
@CONF[:DEBUG_LEVEL] = 1
end
@@ -238,7 +238,7 @@ module IRB
yield proc{|rc| rc == "rc" ? irbrc : irbrc+rc}
end
if home = ENV["HOME"]
- yield proc{|rc| home+"/.irb#{rc}"}
+ yield proc{|rc| home+"/.irb#{rc}"}
end
home = Dir.pwd
yield proc{|rc| home+"/.irb#{rc}"}
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb
index bfb90fa59a..938049df6b 100644
--- a/lib/irb/input-method.rb
+++ b/lib/irb/input-method.rb
@@ -7,10 +7,10 @@
#
# --
#
-#
+#
#
module IRB
- #
+ #
# InputMethod
# StdioInputMethod
# FileInputMethod
@@ -26,7 +26,7 @@ module IRB
attr_reader :file_name
attr_accessor :prompt
-
+
def gets
IRB.fail NotImplementedError, "gets"
end
@@ -36,7 +36,7 @@ module IRB
false
end
end
-
+
class StdioInputMethod < InputMethod
def initialize
super
@@ -61,7 +61,7 @@ module IRB
@line[line_no]
end
end
-
+
class FileInputMethod < InputMethod
def initialize(file)
super
@@ -84,7 +84,7 @@ module IRB
begin
require "readline"
class ReadlineInputMethod < InputMethod
- include Readline
+ include Readline
def initialize
super
diff --git a/lib/irb/lc/error.rb b/lib/irb/lc/error.rb
index 247596b7fe..59aa482181 100644
--- a/lib/irb/lc/error.rb
+++ b/lib/irb/lc/error.rb
@@ -1,5 +1,5 @@
#
-# irb/lc/error.rb -
+# irb/lc/error.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
diff --git a/lib/irb/lc/ja/error.rb b/lib/irb/lc/ja/error.rb
index 4c2fb3b839..e270a411a7 100644
--- a/lib/irb/lc/ja/error.rb
+++ b/lib/irb/lc/ja/error.rb
@@ -1,5 +1,5 @@
#
-# irb/lc/ja/error.rb -
+# irb/lc/ja/error.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index 5ed9f54507..a22b4a3834 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
autoload :Kconv, "kconv"
@@ -20,7 +20,7 @@ module IRB
LOCALE_DIR = "/lc/"
def initialize(locale = nil)
- @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
+ @lang = locale || ENV["IRB_LANG"] || ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
end
attr_reader :lang
@@ -101,7 +101,7 @@ module IRB
end
alias toplevel_load load
-
+
def load(file, priv=nil)
dir = File.dirname(file)
dir = "" if dir == "."
@@ -115,7 +115,7 @@ module IRB
lc_path = search_file(dir, base)
return real_load(lc_path, priv) if lc_path
end
-
+
for path in $:
lc_path = search_file(path + "/" + dir, base)
return real_load(lc_path, priv) if lc_path
@@ -124,7 +124,7 @@ module IRB
@lang = back if back
end
raise LoadError, "No such file to load -- #{file}"
- end
+ end
def real_load(path, priv)
src = self.String(File.read(path))
diff --git a/lib/irb/notifier.rb b/lib/irb/notifier.rb
index dc472bc2ab..1a9dcd5d67 100644
--- a/lib/irb/notifier.rb
+++ b/lib/irb/notifier.rb
@@ -1,5 +1,5 @@
#
-# notifier.rb - output methods used by irb
+# notifier.rb - output methods used by irb
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
@@ -16,16 +16,16 @@ require "irb/output-method"
module IRB
module Notifier
extend Exception2MessageMapper
- def_exception :ErrUndefinedNotifier,
+ def_exception :ErrUndefinedNotifier,
"undefined notifier level: %d is specified"
- def_exception :ErrUnrecognizedLevel,
+ def_exception :ErrUnrecognizedLevel,
"unrecognized notifier level: %s is specified"
def def_notifier(prefix = "", output_method = StdioOutputMethod.new)
CompositeNotifier.new(prefix, output_method)
end
module_function :def_notifier
-
+
class AbstractNotifier
def initialize(prefix, base_notifier)
@prefix = prefix
@@ -113,7 +113,7 @@ module IRB
def initialize(base, level, prefix)
super(prefix, base)
-
+
@level = level
end
@@ -122,7 +122,7 @@ module IRB
def <=>(other)
@level <=> other.level
end
-
+
def notify?
@base_notifier.level >= self
end
diff --git a/lib/irb/output-method.rb b/lib/irb/output-method.rb
index ae712697cb..d4dcd87529 100644
--- a/lib/irb/output-method.rb
+++ b/lib/irb/output-method.rb
@@ -1,5 +1,5 @@
#
-# output-method.rb - output methods used by irb
+# output-method.rb - output methods used by irb
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
@@ -40,7 +40,7 @@ module IRB
# <�Ǿ��ե��������> (\*|\*[1-9][0-9]*\$|[1-9][0-9]*)
# <����>.(\*|\*[1-9][0-9]*\$|[1-9][0-9]*|)?
# #<Ĺ������ʸ��>(hh|h|l|ll|L|q|j|z|t)
- # <�Ѵ�����ʸ��>[diouxXeEfgGcsb%]
+ # <�Ѵ�����ʸ��>[diouxXeEfgGcsb%]
def parse_printf_format(format, opts)
return format, opts if $1.size % 2 == 1
end
@@ -52,7 +52,7 @@ module IRB
puts [f, p, pp, pos, new_pos, c].join("!")
pos = new_pos if new_pos
if c == "I"
- inspects.push pos.to_i
+ inspects.push pos.to_i
(f||"")+(p||"")+(pp||"")+(pos||"")+"s"
else
$&
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index 4849b9378e..795569aa04 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
@@ -21,12 +21,12 @@ class RubyLex
def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
- def_exception(:TkReading2TokenDuplicateError,
+ def_exception(:TkReading2TokenDuplicateError,
"key duplicate(token_n='%s', key='%s')")
def_exception(:SyntaxError, "%s")
def_exception(:TerminateLineInput, "Terminate Line Input")
-
+
include RubyToken
class << self
@@ -54,7 +54,7 @@ class RubyLex
@lex_state = EXPR_BEG
@space_seen = false
@here_header = false
-
+
@continue = false
@line = ""
@@ -92,7 +92,7 @@ class RubyLex
else
@base_char_no += @readed.size
end
-
+
readed = @readed.join("")
@readed = []
readed
@@ -111,7 +111,7 @@ class RubyLex
end
@seek += 1
if c == "\n"
- @line_no += 1
+ @line_no += 1
@char_no = 0
else
@char_no += 1
@@ -148,10 +148,10 @@ class RubyLex
c2 = @here_readed.pop
end
c = c2 unless c
- @rests.unshift c #c =
+ @rests.unshift c #c =
@seek -= 1
if c == "\n"
- @line_no -= 1
+ @line_no -= 1
if idx = @readed.reverse.index("\n")
@char_no = @readed.size - idx
else
@@ -216,14 +216,14 @@ class RubyLex
@lex_state = EXPR_BEG
@space_seen = false
@here_header = false
-
+
@continue = false
prompt
@line = ""
@exp_line_no = @line_no
end
-
+
def each_top_level_statement
initialize_input
catch(:TERM_INPUT) do
@@ -297,7 +297,7 @@ class RubyLex
# Tracer.off
tk
end
-
+
ENINDENT_CLAUSE = [
"case", "class", "def", "do", "for", "if",
"module", "unless", "until", "while", "begin" #, "when"
@@ -314,7 +314,7 @@ class RubyLex
"W" => "]",
"s" => ":"
}
-
+
PERCENT_PAREN = {
"{" => "}",
"[" => "]",
@@ -354,7 +354,7 @@ class RubyLex
end
@OP.def_rule("=begin",
- proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
+ proc{|op, io| @prev_char_no == 0 && peek(0) =~ /\s/}) do
|op, io|
@ltype = "="
until getc == "\n"; end
@@ -374,8 +374,8 @@ class RubyLex
else
@continue = false
@lex_state = EXPR_BEG
- until (@indent_stack.empty? ||
- [TkLPAREN, TkLBRACK, TkLBRACE,
+ until (@indent_stack.empty? ||
+ [TkLPAREN, TkLBRACK, TkLBRACE,
TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
@indent_stack.pop
end
@@ -385,9 +385,9 @@ class RubyLex
Token(TkNL)
end
- @OP.def_rules("*", "**",
- "=", "==", "===",
- "=~", "<=>",
+ @OP.def_rules("*", "**",
+ "=", "==", "===",
+ "=~", "<=>",
"<", "<=",
">", ">=", ">>") do
|op, io|
@@ -455,7 +455,7 @@ class RubyLex
@lex_state = EXPR_BEG;
Token(TkQUESTION)
else
- if (ch == '\\')
+ if (ch == '\\')
read_escape
end
@lex_state = EXPR_END
@@ -469,8 +469,8 @@ class RubyLex
@lex_state = EXPR_BEG
Token(op)
end
-
- @OP.def_rules("+=", "-=", "*=", "**=",
+
+ @OP.def_rules("+=", "-=", "*=", "**=",
"&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
|op, io|
@lex_state = EXPR_BEG
@@ -529,7 +529,7 @@ class RubyLex
lex_int2
end
-
+
def lex_int2
@OP.def_rules("]", "}", ")") do
|op, io|
@@ -572,7 +572,7 @@ class RubyLex
Token(TkOPASGN, "/") #/)
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
identify_string(op)
- else
+ else
@lex_state = EXPR_BEG
Token("/") #/)
end
@@ -588,7 +588,7 @@ class RubyLex
# @lex_state = EXPR_BEG
# Token(OP_ASGN, :^)
# end
-
+
@OP.def_rules(",") do
|op, io|
@lex_state = EXPR_BEG
@@ -598,8 +598,8 @@ class RubyLex
@OP.def_rules(";") do
|op, io|
@lex_state = EXPR_BEG
- until (@indent_stack.empty? ||
- [TkLPAREN, TkLBRACK, TkLBRACE,
+ until (@indent_stack.empty? ||
+ [TkLPAREN, TkLBRACK, TkLBRACE,
TkfLPAREN, TkfLBRACK, TkfLBRACE].include?(@indent_stack.last))
@indent_stack.pop
end
@@ -617,7 +617,7 @@ class RubyLex
@lex_state = EXPR_BEG
Token("~")
end
-
+
@OP.def_rule("(") do
|op, io|
@indent += 1
@@ -718,7 +718,7 @@ class RubyLex
end
end
- # @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
+ # @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
# |op, io|
# @indent += 1
# @lex_state = EXPR_FNAME
@@ -739,13 +739,13 @@ class RubyLex
printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
t
end
-
+
p @OP if RubyLex.debug?
end
-
+
def identify_gvar
@lex_state = EXPR_END
-
+
case ch = getc
when /[~_*$?!@\/\\;,=:<>".]/ #"
Token(TkGVAR, "$" + ch)
@@ -761,12 +761,12 @@ class RubyLex
ungetc
ungetc
identify_identifier
- else
+ else
ungetc
Token("$")
end
end
-
+
def identify_identifier
token = ""
if peek(0) =~ /[$@]/
@@ -781,7 +781,7 @@ class RubyLex
token.concat ch
end
ungetc
-
+
if (ch == "!" || ch == "?") && token[0,1] =~ /\w/ && peek(0) != "="
token.concat getc
end
@@ -799,7 +799,7 @@ class RubyLex
@lex_state = EXPR_END
return Token(TkIVAR, token)
end
-
+
if @lex_state != EXPR_DOT
print token, "\n" if RubyLex.debug?
@@ -927,7 +927,7 @@ class RubyLex
@lex_state = EXPR_END
Token(Ltype2Token[lt])
end
-
+
def identify_quotation
ch = getc
if lt = PERCENT_LTYPE[ch]
@@ -968,10 +968,10 @@ class RubyLex
match = /[0-7_]/
when /[89]/
RubyLex.fail SyntaxError, "Illegal octal digit"
- else
+ else
return Token(TkINTEGER)
end
-
+
len0 = true
non_digit = false
while ch = getc
@@ -999,7 +999,7 @@ class RubyLex
end
return Token(TkINTEGER)
end
-
+
type = TkINTEGER
allow_point = true
allow_e = true
@@ -1042,7 +1042,7 @@ class RubyLex
end
Token(type)
end
-
+
def identify_string(ltype, quoted = ltype)
@ltype = ltype
@quoted = quoted
@@ -1063,7 +1063,7 @@ class RubyLex
elsif ch == '\\' #'
read_escape
end
- if PERCENT_PAREN.values.include?(@quoted)
+ if PERCENT_PAREN.values.include?(@quoted)
if PERCENT_PAREN[ch] == @quoted
nest += 1
elsif ch == @quoted
@@ -1087,7 +1087,7 @@ class RubyLex
@lex_state = EXPR_END
end
end
-
+
def identify_comment
@ltype = "#"
@@ -1103,7 +1103,7 @@ class RubyLex
end
return Token(TkCOMMENT)
end
-
+
def read_escape
case ch = getc
when "\n", "\r", "\f"
@@ -1120,7 +1120,7 @@ class RubyLex
break
end
end
-
+
when "x"
2.times do
case ch = getc
@@ -1149,7 +1149,7 @@ class RubyLex
read_escape
end
else
- # other characters
+ # other characters
end
end
end
diff --git a/lib/irb/ruby-token.rb b/lib/irb/ruby-token.rb
index 525d4df14c..1415c8d90a 100644
--- a/lib/irb/ruby-token.rb
+++ b/lib/irb/ruby-token.rb
@@ -1,5 +1,5 @@
#
-# irb/ruby-token.rb - ruby tokens
+# irb/ruby-token.rb - ruby tokens
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module RubyToken
EXPR_BEG = :EXPR_BEG
@@ -22,7 +22,7 @@ module RubyToken
if !defined?(Symbol)
Symbol = Integer
end
-
+
class Token
def initialize(seek, line_no, char_no)
@seek = seek
@@ -87,7 +87,7 @@ module RubyToken
if (tk = TkReading2Token[token]).nil?
IRB.fail TkReading2TokenNoKey, token
end
- tk = Token(tk[0], value)
+ tk = Token(tk[0], value)
if tk.kind_of?(TkOp)
tk.name = token
end
@@ -96,8 +96,8 @@ module RubyToken
if (tk = TkSymbol2Token[token]).nil?
IRB.fail TkSymbol2TokenNoKey, token
end
- return Token(tk[0], value)
- else
+ return Token(tk[0], value)
+ else
if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
token.new(@prev_seek, @prev_line_no, @prev_char_no)
else
@@ -197,7 +197,7 @@ module RubyToken
[:TkASSOC, TkOp, "=>"],
[:TkQUESTION, TkOp, "?"], #?
[:TkCOLON, TkOp, ":"], #:
-
+
[:TkfLPAREN], # func( #
[:TkfLBRACK], # func[ #
[:TkfLBRACE], # func{ #
@@ -253,7 +253,7 @@ module RubyToken
IRB.fail AlreadyDefinedToken, token_n
end
token_c = eval("class #{token_n} < #{super_token}; end; #{token_n}")
-
+
if reading
if TkReading2Token[reading]
IRB.fail TkReading2TokenDuplicateError, token_n, reading
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
index f7e3a3b2b2..3cc5c49560 100644
--- a/lib/irb/slex.rb
+++ b/lib/irb/slex.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
@@ -25,20 +25,20 @@ module IRB
D_WARN = DOUT::def_notifier(1, "Warn: ")
D_DEBUG = DOUT::def_notifier(2, "Debug: ")
D_DETAIL = DOUT::def_notifier(4, "Detail: ")
-
+
DOUT.level = Notifier::D_NOMSG
def initialize
@head = Node.new("")
end
-
+
def def_rule(token, preproc = nil, postproc = nil, &block)
D_DETAIL.pp token
postproc = block if block_given?
node = create(token, preproc, postproc)
end
-
+
def def_rules(*tokens, &block)
if block_given?
p = block
@@ -47,18 +47,18 @@ module IRB
def_rule(token, nil, p)
end
end
-
+
def preproc(token, proc)
node = search(token)
node.preproc=proc
end
-
- #$BMW%A%'%C%/(B?
+
+ #$BMW%A%'%C%/(B?
def postproc(token)
node = search(token, proc)
node.postproc=proc
end
-
+
def search(token)
@head.search(token.split(//))
end
@@ -66,7 +66,7 @@ module IRB
def create(token, preproc = nil, postproc = nil)
@head.create_subnode(token.split(//), preproc, postproc)
end
-
+
def match(token)
case token
when Array
@@ -79,14 +79,14 @@ module IRB
D_DETAIL.exec_if{D_DEATIL.printf "match end: %s:%s\n", ret, token.inspect}
ret
end
-
+
def inspect
format("<SLex: @head = %s>", @head.inspect)
end
#----------------------------------------------------------------------
#
- # class Node -
+ # class Node -
#
#----------------------------------------------------------------------
class Node
@@ -100,7 +100,7 @@ module IRB
attr_accessor :preproc
attr_accessor :postproc
-
+
def search(chrs, opt = nil)
return self if chrs.empty?
ch = chrs.shift
@@ -115,7 +115,7 @@ module IRB
end
end
end
-
+
def create_subnode(chrs, preproc = nil, postproc = nil)
if chrs.empty?
if @postproc
@@ -128,7 +128,7 @@ module IRB
end
return self
end
-
+
ch = chrs.shift
if node = @Tree[ch]
if chrs.empty?
@@ -162,7 +162,7 @@ module IRB
# chrs: String
# character array
# io must have getc()/ungetc(); and ungetc() must be
- # able to be called arbitrary number of times.
+ # able to be called arbitrary number of times.
#
def match(chrs, op = "")
D_DETAIL.print "match>: ", chrs, "op:", op, "\n"
@@ -257,14 +257,14 @@ if $0 == __FILE__
print "1: ", tr.inspect, "\n"
tr.def_rule("==") {print "==\n"}
print "2: ", tr.inspect, "\n"
-
+
print "case 1:\n"
print tr.match("="), "\n"
print "case 2:\n"
print tr.match("=="), "\n"
print "case 3:\n"
print tr.match("=>"), "\n"
-
+
when "2"
tr = SLex.new
print "0: ", tr.inspect, "\n"
@@ -272,7 +272,7 @@ if $0 == __FILE__
print "1: ", tr.inspect, "\n"
tr.def_rule("==", proc{false}) {print "==\n"}
print "2: ", tr.inspect, "\n"
-
+
print "case 1:\n"
print tr.match("="), "\n"
print "case 2:\n"
diff --git a/lib/irb/version.rb b/lib/irb/version.rb
index 28b079740a..721a6e1af0 100644
--- a/lib/irb/version.rb
+++ b/lib/irb/version.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
diff --git a/lib/irb/workspace.rb b/lib/irb/workspace.rb
index 7d1794cd7b..924ed46ca3 100644
--- a/lib/irb/workspace.rb
+++ b/lib/irb/workspace.rb
@@ -1,5 +1,5 @@
#
-# irb/workspace-binding.rb -
+# irb/workspace-binding.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
module IRB
class WorkSpace
@@ -22,7 +22,7 @@ module IRB
case IRB.conf[:CONTEXT_MODE]
when 0 # binding in proc on TOPLEVEL_BINDING
@binding = eval("proc{binding}.call",
- TOPLEVEL_BINDING,
+ TOPLEVEL_BINDING,
__FILE__,
__LINE__)
when 1 # binding in loaded file
@@ -38,7 +38,7 @@ EOF
when 2 # binding in loaded file(thread use)
unless defined? BINDING_QUEUE
require "thread"
-
+
IRB.const_set("BINDING_QUEUE", SizedQueue.new(1))
Thread.abort_on_exception = true
Thread.start do
@@ -50,7 +50,7 @@ EOF
when 3 # binging in function on TOPLEVEL_BINDING(default)
@binding = eval("def irb_binding; binding; end; irb_binding",
- TOPLEVEL_BINDING,
+ TOPLEVEL_BINDING,
__FILE__,
__LINE__ - 3)
end
@@ -64,7 +64,7 @@ EOF
when Module
@binding = eval("IRB.conf[:__MAIN__].module_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
else
- begin
+ begin
@binding = eval("IRB.conf[:__MAIN__].instance_eval('binding', __FILE__, __LINE__)", @binding, __FILE__, __LINE__)
rescue TypeError
IRB.fail CantChangeBinding, @main.inspect
@@ -80,7 +80,7 @@ EOF
def evaluate(context, statements, file = __FILE__, line = __LINE__)
eval(statements, @binding, file, line)
end
-
+
# error message manipulator
def filter_backtrace(bt)
case IRB.conf[:CONTEXT_MODE]
@@ -96,7 +96,7 @@ EOF
return nil if bt =~ /irb\/.*\.rb/
when 3
return nil if bt =~ /irb\/.*\.rb/
- bt.sub!(/:\s*in `irb_binding'/){""}
+ bt.sub!(/:\s*in `irb_binding'/){""}
end
bt
end
diff --git a/lib/irb/ws-for-case-2.rb b/lib/irb/ws-for-case-2.rb
index afd49d23e1..4603861f73 100644
--- a/lib/irb/ws-for-case-2.rb
+++ b/lib/irb/ws-for-case-2.rb
@@ -1,5 +1,5 @@
#
-# irb/ws-for-case-2.rb -
+# irb/ws-for-case-2.rb -
# $Release Version: 0.9.5$
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
while true
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
index 4bcc2ca22f..4ab0b0e98e 100644
--- a/lib/irb/xmp.rb
+++ b/lib/irb/xmp.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "irb"
diff --git a/lib/mailread.rb b/lib/mailread.rb
index 08b33c92a4..7e1e5594ec 100644
--- a/lib/mailread.rb
+++ b/lib/mailread.rb
@@ -1,5 +1,5 @@
# The Mail class represents an internet mail message (as per RFC822, RFC2822)
-# with headers and a body.
+# with headers and a body.
class Mail
# Create a new Mail where +f+ is either a stream which responds to gets(),
@@ -31,7 +31,7 @@ class Mail
@header[attr] += "\n" + line
end
end
-
+
return unless line
while line = f.gets()
@@ -53,7 +53,7 @@ class Mail
return @body
end
- # Return the header corresponding to +field+.
+ # Return the header corresponding to +field+.
#
# Matching is case-insensitive.
def [](field)
diff --git a/lib/mathn.rb b/lib/mathn.rb
index 7d16923670..04b7b6f3e6 100644
--- a/lib/mathn.rb
+++ b/lib/mathn.rb
@@ -1,5 +1,5 @@
#
-# mathn.rb -
+# mathn.rb -
# $Release Version: 0.5 $
# $Revision: 1.1.1.1.4.1 $
# $Date: 1998/01/16 12:36:05 $
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "complex.rb"
@@ -20,10 +20,10 @@ class Integer
a = self.abs
b = int.abs
a, b = b, a if a < b
-
+
pd_a = a.prime_division
pd_b = b.prime_division
-
+
gcd = 1
for pair in pd_a
as = pd_b.assoc(pair[0])
@@ -33,7 +33,7 @@ class Integer
end
return gcd
end
-
+
def Integer.from_prime_division(pd)
value = 1
for prime, index in pd
@@ -41,7 +41,7 @@ class Integer
end
value
end
-
+
def prime_division
raise ZeroDivisionError if self == 0
ps = Prime.new
@@ -65,7 +65,7 @@ class Integer
return pv
end
end
-
+
class Prime
include Enumerable
@@ -74,7 +74,7 @@ class Prime
@primes = []
@counts = []
end
-
+
def succ
i = -1
size = @primes.size
@@ -155,14 +155,14 @@ class Rational
elsif self == 1
return Rational(1,1)
end
-
+
npd = numerator.prime_division
dpd = denominator.prime_division
if other < 0
other = -other
npd, dpd = dpd, npd
end
-
+
for elm in npd
elm[1] = elm[1] * other
if !elm[1].kind_of?(Integer) and elm[1].denominator != 1
@@ -170,7 +170,7 @@ class Rational
end
elm[1] = elm[1].to_i
end
-
+
for elm in dpd
elm[1] = elm[1] * other
if !elm[1].kind_of?(Integer) and elm[1].denominator != 1
@@ -178,12 +178,12 @@ class Rational
end
elm[1] = elm[1].to_i
end
-
+
num = Integer.from_prime_division(npd)
den = Integer.from_prime_division(dpd)
-
+
Rational(num,den)
-
+
elsif other.kind_of?(Integer)
if other > 0
num = numerator ** other
@@ -215,7 +215,7 @@ class Rational
elsif self == 1
return Rational(1,1)
end
-
+
dem = nil
x = self.denominator.to_f.to_i
neard = self.denominator.to_f ** (1.0/other.denominator.to_f)
@@ -227,7 +227,7 @@ class Rational
end
nearn = self.numerator.to_f ** (1.0/other.denominator.to_f)
Rational(num,den)
-
+
elsif other.kind_of?(Integer)
if other > 0
num = numerator ** other
@@ -261,7 +261,7 @@ module Math
# if !(x.kind_of?(Rational) and y.kind_of?(Rational))
# return a**Rational(1,2)
# end
- if a.image >= 0
+ if a.image >= 0
Complex(x, y)
else
Complex(x, -y)
@@ -272,7 +272,7 @@ module Math
Complex(0,rsqrt(-a))
end
end
-
+
def rsqrt(a)
if a.kind_of?(Float)
sqrt!(a)
@@ -286,7 +286,7 @@ module Math
while (src >= max) and (src >>= 32)
byte_a.unshift src & 0xffffffff
end
-
+
answer = 0
main = 0
side = 0
@@ -296,13 +296,13 @@ module Math
if answer != 0
if main * 4 < side * side
applo = main.div(side)
- else
+ else
applo = ((sqrt!(side * side + 4 * main) - side)/2.0).to_i + 1
end
else
applo = sqrt!(main).to_i + 1
end
-
+
while (x = (side + applo) * applo) > main
applo -= 1
end
diff --git a/lib/matrix.rb b/lib/matrix.rb
index 93ae3a9909..2f0f1b9d68 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -1,6 +1,6 @@
#!/usr/local/bin/ruby
#--
-# matrix.rb -
+# matrix.rb -
# $Release Version: 1.0$
# $Revision: 1.11 $
# $Date: 1999/10/06 11:01:53 $
@@ -14,9 +14,9 @@
# An implementation of Matrix and Vector classes.
#
# Author:: Keiju ISHITSUKA
-# Documentation:: Gavin Sinclair (sourced from <i>Ruby in a Nutshell</i> (Matsumoto, O'Reilly))
+# Documentation:: Gavin Sinclair (sourced from <i>Ruby in a Nutshell</i> (Matsumoto, O'Reilly))
#
-# See classes Matrix and Vector for documentation.
+# See classes Matrix and Vector for documentation.
#
@@ -26,7 +26,7 @@ module ExceptionForMatrix # :nodoc:
extend Exception2MessageMapper
def_e2message(TypeError, "wrong argument type %s (expected %s)")
def_e2message(ArgumentError, "Wrong # of arguments(%d for %d)")
-
+
def_exception("ErrDimensionMismatch", "\#{self.name} dimension mismatch")
def_exception("ErrNotRegular", "Not Regular Matrix")
def_exception("ErrOperationNotDefined", "This operation(%s) can\\'t defined")
@@ -60,7 +60,7 @@ end
# * <tt> Matrix.row_vector(row) </tt>
# * <tt> Matrix.column_vector(column) </tt>
#
-# To access Matrix elements/columns/rows/submatrices/properties:
+# To access Matrix elements/columns/rows/submatrices/properties:
# * <tt> [](i, j) </tt>
# * <tt> #row_size </tt>
# * <tt> #column_size </tt>
@@ -105,13 +105,13 @@ end
#
class Matrix
@RCS_ID='-$Id: matrix.rb,v 1.11 1999/10/06 11:01:53 keiju Exp keiju $-'
-
+
# extend Exception2MessageMapper
include ExceptionForMatrix
-
+
# instance creations
private_class_method :new
-
+
#
# Creates a matrix where each argument is a row.
# Matrix[ [25, 93], [-1, 66] ]
@@ -121,7 +121,7 @@ class Matrix
def Matrix.[](*rows)
new(:init_rows, rows, false)
end
-
+
#
# Creates a matrix where +rows+ is an array of arrays, each of which is a row
# of the matrix. If the optional argument +copy+ is false, use the given
@@ -133,7 +133,7 @@ class Matrix
def Matrix.rows(rows, copy = true)
new(:init_rows, rows, copy)
end
-
+
#
# Creates a matrix using +columns+ as an array of column vectors.
# Matrix.columns([[25, 93], [-1, 66]])
@@ -148,7 +148,7 @@ class Matrix
}
Matrix.rows(rows, false)
end
-
+
#
# Creates a matrix where the diagonal elements are composed of +values+.
# Matrix.diagonal(9, 5, -3)
@@ -165,7 +165,7 @@ class Matrix
}
rows(rows, false)
end
-
+
#
# Creates an +n+ by +n+ diagonal matrix where each diagonal element is
# +value+.
@@ -186,11 +186,11 @@ class Matrix
def Matrix.identity(n)
Matrix.scalar(n, 1)
end
- class << Matrix
+ class << Matrix
alias unit identity
alias I identity
end
-
+
#
# Creates an +n+ by +n+ zero matrix.
# Matrix.zero(2)
@@ -200,7 +200,7 @@ class Matrix
def Matrix.zero(n)
Matrix.scalar(n, 0)
end
-
+
#
# Creates a single-row matrix where the values of that row are as given in
# +row+.
@@ -217,7 +217,7 @@ class Matrix
Matrix.rows([[row]], false)
end
end
-
+
#
# Creates a single-column matrix where the values of that column are as given
# in +column+.
@@ -244,7 +244,7 @@ class Matrix
def initialize(init_method, *argv)
self.send(init_method, *argv)
end
-
+
def init_rows(rows, copy)
if copy
@rows = rows.collect{|row| row.dup}
@@ -254,7 +254,7 @@ class Matrix
self
end
private :init_rows
-
+
#
# Returns element (+i+,+j+) of the matrix. That is: row +i+, column +j+.
#
@@ -268,7 +268,7 @@ class Matrix
def row_size
@rows.size
end
-
+
#
# Returns the number of columns. Note that it is possible to construct a
# matrix with uneven columns (e.g. Matrix[ [1,2,3], [4,5] ]), but this is
@@ -308,7 +308,7 @@ class Matrix
Vector.elements(col, false)
end
end
-
+
#
# Returns a matrix that is the result of iteration of the given block over all
# elements of the matrix.
@@ -321,7 +321,7 @@ class Matrix
Matrix.rows(rows, false)
end
alias map collect
-
+
#
# Returns a section of the matrix. The parameters are either:
# * start_row, nrows, start_col, ncols; OR
@@ -345,14 +345,14 @@ class Matrix
else
Matrix.Raise ArgumentError, param.inspect
end
-
+
rows = @rows[from_row, size_row].collect{
|row|
row[from_col, size_col]
}
Matrix.rows(rows, false)
end
-
+
#--
# TESTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -363,7 +363,7 @@ class Matrix
def regular?
square? and rank == column_size
end
-
+
#
# Returns +true+ is this is a singular (i.e. non-regular) matrix.
#
@@ -378,7 +378,7 @@ class Matrix
def square?
column_size == row_size
end
-
+
#--
# OBJECT METHODS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -388,15 +388,15 @@ class Matrix
#
def ==(other)
return false unless Matrix === other
-
+
other.compare_by_row_vectors(@rows)
end
def eql?(other)
return false unless Matrix === other
-
+
other.compare_by_row_vectors(@rows, :eql?)
end
-
+
#
# Not really intended for general consumption.
#
@@ -408,7 +408,7 @@ class Matrix
end
true
end
-
+
#
# Returns a clone of the matrix, so that the contents of each do not reference
# identical objects.
@@ -416,18 +416,18 @@ class Matrix
def clone
Matrix.rows(@rows)
end
-
+
#
# Returns a hash-code for the matrix.
#
def hash
@rows.hash
end
-
+
#--
# ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# Matrix multiplication.
# Matrix[[2,4], [6,8]] * Matrix.identity(2)
@@ -465,7 +465,7 @@ class Matrix
return x * y
end
end
-
+
#
# Matrix addition.
# Matrix.scalar(2,5) + Matrix[[1,0], [-4,7]]
@@ -483,7 +483,7 @@ class Matrix
x, y = m.coerce(self)
return x + y
end
-
+
Matrix.Raise ErrDimensionMismatch unless row_size == m.row_size and column_size == m.column_size
rows = (0 ... row_size).collect {|i|
@@ -511,7 +511,7 @@ class Matrix
x, y = m.coerce(self)
return x - y
end
-
+
Matrix.Raise ErrDimensionMismatch unless row_size == m.row_size and column_size == m.column_size
rows = (0 ... row_size).collect {|i|
@@ -521,7 +521,7 @@ class Matrix
}
Matrix.rows(rows, false)
end
-
+
#
# Matrix division (multiplication by the inverse).
# Matrix[[7,6], [3,9]] / Matrix[[2,9], [3,1]]
@@ -606,7 +606,7 @@ class Matrix
self
end
#alias reciprocal inverse
-
+
#
# Matrix exponentiation. Defined for integer powers only. Equivalent to
# multiplying the matrix by itself N times.
@@ -640,11 +640,11 @@ class Matrix
Matrix.Raise ErrOperationNotDefined, "**"
end
end
-
+
#--
# MATRIX FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# Returns the determinant of the matrix. If the matrix is not square, the
# result is 0.
@@ -656,7 +656,7 @@ class Matrix
size = row_size
a = to_a
-
+
det = 1
size.times do |k|
if (akk = a[k][k]) == 0
@@ -741,7 +741,7 @@ class Matrix
end
end
alias tr trace
-
+
#
# Returns the transpose of the matrix.
# Matrix[[1,2], [3,4], [5,6]]
@@ -756,11 +756,11 @@ class Matrix
Matrix.columns(@rows)
end
alias t transpose
-
+
#--
# CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# FIXME: describe #coerce.
#
@@ -781,7 +781,7 @@ class Matrix
row(i)
}
end
-
+
#
# Returns an array of the column vectors of the matrix. See Vector.
#
@@ -790,18 +790,18 @@ class Matrix
column(i)
}
end
-
+
#
# Returns an array of arrays that describe the rows of the matrix.
#
def to_a
@rows.collect{|row| row.dup}
end
-
+
#--
# PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# Overrides Object#to_s
#
@@ -811,23 +811,23 @@ class Matrix
"[" + row.collect{|e| e.to_s}.join(", ") + "]"
}.join(", ")+"]"
end
-
+
#
# Overrides Object#inspect
#
def inspect
end
-
+
# Private CLASS
-
+
class Scalar < Numeric # :nodoc:
include ExceptionForMatrix
-
+
def initialize(value)
@value = value
end
-
+
# ARITHMETIC
def +(other)
case other
@@ -842,7 +842,7 @@ class Matrix
x + y
end
end
-
+
def -(other)
case other
when Numeric
@@ -856,7 +856,7 @@ class Matrix
x - y
end
end
-
+
def *(other)
case other
when Numeric
@@ -868,7 +868,7 @@ class Matrix
x * y
end
end
-
+
def / (other)
case other
when Numeric
@@ -882,7 +882,7 @@ class Matrix
x / y
end
end
-
+
def ** (other)
case other
when Numeric
@@ -941,9 +941,9 @@ end
#
class Vector
include ExceptionForMatrix
-
+
#INSTANCE CREATION
-
+
private_class_method :new
#
@@ -953,7 +953,7 @@ class Vector
def Vector.[](*array)
new(:init_elements, array, copy = false)
end
-
+
#
# Creates a vector from an Array. The optional second argument specifies
# whether the array itself or a copy is used internally.
@@ -961,14 +961,14 @@ class Vector
def Vector.elements(array, copy = true)
new(:init_elements, array, copy)
end
-
+
#
# For internal use.
#
def initialize(method, array, copy)
self.send(method, array, copy)
end
-
+
#
# For internal use.
#
@@ -979,23 +979,23 @@ class Vector
@elements = array
end
end
-
+
# ACCESSING
-
+
#
# Returns element number +i+ (starting at zero) of the vector.
#
def [](i)
@elements[i]
end
-
+
#
# Returns the number of elements in the vector.
#
def size
@elements.size
end
-
+
#--
# ENUMERATIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -1009,7 +1009,7 @@ class Vector
yield @elements[i], v[i]
end
end
-
+
#
# Collects (as in Enumerable#collect) over the elements of this vector and +v+
# in conjunction.
@@ -1030,40 +1030,40 @@ class Vector
#
def ==(other)
return false unless Vector === other
-
+
other.compare_by(@elements)
end
def eql?(other)
return false unless Vector === other
-
+
other.compare_by(@elements, :eql?)
end
-
+
#
# For internal use.
#
def compare_by(elements, comparison = :==)
@elements.send(comparison, elements)
end
-
+
#
# Return a copy of the vector.
#
def clone
Vector.elements(@elements)
end
-
+
#
# Return a hash-code for the vector.
#
def hash
@elements.hash
end
-
+
#--
# ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# Multiplies the vector by +x+, where +x+ is a number or another vector.
#
@@ -1119,18 +1119,18 @@ class Vector
s - x
end
end
-
+
#--
# VECTOR FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# Returns the inner product of this vector with the other.
# Vector[4,7].inner_product Vector[10,1] => 47
#
def inner_product(v)
Vector.Raise ErrDimensionMismatch if size != v.size
-
+
p = 0
each2(v) {
|v1, v2|
@@ -1138,7 +1138,7 @@ class Vector
}
p
end
-
+
#
# Like Array#collect.
#
@@ -1147,7 +1147,7 @@ class Vector
Vector.elements(els, false)
end
alias map collect
-
+
#
# Like Vector#collect2, but returns a Vector instead of an Array.
#
@@ -1155,7 +1155,7 @@ class Vector
els = collect2(v, &block)
Vector.elements(els, false)
end
-
+
#
# Returns the modulus (Pythagorean distance) of the vector.
# Vector[5,8,2].r => 9.643650761
@@ -1163,7 +1163,7 @@ class Vector
def r
Math.sqrt(@elements.inject(0) {|v, e| v + e*e})
end
-
+
#--
# CONVERTING
#++
@@ -1174,14 +1174,14 @@ class Vector
def covector
Matrix.row_vector(self)
end
-
+
#
# Returns the elements of the vector in an array.
#
def to_a
@elements.dup
end
-
+
#
# FIXME: describe Vector#coerce.
#
@@ -1193,18 +1193,18 @@ class Vector
raise TypeError, "#{self.class} can't be coerced into #{other.class}"
end
end
-
+
#--
# PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
-
+
#
# Overrides Object#to_s
#
def to_s
"Vector[" + @elements.join(", ") + "]"
end
-
+
#
# Overrides Object#inspect
#
diff --git a/lib/monitor.rb b/lib/monitor.rb
index 9158f9fb32..004e0557cb 100644
--- a/lib/monitor.rb
+++ b/lib/monitor.rb
@@ -12,11 +12,11 @@ You can freely distribute/modify this library.
This is a simple example.
require 'monitor.rb'
-
+
buf = []
buf.extend(MonitorMixin)
empty_cond = buf.new_cond
-
+
# consumer
Thread.start do
loop do
@@ -26,7 +26,7 @@ This is a simple example.
end
end
end
-
+
# producer
while line = ARGF.gets
buf.synchronize do
@@ -41,18 +41,18 @@ reads a line from ARGF and push it to buf, then call
empty_cond.signal.
=end
-
+
#
# Adds monitor functionality to an arbitrary object by mixing the module with
# +include+. For example:
#
# require 'monitor.rb'
-#
+#
# buf = []
# buf.extend(MonitorMixin)
# empty_cond = buf.new_cond
-#
+#
# # consumer
# Thread.start do
# loop do
@@ -62,7 +62,7 @@ empty_cond.signal.
# end
# end
# end
-#
+#
# # producer
# while line = ARGF.gets
# buf.synchronize do
@@ -70,7 +70,7 @@ empty_cond.signal.
# empty_cond.signal
# end
# end
-#
+#
# The consumer thread waits for the producer thread to push a line
# to buf while buf.empty?, and the producer thread (main thread)
# reads a line from ARGF and push it to buf, then call
@@ -85,15 +85,15 @@ module MonitorMixin
#
class ConditionVariable
class Timeout < Exception; end
-
+
# Create a new timer with the argument timeout, and add the
# current thread to the list of waiters. Then the thread is
- # stopped. It will be resumed when a corresponding #signal
+ # stopped. It will be resumed when a corresponding #signal
# occurs.
def wait(timeout = nil)
@monitor.instance_eval {mon_check_owner()}
timer = create_timer(timeout)
-
+
Thread.critical = true
count = @monitor.instance_eval {mon_exit_for_cond()}
@waiters.push(Thread.current)
@@ -118,7 +118,7 @@ module MonitorMixin
end
end
end
-
+
# call #wait while the supplied block returns +true+.
def wait_while
@@ -126,14 +126,14 @@ module MonitorMixin
wait
end
end
-
+
# call #wait until the supplied block returns +true+.
def wait_until
until yield
wait
end
end
-
+
# Wake up and run the next waiter
def signal
@monitor.instance_eval {mon_check_owner()}
@@ -143,7 +143,7 @@ module MonitorMixin
Thread.critical = false
Thread.pass
end
-
+
# Wake up all the waiters.
def broadcast
@monitor.instance_eval {mon_check_owner()}
@@ -155,11 +155,11 @@ module MonitorMixin
Thread.critical = false
Thread.pass
end
-
+
def count_waiters
return @waiters.length
end
-
+
private
def initialize(monitor)
@@ -181,12 +181,12 @@ module MonitorMixin
end
end
end
-
+
def self.extend_object(obj)
super(obj)
obj.instance_eval {mon_initialize()}
end
-
+
#
# Attempts to enter exclusive section. Returns +false+ if lock fails.
#
@@ -216,7 +216,7 @@ module MonitorMixin
ensure
Thread.critical = false
end
-
+
#
# Leaves exclusive section.
#
@@ -245,10 +245,10 @@ module MonitorMixin
end
end
alias synchronize mon_synchronize
-
+
#
# FIXME: This isn't documented in Nutshell.
- #
+ #
# Create a new condition variable for this monitor.
# This facilitates control of the monitor with #signal and #wait.
#
@@ -316,7 +316,7 @@ end
# Monitors provide means of mutual exclusion for Thread programming.
# A critical region is created by means of the synchronize method,
# which takes a block.
-# The condition variables (created with #new_cond) may be used
+# The condition variables (created with #new_cond) may be used
# to control the execution of a monitor with #signal and #wait.
#
# the Monitor class wraps MonitorMixin, and provides aliases
diff --git a/lib/mutex_m.rb b/lib/mutex_m.rb
index 8e0d42bc8d..b00756cb21 100644
--- a/lib/mutex_m.rb
+++ b/lib/mutex_m.rb
@@ -1,5 +1,5 @@
#--
-# mutex_m.rb -
+# mutex_m.rb -
# $Release Version: 3.0$
# $Revision: 1.7 $
# $Date: 1998/02/27 04:28:57 $
@@ -25,7 +25,7 @@
# include Mutex_m
# # ...
# end
-#
+#
# obj = Foo.new
module Mutex_m
@@ -37,13 +37,13 @@ module Mutex_m
alias try_lock mu_try_lock
alias synchronize mu_synchronize
}
- end
+ end
def Mutex_m.append_features(cl)
super
define_aliases(cl) unless cl.instance_of?(Module)
end
-
+
def Mutex_m.extend_object(obj)
super
obj.mu_extended
@@ -59,8 +59,8 @@ module Mutex_m
end
mu_initialize
end
-
- # locking
+
+ # locking
def mu_synchronize
begin
mu_lock
@@ -69,11 +69,11 @@ module Mutex_m
mu_unlock
end
end
-
+
def mu_locked?
@mu_locked
end
-
+
def mu_try_lock
result = false
Thread.critical = true
@@ -84,7 +84,7 @@ module Mutex_m
Thread.critical = false
result
end
-
+
def mu_lock
while (Thread.critical = true; @mu_locked)
@mu_waiting.push Thread.current
@@ -94,7 +94,7 @@ module Mutex_m
Thread.critical = false
self
end
-
+
def mu_unlock
return unless @mu_locked
Thread.critical = true
@@ -107,9 +107,9 @@ module Mutex_m
end
self
end
-
+
private
-
+
def mu_initialize
@mu_waiting = []
@mu_locked = false;
diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb
index c611e09ee3..1b2399dc84 100644
--- a/lib/net/ftp.rb
+++ b/lib/net/ftp.rb
@@ -1,11 +1,11 @@
-#
+#
# = net/ftp.rb - FTP Client Library
-#
+#
# Written by Shugo Maeda <[email protected]>.
#
# Documentation by Gavin Sinclair, sourced from "Programming Ruby" (Hunt/Thomas)
# and "Ruby In a Nutshell" (Matsumoto), used with permission.
-#
+#
# This library is distributed under the terms of the Ruby license.
# You can freely distribute/modify this library.
#
@@ -22,8 +22,8 @@ module Net
# :stopdoc:
class FTPError < StandardError; end
class FTPReplyError < FTPError; end
- class FTPTempError < FTPError; end
- class FTPPermError < FTPError; end
+ class FTPTempError < FTPError; end
+ class FTPPermError < FTPError; end
class FTPProtoError < FTPError; end
# :startdoc:
@@ -34,11 +34,11 @@ module Net
# advantage of Ruby's style and strengths.
#
# == Example
- #
+ #
# require 'net/ftp'
#
# === Example 1
- #
+ #
# ftp = Net::FTP.new('ftp.netlab.co.jp')
# ftp.login
# files = ftp.chdir('pub/lang/ruby/contrib')
@@ -71,13 +71,13 @@ module Net
#
class FTP
include MonitorMixin
-
+
# :stopdoc:
FTP_PORT = 21
CRLF = "\r\n"
DEFAULT_BLOCKSIZE = 4096
# :startdoc:
-
+
# When +true+, transfers are performed in binary mode. Default: +true+.
attr_accessor :binary
@@ -101,7 +101,7 @@ module Net
# The server's last response.
attr_reader :last_response
-
+
#
# A synonym for <tt>FTP.new</tt>, but with a mandatory host parameter.
#
@@ -120,7 +120,7 @@ module Net
new(host, user, passwd, acct)
end
end
-
+
#
# Creates and returns a new +FTP+ object. If a +host+ is given, a connection
# is made. Additionally, if the +user+ is given, the given user name,
@@ -160,7 +160,7 @@ module Net
end
end
private :open_socket
-
+
#
# Establishes an FTP connection to host, optionally overriding the default
# port. If the environment variable +SOCKS_SERVER+ is set, sets up the
@@ -197,7 +197,7 @@ module Net
end
end
private :sanitize
-
+
def putline(line)
if @debug_mode
print "put: ", sanitize(line), "\n"
@@ -206,7 +206,7 @@ module Net
@sock.write(line)
end
private :putline
-
+
def getline
line = @sock.readline # if get EOF, raise EOFError
line.sub!(/(\r\n|\n|\r)\z/n, "")
@@ -216,7 +216,7 @@ module Net
return line
end
private :getline
-
+
def getmultiline
line = getline
buff = line
@@ -230,7 +230,7 @@ module Net
return buff << "\n"
end
private :getmultiline
-
+
def getresp
@last_response = getmultiline
@last_response_code = @last_response[0, 3]
@@ -246,7 +246,7 @@ module Net
end
end
private :getresp
-
+
def voidresp
resp = getresp
if resp[0] != ?2
@@ -254,7 +254,7 @@ module Net
end
end
private :voidresp
-
+
#
# Sends a command and returns the response.
#
@@ -264,7 +264,7 @@ module Net
return getresp
end
end
-
+
#
# Sends a command and expect a response beginning with '2'.
#
@@ -274,7 +274,7 @@ module Net
voidresp
end
end
-
+
def sendport(host, port)
af = (@sock.peeraddr)[0]
if af == "AF_INET"
@@ -287,7 +287,7 @@ module Net
voidcmd(cmd)
end
private :sendport
-
+
def makeport
sock = TCPServer.open(@sock.addr[3], 0)
port = sock.addr[1]
@@ -296,7 +296,7 @@ module Net
return sock
end
private :makeport
-
+
def makepasv
if @sock.peeraddr[0] == "AF_INET"
host, port = parse227(sendcmd("PASV"))
@@ -307,13 +307,13 @@ module Net
return host, port
end
private :makepasv
-
+
def transfercmd(cmd, rest_offset = nil)
if @passive
host, port = makepasv
conn = open_socket(host, port)
if @resume and rest_offset
- resp = sendcmd("REST " + rest_offset.to_s)
+ resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3
raise FTPReplyError, resp
end
@@ -327,7 +327,7 @@ module Net
else
sock = makeport
if @resume and rest_offset
- resp = sendcmd("REST " + rest_offset.to_s)
+ resp = sendcmd("REST " + rest_offset.to_s)
if resp[0] != ?3
raise FTPReplyError, resp
end
@@ -344,7 +344,7 @@ module Net
return conn
end
private :transfercmd
-
+
def getaddress
thishost = Socket.gethostname rescue ""
if not thishost.index(".")
@@ -360,7 +360,7 @@ module Net
return realuser + "@" + thishost
end
private :getaddress
-
+
#
# Logs in to the remote host. The session must have been previously
# connected. If +user+ is the string "anonymous" and the +password+ is
@@ -373,7 +373,7 @@ module Net
if user == "anonymous" and passwd == nil
passwd = getaddress
end
-
+
resp = ""
synchronize do
resp = sendcmd('USER ' + user)
@@ -391,7 +391,7 @@ module Net
end
@welcome = resp
end
-
+
#
# Puts the connection into binary (image) mode, issues the given command,
# and fetches the data returned, passing it to the associated block in
@@ -411,7 +411,7 @@ module Net
voidresp
end
end
-
+
#
# Puts the connection into ASCII (text) mode, issues the given command, and
# passes the resulting data, one line at a time, to the associated block. If
@@ -436,7 +436,7 @@ module Net
voidresp
end
end
-
+
#
# Puts the connection into binary (image) mode, issues the given server-side
# command (such as "STOR myfile"), and sends the contents of the file named
@@ -460,7 +460,7 @@ module Net
voidresp
end
end
-
+
#
# Puts the connection into ASCII (text) mode, issues the given server-side
# command (such as "STOR myfile"), and sends the contents of the file
@@ -509,7 +509,7 @@ module Net
f.close
end
end
-
+
#
# Retrieves +remotefile+ in ASCII (text) mode, storing the result in
# +localfile+. If a block is supplied, it is passed the retrieved data one
@@ -539,7 +539,7 @@ module Net
getbinaryfile(remotefile, localfile, blocksize, &block)
end
end
-
+
#
# Transfers +localfile+ to the server in binary mode, storing the result in
# +remotefile+. If a block is supplied, calls it, passing in the transmitted
@@ -568,7 +568,7 @@ module Net
f.close
end
end
-
+
#
# Transfers +localfile+ to the server in ASCII (text) mode, storing the result
# in +remotefile+. If callback or an associated block is supplied, calls it,
@@ -603,7 +603,7 @@ module Net
cmd = "ACCT " + account
voidcmd(cmd)
end
-
+
#
# Returns an array of filenames in the remote directory.
#
@@ -618,7 +618,7 @@ module Net
end
return files
end
-
+
#
# Returns an array of file information in the directory (the output is like
# `ls -l`). If a block is given, it iterates through the listing.
@@ -640,7 +640,7 @@ module Net
end
alias ls list
alias dir list
-
+
#
# Renames a file on the server.
#
@@ -651,7 +651,7 @@ module Net
end
voidcmd("RNTO " + toname)
end
-
+
#
# Deletes a file on the server.
#
@@ -665,7 +665,7 @@ module Net
raise FTPReplyError, resp
end
end
-
+
#
# Changes the (remote) directory.
#
@@ -683,21 +683,21 @@ module Net
cmd = "CWD " + dirname
voidcmd(cmd)
end
-
+
#
# Returns the size of the given (remote) filename.
#
def size(filename)
voidcmd("TYPE I")
resp = sendcmd("SIZE " + filename)
- if resp[0, 3] != "213"
+ if resp[0, 3] != "213"
raise FTPReplyError, resp
end
return resp[3..-1].strip.to_i
end
-
+
MDTM_REGEXP = /^(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/ # :nodoc:
-
+
#
# Returns the last modification time of the (remote) file. If +local+ is
# +true+, it is returned as a local time, otherwise it's a UTC time.
@@ -707,7 +707,7 @@ module Net
ary = str.scan(MDTM_REGEXP)[0].collect {|i| i.to_i}
return local ? Time.local(*ary) : Time.gm(*ary)
end
-
+
#
# Creates a remote directory.
#
@@ -715,14 +715,14 @@ module Net
resp = sendcmd("MKD " + dirname)
return parse257(resp)
end
-
+
#
# Removes a remote directory.
#
def rmdir(dirname)
voidcmd("RMD " + dirname)
end
-
+
#
# Returns the current remote directory.
#
@@ -731,7 +731,7 @@ module Net
return parse257(resp)
end
alias getdir pwd
-
+
#
# Returns system information.
#
@@ -742,7 +742,7 @@ module Net
end
return resp[4 .. -1]
end
-
+
#
# Aborts the previous command (ABOR command).
#
@@ -756,7 +756,7 @@ module Net
end
return resp
end
-
+
#
# Returns the status (STAT command).
#
@@ -766,7 +766,7 @@ module Net
@sock.send(line, Socket::MSG_OOB)
return getresp
end
-
+
#
# Issues the MDTM command. TODO: more info.
#
@@ -776,7 +776,7 @@ module Net
return resp[3 .. -1].strip
end
end
-
+
#
# Issues the HELP command.
#
@@ -787,7 +787,7 @@ module Net
end
sendcmd(cmd)
end
-
+
#
# Exits the FTP session.
#
@@ -809,7 +809,7 @@ module Net
cmd = "SITE " + arg
voidcmd(cmd)
end
-
+
#
# Closes the connection. Further operations are impossible until you open
# a new connection with #connect.
@@ -817,14 +817,14 @@ module Net
def close
@sock.close if @sock and not @sock.closed?
end
-
+
#
# Returns +true+ iff the connection is closed.
#
def closed?
@sock == nil or @sock.closed?
end
-
+
def parse227(resp)
if resp[0, 3] != "227"
raise FTPReplyError, resp
@@ -843,7 +843,7 @@ module Net
return host, port
end
private :parse227
-
+
def parse228(resp)
if resp[0, 3] != "228"
raise FTPReplyError, resp
@@ -871,11 +871,11 @@ module Net
end
host = v6[0, 8].join(":")
port = (numbers[19].to_i << 8) + numbers[20].to_i
- end
+ end
return host, port
end
private :parse228
-
+
def parse229(resp)
if resp[0, 3] != "229"
raise FTPReplyError, resp
@@ -894,7 +894,7 @@ module Net
return host, port
end
private :parse229
-
+
def parse257(resp)
if resp[0, 3] != "257"
raise FTPReplyError, resp
diff --git a/lib/net/http.rb b/lib/net/http.rb
index 142248d3dc..e30f9c22eb 100644
--- a/lib/net/http.rb
+++ b/lib/net/http.rb
@@ -4,26 +4,26 @@
# Copyright (c) 1999-2006 Yukihiro Matsumoto
# Copyright (c) 1999-2006 Minero Aoki
# Copyright (c) 2001 GOTOU Yuuzou
-#
+#
# Written and maintained by Minero Aoki <[email protected]>.
# HTTPS support added by GOTOU Yuuzou <[email protected]>.
#
# This file is derived from "http-access.rb".
#
# Documented by Minero Aoki; converted to RDoc by William Webber.
-#
+#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms of ruby itself ---
# Ruby Distribution License or GNU General Public License.
#
-# See Net::HTTP for an overview and examples.
-#
+# See Net::HTTP for an overview and examples.
+#
# NOTE: You can find Japanese version of this document here:
# http://www.ruby-lang.org/ja/man/?cmd=view;name=net%2Fhttp.rb
-#
+#
#--
# $Id$
-#++
+#++
require 'net/protocol'
require 'uri'
@@ -36,29 +36,29 @@ module Net #:nodoc:
# :startdoc:
# == What Is This Library?
- #
+ #
# This library provides your program functions to access WWW
# documents via HTTP, Hyper Text Transfer Protocol version 1.1.
# For details of HTTP, refer to [RFC2616]
# (http://www.ietf.org/rfc/rfc2616.txt).
- #
+ #
# == Examples
- #
+ #
# === Getting Document From WWW Server
- #
+ #
# Example #1: Simple GET+print
- #
+ #
# require 'net/http'
# Net::HTTP.get_print 'www.example.com', '/index.html'
- #
+ #
# Example #2: Simple GET+print by URL
- #
+ #
# require 'net/http'
# require 'uri'
# Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
- #
+ #
# Example #3: More generic GET+print
- #
+ #
# require 'net/http'
# require 'uri'
#
@@ -69,7 +69,7 @@ module Net #:nodoc:
# puts res.body
#
# Example #4: More generic GET+print
- #
+ #
# require 'net/http'
#
# url = URI.parse('http://www.example.com/index.html')
@@ -78,9 +78,9 @@ module Net #:nodoc:
# http.request(req)
# }
# puts res.body
- #
+ #
# === Posting Form Data
- #
+ #
# require 'net/http'
# require 'uri'
#
@@ -106,15 +106,15 @@ module Net #:nodoc:
# else
# res.error!
# end
- #
+ #
# === Accessing via Proxy
- #
+ #
# Net::HTTP.Proxy creates http proxy class. It has same
# methods of Net::HTTP but its instances always connect to
# proxy, instead of given host.
- #
+ #
# require 'net/http'
- #
+ #
# proxy_addr = 'your.proxy.host'
# proxy_port = 8080
# :
@@ -122,20 +122,20 @@ module Net #:nodoc:
# # always connect to your.proxy.addr:8080
# :
# }
- #
+ #
# Since Net::HTTP.Proxy returns Net::HTTP itself when proxy_addr is nil,
# there's no need to change code if there's proxy or not.
- #
+ #
# There are two additional parameters in Net::HTTP.Proxy which allow to
# specify proxy user name and password:
- #
+ #
# Net::HTTP::Proxy(proxy_addr, proxy_port, proxy_user = nil, proxy_pass = nil)
- #
+ #
# You may use them to work with authorization-enabled proxies:
- #
+ #
# require 'net/http'
# require 'uri'
- #
+ #
# proxy_host = 'your.proxy.host'
# proxy_port = 8080
# uri = URI.parse(ENV['http_proxy'])
@@ -148,16 +148,16 @@ module Net #:nodoc:
#
# Note that net/http never rely on HTTP_PROXY environment variable.
# If you want to use proxy, set it explicitly.
- #
+ #
# === Following Redirection
- #
+ #
# require 'net/http'
# require 'uri'
- #
+ #
# def fetch(uri_str, limit = 10)
- # # You should choose better exception.
+ # # You should choose better exception.
# raise ArgumentError, 'HTTP redirect too deep' if limit == 0
- #
+ #
# response = Net::HTTP.get_response(URI.parse(uri_str))
# case response
# when Net::HTTPSuccess then response
@@ -166,25 +166,25 @@ module Net #:nodoc:
# response.error!
# end
# end
- #
+ #
# print fetch('http://www.ruby-lang.org')
- #
+ #
# Net::HTTPSuccess and Net::HTTPRedirection is a HTTPResponse class.
# All HTTPResponse objects belong to its own response class which
# indicate HTTP result status. For details of response classes,
# see section "HTTP Response Classes".
- #
+ #
# === Basic Authentication
- #
+ #
# require 'net/http'
- #
+ #
# Net::HTTP.start('www.example.com') {|http|
# req = Net::HTTP::Get.new('/secret-page.html')
# req.basic_auth 'account', 'password'
# response = http.request(req)
# print response.body
# }
- #
+ #
# === HTTP Request Classes
#
# Here is HTTP request class hierarchy.
@@ -257,22 +257,22 @@ module Net #:nodoc:
# HTTPServiceUnavailable # 503
# HTTPGatewayTimeOut # 504
# HTTPVersionNotSupported # 505
- #
+ #
# == Switching Net::HTTP versions
- #
+ #
# You can use net/http.rb 1.1 features (bundled with Ruby 1.6)
# by calling HTTP.version_1_1. Calling Net::HTTP.version_1_2
# allows you to use 1.2 features again.
- #
+ #
# # example
# Net::HTTP.start {|http1| ...(http1 has 1.2 features)... }
- #
+ #
# Net::HTTP.version_1_1
# Net::HTTP.start {|http2| ...(http2 has 1.1 features)... }
- #
+ #
# Net::HTTP.version_1_2
# Net::HTTP.start {|http3| ...(http3 has 1.2 features)... }
- #
+ #
# This function is NOT thread-safe.
#
class HTTP < Protocol
@@ -325,7 +325,7 @@ module Net #:nodoc:
#
# Get body from target and output it to +$stdout+. The
# target can either be specified as (+uri+), or as
- # (+host+, +path+, +port+ = 80); so:
+ # (+host+, +path+, +port+ = 80); so:
#
# Net::HTTP.get_print URI.parse('http://www.example.com/index.html')
#
@@ -345,7 +345,7 @@ module Net #:nodoc:
# Send a GET request to the target and return the response
# as a string. The target can either be specified as
# (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
+ #
# print Net::HTTP.get(URI.parse('http://www.example.com/index.html'))
#
# or:
@@ -359,7 +359,7 @@ module Net #:nodoc:
# Send a GET request to the target and return the response
# as a Net::HTTPResponse object. The target can either be specified as
# (+uri+), or as (+host+, +path+, +port+ = 80); so:
- #
+ #
# res = Net::HTTP.get_response(URI.parse('http://www.example.com/index.html'))
# print res.body
#
@@ -429,9 +429,9 @@ module Net #:nodoc:
BufferedIO
end
- # creates a new Net::HTTP object and opens its TCP connection and
- # HTTP session. If the optional block is given, the newly
- # created Net::HTTP object is passed to it and closed when the
+ # creates a new Net::HTTP object and opens its TCP connection and
+ # HTTP session. If the optional block is given, the newly
+ # created Net::HTTP object is passed to it and closed when the
# block finishes. In this case, the return value of this method
# is the return value of the block. If no block is given, the
# return value of this method is the newly created Net::HTTP object
@@ -527,7 +527,7 @@ module Net #:nodoc:
end
# Opens TCP connection and HTTP session.
- #
+ #
# When this method is called with block, gives a HTTP object
# to the block and closes the TCP connection / HTTP session
# after the block executed.
@@ -627,9 +627,9 @@ module Net #:nodoc:
# Arguments are address/port of proxy host and username/password
# if authorization on proxy server is required.
# You can replace the HTTP class with created proxy class.
- #
+ #
# If ADDRESS is nil, this method returns self (Net::HTTP).
- #
+ #
# # Example
# proxy_class = Net::HTTP::Proxy('proxy.example.com', 8080)
# :
@@ -637,7 +637,7 @@ module Net #:nodoc:
# # connecting proxy.foo.org:8080
# :
# }
- #
+ #
def HTTP.Proxy(p_addr, p_port = nil, p_user = nil, p_pass = nil)
return self unless p_addr
delta = ProxyDelta
@@ -748,7 +748,7 @@ module Net #:nodoc:
# +dest+ argument is obsolete.
# It still works but you must not use it.
#
- # In version 1.1, this method might raise an exception for
+ # In version 1.1, this method might raise an exception for
# 3xx (redirect). In this case you can get a HTTPResponse object
# by "anException.response".
#
@@ -759,7 +759,7 @@ module Net #:nodoc:
#
# # version 1.2 (bundled with Ruby 1.8 or later)
# response = http.get('/index.html')
- #
+ #
# # using block
# File.open('result.txt', 'w') {|f|
# http.get('/~foo/') do |str|
@@ -783,21 +783,21 @@ module Net #:nodoc:
# Gets only the header from +path+ on the connected-to host.
# +header+ is a Hash like { 'Accept' => '*/*', ... }.
- #
+ #
# This method returns a Net::HTTPResponse object.
- #
- # In version 1.1, this method might raise an exception for
+ #
+ # In version 1.1, this method might raise an exception for
# 3xx (redirect). On the case you can get a HTTPResponse object
# by "anException.response".
# In version 1.2, this method never raises an exception.
- #
+ #
# response = nil
# Net::HTTP.start('some.www.server', 80) {|http|
# response = http.head('/index.html')
# }
# p response['content-type']
#
- def head(path, initheader = nil)
+ def head(path, initheader = nil)
res = request(Head.new(path, initheader))
res.value unless @newimpl
res
@@ -805,11 +805,11 @@ module Net #:nodoc:
# Posts +data+ (must be a String) to +path+. +header+ must be a Hash
# like { 'Accept' => '*/*', ... }.
- #
+ #
# In version 1.1 (ruby 1.6), this method returns a pair of objects, a
# Net::HTTPResponse object and an entity body string.
# In version 1.2 (ruby 1.8), this method returns a Net::HTTPResponse object.
- #
+ #
# If called with a block, yields each fragment of the
# entity body in turn as a string as it are read from
# the socket. Note that in this case, the returned response
@@ -817,18 +817,18 @@ module Net #:nodoc:
#
# +dest+ argument is obsolete.
# It still works but you must not use it.
- #
- # In version 1.1, this method might raise an exception for
+ #
+ # In version 1.1, this method might raise an exception for
# 3xx (redirect). In this case you can get an HTTPResponse object
# by "anException.response".
# In version 1.2, this method never raises exception.
- #
+ #
# # version 1.1
# response, body = http.post('/cgi-bin/search.rb', 'query=foo')
- #
+ #
# # version 1.2
# response = http.post('/cgi-bin/search.rb', 'query=foo')
- #
+ #
# # using block
# File.open('result.txt', 'w') {|f|
# http.post('/cgi-bin/search.rb', 'query=foo') do |str|
@@ -921,21 +921,21 @@ module Net #:nodoc:
# Sends a GET request to the +path+ and gets a response,
# as an HTTPResponse object.
- #
+ #
# When called with a block, yields an HTTPResponse object.
# The body of this response will not have been read yet;
# the caller can process it using HTTPResponse#read_body,
# if desired.
#
# Returns the response.
- #
+ #
# This method never raises Net::* exceptions.
- #
+ #
# response = http.request_get('/index.html')
# # The entity body is already read here.
# p response['content-type']
# puts response.body
- #
+ #
# # using block
# http.request_get('/index.html') {|response|
# p response['content-type']
@@ -952,9 +952,9 @@ module Net #:nodoc:
# as an HTTPResponse object.
#
# Returns the response.
- #
+ #
# This method never raises Net::* exceptions.
- #
+ #
# response = http.request_head('/index.html')
# p response['content-type']
#
@@ -964,21 +964,21 @@ module Net #:nodoc:
# Sends a POST request to the +path+ and gets a response,
# as an HTTPResponse object.
- #
+ #
# When called with a block, yields an HTTPResponse object.
# The body of this response will not have been read yet;
# the caller can process it using HTTPResponse#read_body,
# if desired.
#
# Returns the response.
- #
+ #
# This method never raises Net::* exceptions.
- #
+ #
# # example
# response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...')
# p response.status
# puts response.body # body is already read
- #
+ #
# # using block
# http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response|
# p response.status
@@ -1006,7 +1006,7 @@ module Net #:nodoc:
# This method also sends DATA string if DATA is given.
#
# Returns a HTTPResponse object.
- #
+ #
# This method never raises Net::* exceptions.
#
# response = http.send_request('GET', '/index.html')
@@ -1020,14 +1020,14 @@ module Net #:nodoc:
# Sends an HTTPRequest object REQUEST to the HTTP server.
# This method also sends DATA string if REQUEST is a post/put request.
# Giving DATA for get/head request causes ArgumentError.
- #
+ #
# When called with a block, yields an HTTPResponse object.
# The body of this response will not have been read yet;
# the caller can process it using HTTPResponse#read_body,
# if desired.
#
# Returns a HTTPResponse object.
- #
+ #
# This method never raises Net::* exceptions.
#
def request(req, body = nil, &block) # :yield: +response+
@@ -1340,7 +1340,7 @@ module Net #:nodoc:
raise HTTPHeaderSyntaxError, 'wrong Content-Length format'
len.to_i
end
-
+
def content_length=(len)
unless len
@header.delete 'content-length'
@@ -1350,7 +1350,7 @@ module Net #:nodoc:
end
# Returns "true" if the "transfer-encoding" header is present and
- # set to "chunked". This is an HTTP/1.1 feature, allowing the
+ # set to "chunked". This is an HTTP/1.1 feature, allowing the
# the content to be sent in "chunks" without at the outset
# stating the entire content length.
def chunked?
@@ -1391,7 +1391,7 @@ module Net #:nodoc:
return nil unless @header['content-type']
self['Content-Type'].split(';').first.to_s.split('/')[0].to_s.strip
end
-
+
# Returns a content type string such as "html".
# This method returns nil if Content-Type: header field does not exist
# or sub-type is not given (e.g. "Content-Type: text").
@@ -1581,14 +1581,14 @@ module Net #:nodoc:
buf << "\r\n"
sock.write buf
end
-
+
end
- #
+ #
# HTTP request class. This class wraps request header and entity path.
# You *must* use its subclass, Net::HTTP::Get, Post, Head.
- #
+ #
class HTTPRequest < HTTPGenericRequest
# Creates HTTP request object.
@@ -1728,17 +1728,17 @@ module Net #:nodoc:
# HTTP response class. This class wraps response header and entity.
# Mixes in the HTTPHeader module, which provides access to response
# header values both via hash-like methods and individual readers.
- # Note that each possible HTTP response code defines its own
+ # Note that each possible HTTP response code defines its own
# HTTPResponse subclass. These are listed below.
# All classes are
# defined under the Net module. Indentation indicates inheritance.
- #
+ #
# xxx HTTPResponse
- #
+ #
# 1xx HTTPInformation
- # 100 HTTPContinue
+ # 100 HTTPContinue
# 101 HTTPSwitchProtocol
- #
+ #
# 2xx HTTPSuccess
# 200 HTTPOK
# 201 HTTPCreated
@@ -1747,7 +1747,7 @@ module Net #:nodoc:
# 204 HTTPNoContent
# 205 HTTPResetContent
# 206 HTTPPartialContent
- #
+ #
# 3xx HTTPRedirection
# 300 HTTPMultipleChoice
# 301 HTTPMovedPermanently
@@ -1756,7 +1756,7 @@ module Net #:nodoc:
# 304 HTTPNotModified
# 305 HTTPUseProxy
# 307 HTTPTemporaryRedirect
- #
+ #
# 4xx HTTPClientError
# 400 HTTPBadRequest
# 401 HTTPUnauthorized
@@ -1776,7 +1776,7 @@ module Net #:nodoc:
# 415 HTTPUnsupportedMediaType
# 416 HTTPRequestedRangeNotSatisfiable
# 417 HTTPExpectationFailed
- #
+ #
# 5xx HTTPServerError
# 500 HTTPInternalServerError
# 501 HTTPNotImplemented
@@ -1784,7 +1784,7 @@ module Net #:nodoc:
# 503 HTTPServiceUnavailable
# 504 HTTPGatewayTimeOut
# 505 HTTPVersionNotSupported
- #
+ #
# xxx HTTPUnknownResponse
#
class HTTPResponse
@@ -2057,7 +2057,7 @@ module Net #:nodoc:
# next is to fix bug in RDoc, where the private inside class << self
# spills out.
- public
+ public
include HTTPHeader
@@ -2090,7 +2090,7 @@ module Net #:nodoc:
# To allow Net::HTTP 1.1 style assignment
# e.g.
# response, body = Net::HTTP.get(....)
- #
+ #
def to_ary
warn "net/http.rb: warning: Net::HTTP v1.1 style assignment found at #{caller(1)[0]}; use `response = http.get(...)' instead." if $VERBOSE
res = self.dup
diff --git a/lib/net/https.rb b/lib/net/https.rb
index df72469e2f..00fe1bbbd9 100644
--- a/lib/net/https.rb
+++ b/lib/net/https.rb
@@ -17,7 +17,7 @@
== Version
$Id$
-
+
2001-11-06: Contiributed to Ruby/OpenSSL project.
2004-03-06: Some code is merged in to net/http.
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 79ed4b4981..663be7fc84 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -9,7 +9,7 @@
# Documentation: Shugo Maeda, with RDoc conversion and overview by William
# Webber.
#
-# See Net::IMAP for documentation.
+# See Net::IMAP for documentation.
#
@@ -44,12 +44,12 @@ module Net
# read-only access) #examine(). Once the client has successfully
# selected a mailbox, they enter _selected_ state, and that
# mailbox becomes the _current_ mailbox, on which mail-item
- # related commands implicitly operate.
+ # related commands implicitly operate.
#
# Messages have two sorts of identifiers: message sequence
- # numbers, and UIDs.
+ # numbers, and UIDs.
#
- # Message sequence numbers number messages within a mail box
+ # Message sequence numbers number messages within a mail box
# from 1 up to the number of items in the mail box. If new
# message arrives during a session, it receives a sequence
# number equal to the new size of the mail box. If messages
@@ -57,7 +57,7 @@ module Net
# sequence numbers "shuffled down" to fill the gaps.
#
# UIDs, on the other hand, are permanently guaranteed not to
- # identify another message within the same mailbox, even if
+ # identify another message within the same mailbox, even if
# the existing message is deleted. UIDs are required to
# be assigned in ascending (but not necessarily sequential)
# order within a mailbox; this means that if a non-IMAP client
@@ -90,11 +90,11 @@ module Net
# imap.store(message_id, "+FLAGS", [:Deleted])
# end
# imap.expunge
- #
+ #
# == Thread Safety
#
# Net::IMAP supports concurrent threads. For example,
- #
+ #
# imap = Net::IMAP.new("imap.foo.net", "imap2")
# imap.authenticate("cram-md5", "bar", "password")
# imap.select("inbox")
@@ -102,7 +102,7 @@ module Net
# search_result = imap.search(["BODY", "hello"])
# fetch_result = fetch_thread.value
# imap.disconnect
- #
+ #
# This script invokes the FETCH command and the SEARCH command concurrently.
#
# == Errors
@@ -112,9 +112,9 @@ module Net
#
# NO:: the attempted command could not be successfully completed. For
# instance, the username/password used for logging in are incorrect;
- # the selected mailbox does not exists; etc.
+ # the selected mailbox does not exists; etc.
#
- # BAD:: the request from the client does not follow the server's
+ # BAD:: the request from the client does not follow the server's
# understanding of the IMAP protocol. This includes attempting
# commands from the wrong client state; for instance, attempting
# to perform a SEARCH command without having SELECTed a current
@@ -146,8 +146,8 @@ module Net
#
# Finally, a Net::IMAP::DataFormatError is thrown if low-level data
# is found to be in an incorrect format (for instance, when converting
- # between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
- # thrown if a server response is non-parseable.
+ # between UTF-8 and UTF-16), and Net::IMAP::ResponseParseError is
+ # thrown if a server response is non-parseable.
#
#
# == References
@@ -283,7 +283,7 @@ module Net
# is the type of authentication this authenticator supports
# (for instance, "LOGIN"). The +authenticator+ is an object
# which defines a process() method to handle authentication with
- # the server. See Net::IMAP::LoginAuthenticator and
+ # the server. See Net::IMAP::LoginAuthenticator and
# Net::IMAP::CramMD5Authenticator for examples.
#
# If +auth_type+ refers to an existing authenticator, it will be
@@ -317,7 +317,7 @@ module Net
#
# Note that the Net::IMAP class does not modify its
# behaviour according to the capabilities of the server;
- # it is up to the user of the class to ensure that
+ # it is up to the user of the class to ensure that
# a certain capability is supported by a server before
# using it.
def capability
@@ -343,7 +343,7 @@ module Net
# the authentication mechanism to be used. Currently Net::IMAP
# supports authentication mechanisms:
#
- # LOGIN:: login using cleartext user and password.
+ # LOGIN:: login using cleartext user and password.
# CRAM-MD5:: login with cleartext user and encrypted password
# (see [RFC-2195] for a full description). This
# mechanism requires that the server have the user's
@@ -391,7 +391,7 @@ module Net
end
# Sends a SELECT command to select a +mailbox+ so that messages
- # in the +mailbox+ can be accessed.
+ # in the +mailbox+ can be accessed.
#
# After you have selected a mailbox, you may retrieve the
# number of items in that mailbox from @responses["EXISTS"][-1],
@@ -442,7 +442,7 @@ module Net
# Sends a RENAME command to change the name of the +mailbox+ to
# +newname+.
#
- # A Net::IMAP::NoResponseError is raised if a mailbox with the
+ # A Net::IMAP::NoResponseError is raised if a mailbox with the
# name +mailbox+ cannot be renamed to +newname+ for whatever
# reason; for instance, because +mailbox+ does not exist, or
# because there is already a mailbox with the name +newname+.
@@ -489,8 +489,8 @@ module Net
# imap.create("foo/bar")
# imap.create("foo/baz")
# p imap.list("", "foo/%")
- # #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
- # #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
+ # #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
+ # #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
# #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
def list(refname, mailbox)
synchronize do
@@ -543,7 +543,7 @@ module Net
# then that user will be stripped of any rights to that mailbox.
# The IMAP ACL commands are described in [RFC-2086].
def setacl(mailbox, user, rights)
- if rights.nil?
+ if rights.nil?
send_command("SETACL", mailbox, user, "")
else
send_command("SETACL", mailbox, user, rights)
@@ -562,7 +562,7 @@ module Net
# Sends a LSUB command, and returns a subset of names from the set
# of names that the user has declared as being "active" or
- # "subscribed". +refname+ and +mailbox+ are interpreted as
+ # "subscribed". +refname+ and +mailbox+ are interpreted as
# for #list().
# The return value is an array of +Net::IMAP::MailboxList+.
def lsub(refname, mailbox)
@@ -585,7 +585,7 @@ module Net
# p imap.status("inbox", ["MESSAGES", "RECENT"])
# #=> {"RECENT"=>0, "MESSAGES"=>44}
#
- # A Net::IMAP::NoResponseError is raised if status values
+ # A Net::IMAP::NoResponseError is raised if status values
# for +mailbox+ cannot be returned, for instance because it
# does not exist.
def status(mailbox, attr)
@@ -596,9 +596,9 @@ module Net
end
# Sends a APPEND command to append the +message+ to the end of
- # the +mailbox+. The optional +flags+ argument is an array of
+ # the +mailbox+. The optional +flags+ argument is an array of
# flags to initially passing to the new message. The optional
- # +date_time+ argument specifies the creation time to assign to the
+ # +date_time+ argument specifies the creation time to assign to the
# new message; it defaults to the current time.
# For example:
#
@@ -606,7 +606,7 @@ module Net
# Subject: hello
- #
+ #
# hello world
# EOF
#
@@ -625,7 +625,7 @@ module Net
# Sends a CHECK command to request a checkpoint of the currently
# selected mailbox. This performs implementation-specific
- # housekeeping, for instance, reconciling the mailbox's
+ # housekeeping, for instance, reconciling the mailbox's
# in-memory and on-disk state.
def check
send_command("CHECK")
@@ -649,8 +649,8 @@ module Net
# Sends a SEARCH command to search the mailbox for messages that
# match the given searching criteria, and returns message sequence
- # numbers. +keys+ can either be a string holding the entire
- # search string, or a single-dimension array of search keywords and
+ # numbers. +keys+ can either be a string holding the entire
+ # search string, or a single-dimension array of search keywords and
# arguments. The following are some common search criteria;
# see [IMAP] section 6.4.4 for a full list.
#
@@ -674,7 +674,7 @@ module Net
#
# OR <search-key> <search-key>:: "or" two search keys together.
#
- # ON <date>:: messages with an internal date exactly equal to <date>,
+ # ON <date>:: messages with an internal date exactly equal to <date>,
# which has a format similar to 8-Aug-2002.
#
# SINCE <date>:: messages with an internal date on or after <date>.
@@ -682,7 +682,7 @@ module Net
# SUBJECT <string>:: messages with <string> in their subject.
#
# TO <string>:: messages with <string> in their TO field.
- #
+ #
# For example:
#
# p imap.search(["SUBJECT", "hello", "NOT", "NEW"])
@@ -705,8 +705,8 @@ module Net
# The return value is an array of Net::IMAP::FetchData. For example:
#
# p imap.fetch(6..8, "UID")
- # #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\
- # #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, \\
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"UID"=>98}>, \\
+ # #<Net::IMAP::FetchData seqno=7, attr={"UID"=>99}>, \\
# #<Net::IMAP::FetchData seqno=8, attr={"UID"=>100}>]
# p imap.fetch(6, "BODY[HEADER.FIELDS (SUBJECT)]")
# #=> [#<Net::IMAP::FetchData seqno=6, attr={"BODY[HEADER.FIELDS (SUBJECT)]"=>"Subject: test\r\n\r\n"}>]
@@ -729,9 +729,9 @@ module Net
end
# Sends a STORE command to alter data associated with messages
- # in the mailbox, in particular their flags. The +set+ parameter
- # is a number or an array of numbers or a Range object. Each number
- # is a message sequence number. +attr+ is the name of a data item
+ # in the mailbox, in particular their flags. The +set+ parameter
+ # is a number or an array of numbers or a Range object. Each number
+ # is a message sequence number. +attr+ is the name of a data item
# to store: 'FLAGS' means to replace the message's flag list
# with the provided one; '+FLAGS' means to add the provided flags;
# and '-FLAGS' means to remove them. +flags+ is a list of flags.
@@ -739,8 +739,8 @@ module Net
# The return value is an array of Net::IMAP::FetchData. For example:
#
# p imap.store(6..8, "+FLAGS", [:Deleted])
- # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
- # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
+ # #=> [#<Net::IMAP::FetchData seqno=6, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
+ # #<Net::IMAP::FetchData seqno=7, attr={"FLAGS"=>[:Seen, :Deleted]}>, \\
# #<Net::IMAP::FetchData seqno=8, attr={"FLAGS"=>[:Seen, :Deleted]}>]
def store(set, attr, flags)
return store_internal("STORE", set, attr, flags)
@@ -782,9 +782,9 @@ module Net
return sort_internal("UID SORT", sort_keys, search_keys, charset)
end
- # Adds a response handler. For example, to detect when
+ # Adds a response handler. For example, to detect when
# the server sends us a new EXISTS response (which normally
- # indicates new messages being added to the mail box),
+ # indicates new messages being added to the mail box),
# you could add the following handler after selecting the
# mailbox.
#
@@ -820,7 +820,7 @@ module Net
return thread_internal("THREAD", algorithm, search_keys, charset)
end
- # As for #thread(), but returns unique identifiers instead of
+ # As for #thread(), but returns unique identifiers instead of
# message sequence numbers.
def uid_thread(algorithm, search_keys, charset)
return thread_internal("UID THREAD", algorithm, search_keys, charset)
@@ -871,7 +871,7 @@ module Net
@@max_flag_count = 10000
# Creates a new Net::IMAP object and connects it to the specified
- # +port+ (143 by default) on the named +host+. If +usessl+ is true,
+ # +port+ (143 by default) on the named +host+. If +usessl+ is true,
# then an attempt will
# be made to use SSL (now TLS) to connect to the server. For this
# to work OpenSSL [OSSL] and the Ruby OpenSSL [RSSL]
@@ -887,7 +887,7 @@ module Net
# being dropped by an intervening firewall).
# Errno::ENETUNREACH:: there is no route to that network.
# SocketError:: hostname not known or other socket error.
- # Net::IMAP::ByeResponseError:: we connected to the host, but they
+ # Net::IMAP::ByeResponseError:: we connected to the host, but they
# immediately said goodbye to us.
def initialize(host, port = PORT, usessl = false, certs = nil, verify = false)
super()
@@ -909,7 +909,7 @@ module Net
context.ca_path = certs if certs && FileTest::directory?(certs)
context.verify_mode = VERIFY_PEER if verify
if defined?(VerifyCallbackProc)
- context.verify_callback = VerifyCallbackProc
+ context.verify_callback = VerifyCallbackProc
end
@sock = SSLSocket.new(@sock, context)
@sock.connect # start ssl session.
@@ -1055,7 +1055,7 @@ module Net
@tagno += 1
return format("%s%04d", @tag_prefix, @tagno)
end
-
+
def put_string(str)
@sock.print(str)
if @@debug
@@ -1104,7 +1104,7 @@ module Net
put_string(str)
end
end
-
+
def send_quoted_string(str)
put_string('"' + str.gsub(/["\\]/n, "\\\\\\&") + '"')
end
@@ -1447,109 +1447,109 @@ module Net
end
# Net::IMAP::ContinuationRequest represents command continuation requests.
- #
+ #
# The command continuation request response is indicated by a "+" token
# instead of a tag. This form of response indicates that the server is
# ready to accept the continuation of a command from the client. The
# remainder of this response is a line of text.
- #
+ #
# continue_req ::= "+" SPACE (resp_text / base64)
- #
+ #
# ==== Fields:
- #
+ #
# data:: Returns the data (Net::IMAP::ResponseText).
- #
+ #
# raw_data:: Returns the raw data string.
ContinuationRequest = Struct.new(:data, :raw_data)
# Net::IMAP::UntaggedResponse represents untagged responses.
- #
+ #
# Data transmitted by the server to the client and status responses
# that do not indicate command completion are prefixed with the token
# "*", and are called untagged responses.
- #
+ #
# response_data ::= "*" SPACE (resp_cond_state / resp_cond_bye /
# mailbox_data / message_data / capability_data)
- #
+ #
# ==== Fields:
- #
+ #
# name:: Returns the name such as "FLAGS", "LIST", "FETCH"....
- #
+ #
# data:: Returns the data such as an array of flag symbols,
# a ((<Net::IMAP::MailboxList>)) object....
- #
+ #
# raw_data:: Returns the raw data string.
UntaggedResponse = Struct.new(:name, :data, :raw_data)
-
+
# Net::IMAP::TaggedResponse represents tagged responses.
- #
+ #
# The server completion result response indicates the success or
# failure of the operation. It is tagged with the same tag as the
# client command which began the operation.
- #
+ #
# response_tagged ::= tag SPACE resp_cond_state CRLF
- #
+ #
# tag ::= 1*<any ATOM_CHAR except "+">
- #
+ #
# resp_cond_state ::= ("OK" / "NO" / "BAD") SPACE resp_text
- #
+ #
# ==== Fields:
- #
+ #
# tag:: Returns the tag.
- #
+ #
# name:: Returns the name. the name is one of "OK", "NO", "BAD".
- #
+ #
# data:: Returns the data. See ((<Net::IMAP::ResponseText>)).
- #
+ #
# raw_data:: Returns the raw data string.
#
TaggedResponse = Struct.new(:tag, :name, :data, :raw_data)
-
+
# Net::IMAP::ResponseText represents texts of responses.
# The text may be prefixed by the response code.
- #
+ #
# resp_text ::= ["[" resp_text_code "]" SPACE] (text_mime2 / text)
# ;; text SHOULD NOT begin with "[" or "="
- #
+ #
# ==== Fields:
- #
+ #
# code:: Returns the response code. See ((<Net::IMAP::ResponseCode>)).
- #
+ #
# text:: Returns the text.
- #
+ #
ResponseText = Struct.new(:code, :text)
- #
+ #
# Net::IMAP::ResponseCode represents response codes.
- #
+ #
# resp_text_code ::= "ALERT" / "PARSE" /
# "PERMANENTFLAGS" SPACE "(" #(flag / "\*") ")" /
# "READ-ONLY" / "READ-WRITE" / "TRYCREATE" /
# "UIDVALIDITY" SPACE nz_number /
# "UNSEEN" SPACE nz_number /
# atom [SPACE 1*<any TEXT_CHAR except "]">]
- #
+ #
# ==== Fields:
- #
+ #
# name:: Returns the name such as "ALERT", "PERMANENTFLAGS", "UIDVALIDITY"....
- #
+ #
# data:: Returns the data if it exists.
#
ResponseCode = Struct.new(:name, :data)
# Net::IMAP::MailboxList represents contents of the LIST response.
- #
+ #
# mailbox_list ::= "(" #("\Marked" / "\Noinferiors" /
# "\Noselect" / "\Unmarked" / flag_extension) ")"
# SPACE (<"> QUOTED_CHAR <"> / nil) SPACE mailbox
- #
+ #
# ==== Fields:
- #
+ #
# attr:: Returns the name attributes. Each name attribute is a symbol
# capitalized by String#capitalize, such as :Noselect (not :NoSelect).
- #
+ #
# delim:: Returns the hierarchy delimiter
- #
+ #
# name:: Returns the mailbox name.
#
MailboxList = Struct.new(:attr, :delim, :name)
@@ -1558,78 +1558,78 @@ module Net
# This object can also be a response to GETQUOTAROOT. In the syntax
# specification below, the delimiter used with the "#" construct is a
# single space (SPACE).
- #
+ #
# quota_list ::= "(" #quota_resource ")"
- #
+ #
# quota_resource ::= atom SPACE number SPACE number
- #
+ #
# quota_response ::= "QUOTA" SPACE astring SPACE quota_list
- #
+ #
# ==== Fields:
- #
+ #
# mailbox:: The mailbox with the associated quota.
- #
+ #
# usage:: Current storage usage of mailbox.
- #
+ #
# quota:: Quota limit imposed on mailbox.
#
MailboxQuota = Struct.new(:mailbox, :usage, :quota)
# Net::IMAP::MailboxQuotaRoot represents part of the GETQUOTAROOT
# response. (GETQUOTAROOT can also return Net::IMAP::MailboxQuota.)
- #
+ #
# quotaroot_response ::= "QUOTAROOT" SPACE astring *(SPACE astring)
- #
+ #
# ==== Fields:
- #
+ #
# mailbox:: The mailbox with the associated quota.
- #
+ #
# quotaroots:: Zero or more quotaroots that effect the quota on the
# specified mailbox.
#
MailboxQuotaRoot = Struct.new(:mailbox, :quotaroots)
# Net::IMAP::MailboxACLItem represents response from GETACL.
- #
+ #
# acl_data ::= "ACL" SPACE mailbox *(SPACE identifier SPACE rights)
- #
+ #
# identifier ::= astring
- #
+ #
# rights ::= astring
- #
+ #
# ==== Fields:
- #
+ #
# user:: Login name that has certain rights to the mailbox
# that was specified with the getacl command.
- #
+ #
# rights:: The access rights the indicated user has to the
# mailbox.
#
MailboxACLItem = Struct.new(:user, :rights)
# Net::IMAP::StatusData represents contents of the STATUS response.
- #
+ #
# ==== Fields:
- #
+ #
# mailbox:: Returns the mailbox name.
- #
+ #
# attr:: Returns a hash. Each key is one of "MESSAGES", "RECENT", "UIDNEXT",
# "UIDVALIDITY", "UNSEEN". Each value is a number.
- #
+ #
StatusData = Struct.new(:mailbox, :attr)
# Net::IMAP::FetchData represents contents of the FETCH response.
- #
+ #
# ==== Fields:
- #
+ #
# seqno:: Returns the message sequence number.
# (Note: not the unique identifier, even for the UID command response.)
- #
+ #
# attr:: Returns a hash. Each key is a data item name, and each value is
# its value.
- #
+ #
# The current data items are:
- #
+ #
# [BODY]
# A form of BODYSTRUCTURE without extension data.
# [BODY[<section>]<<origin_octet>>]
@@ -1656,67 +1656,67 @@ module Net
# Equivalent to BODY[TEXT].
# [UID]
# A number expressing the unique identifier of the message.
- #
+ #
FetchData = Struct.new(:seqno, :attr)
# Net::IMAP::Envelope represents envelope structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# date:: Returns a string that represents the date.
- #
+ #
# subject:: Returns a string that represents the subject.
- #
+ #
# from:: Returns an array of Net::IMAP::Address that represents the from.
- #
+ #
# sender:: Returns an array of Net::IMAP::Address that represents the sender.
- #
+ #
# reply_to:: Returns an array of Net::IMAP::Address that represents the reply-to.
- #
+ #
# to:: Returns an array of Net::IMAP::Address that represents the to.
- #
+ #
# cc:: Returns an array of Net::IMAP::Address that represents the cc.
- #
+ #
# bcc:: Returns an array of Net::IMAP::Address that represents the bcc.
- #
+ #
# in_reply_to:: Returns a string that represents the in-reply-to.
- #
+ #
# message_id:: Returns a string that represents the message-id.
- #
+ #
Envelope = Struct.new(:date, :subject, :from, :sender, :reply_to,
:to, :cc, :bcc, :in_reply_to, :message_id)
- #
+ #
# Net::IMAP::Address represents electronic mail addresses.
- #
+ #
# ==== Fields:
- #
+ #
# name:: Returns the phrase from [RFC-822] mailbox.
- #
+ #
# route:: Returns the route from [RFC-822] route-addr.
- #
+ #
# mailbox:: nil indicates end of [RFC-822] group.
# If non-nil and host is nil, returns [RFC-822] group name.
# Otherwise, returns [RFC-822] local-part
- #
+ #
# host:: nil indicates [RFC-822] group syntax.
# Otherwise, returns [RFC-822] domain name.
#
Address = Struct.new(:name, :route, :mailbox, :host)
- #
+ #
# Net::IMAP::ContentDisposition represents Content-Disposition fields.
- #
+ #
# ==== Fields:
- #
+ #
# dsp_type:: Returns the disposition type.
- #
+ #
# param:: Returns a hash that represents parameters of the Content-Disposition
# field.
- #
+ #
ContentDisposition = Struct.new(:dsp_type, :param)
- # Net::IMAP::ThreadMember represents a thread-node returned
+ # Net::IMAP::ThreadMember represents a thread-node returned
# by Net::IMAP#thread
#
# ==== Fields:
@@ -1729,37 +1729,37 @@ module Net
ThreadMember = Struct.new(:seqno, :children)
# Net::IMAP::BodyTypeBasic represents basic body structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# media_type:: Returns the content media type name as defined in [MIME-IMB].
- #
+ #
# subtype:: Returns the content subtype name as defined in [MIME-IMB].
- #
+ #
# param:: Returns a hash that represents parameters as defined in [MIME-IMB].
- #
+ #
# content_id:: Returns a string giving the content id as defined in [MIME-IMB].
- #
+ #
# description:: Returns a string giving the content description as defined in
# [MIME-IMB].
- #
+ #
# encoding:: Returns a string giving the content transfer encoding as defined in
# [MIME-IMB].
- #
+ #
# size:: Returns a number giving the size of the body in octets.
- #
+ #
# md5:: Returns a string giving the body MD5 value as defined in [MD5].
- #
+ #
# disposition:: Returns a Net::IMAP::ContentDisposition object giving
# the content disposition.
- #
+ #
# language:: Returns a string or an array of strings giving the body
# language value as defined in [LANGUAGE-TAGS].
- #
+ #
# extension:: Returns extension data.
- #
+ #
# multipart?:: Returns false.
- #
+ #
class BodyTypeBasic < Struct.new(:media_type, :subtype,
:param, :content_id,
:description, :encoding, :size,
@@ -1770,7 +1770,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -1780,13 +1780,13 @@ module Net
end
# Net::IMAP::BodyTypeText represents TEXT body structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# lines:: Returns the size of the body in text lines.
- #
+ #
# And Net::IMAP::BodyTypeText has all fields of Net::IMAP::BodyTypeBasic.
- #
+ #
class BodyTypeText < Struct.new(:media_type, :subtype,
:param, :content_id,
:description, :encoding, :size,
@@ -1798,7 +1798,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -1808,13 +1808,13 @@ module Net
end
# Net::IMAP::BodyTypeMessage represents MESSAGE/RFC822 body structures of messages.
- #
+ #
# ==== Fields:
- #
+ #
# envelope:: Returns a Net::IMAP::Envelope giving the envelope structure.
- #
+ #
# body:: Returns an object giving the body structure.
- #
+ #
# And Net::IMAP::BodyTypeMessage has all methods of Net::IMAP::BodyTypeText.
#
class BodyTypeMessage < Struct.new(:media_type, :subtype,
@@ -1828,7 +1828,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -1837,29 +1837,29 @@ module Net
end
end
- # Net::IMAP::BodyTypeMultipart represents multipart body structures
+ # Net::IMAP::BodyTypeMultipart represents multipart body structures
# of messages.
- #
+ #
# ==== Fields:
- #
+ #
# media_type:: Returns the content media type name as defined in [MIME-IMB].
- #
+ #
# subtype:: Returns the content subtype name as defined in [MIME-IMB].
- #
+ #
# parts:: Returns multiple parts.
- #
+ #
# param:: Returns a hash that represents parameters as defined in [MIME-IMB].
- #
+ #
# disposition:: Returns a Net::IMAP::ContentDisposition object giving
# the content disposition.
- #
+ #
# language:: Returns a string or an array of strings giving the body
# language value as defined in [LANGUAGE-TAGS].
- #
+ #
# extension:: Returns extension data.
- #
+ #
# multipart?:: Returns true.
- #
+ #
class BodyTypeMultipart < Struct.new(:media_type, :subtype,
:parts,
:param, :disposition, :language,
@@ -1869,7 +1869,7 @@ module Net
end
# Obsolete: use +subtype+ instead. Calling this will
- # generate a warning message to +stderr+, then return
+ # generate a warning message to +stderr+, then return
# the value of +subtype+.
def media_subtype
$stderr.printf("warning: media_subtype is obsolete.\n")
@@ -2678,35 +2678,35 @@ module Net
def thread_branch(token)
rootmember = nil
lastmember = nil
-
+
while true
shift_token # ignore first T_LPAR
token = lookahead
-
+
case token.symbol
when T_NUMBER
# new member
newmember = ThreadMember.new(number, [])
if rootmember.nil?
rootmember = newmember
- else
+ else
lastmember.children << newmember
- end
+ end
lastmember = newmember
- when T_SPACE
- # do nothing
+ when T_SPACE
+ # do nothing
when T_LPAR
if rootmember.nil?
# dummy member
lastmember = rootmember = ThreadMember.new(nil, [])
- end
-
+ end
+
lastmember.children << thread_branch(token)
when T_RPAR
- break
- end
+ break
+ end
end
-
+
return rootmember
end
@@ -3246,7 +3246,7 @@ module Net
class BadResponseError < ResponseError
end
- # Error raised upon a "BYE" response from the server, indicating
+ # Error raised upon a "BYE" response from the server, indicating
# that the client is not being allowed to login, or has been timed
# out due to inactivity.
class ByeResponseError < ResponseError
@@ -3336,7 +3336,7 @@ EOF
exit(1)
end
$port ||= $ssl ? 993 : 143
-
+
imap = Net::IMAP.new($host, $port, $ssl)
begin
password = get_password
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 4374550ae9..574ed4520f 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -3,20 +3,20 @@
# Copyright (c) 1999-2007 Yukihiro Matsumoto.
#
# Copyright (c) 1999-2007 Minero Aoki.
-#
+#
# Written & maintained by Minero Aoki <[email protected]>.
#
# Documented by William Webber and Minero Aoki.
-#
+#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms as Ruby itself,
# Ruby Distribute License.
-#
+#
# NOTE: You can find Japanese version of this document at:
# http://www.ruby-lang.org/ja/man/html/net_pop.html
-#
+#
# $Id$
-#
+#
# See Net::POP3 for documentation.
#
@@ -45,25 +45,25 @@ module Net
# = Net::POP3
#
# == What is This Library?
- #
- # This library provides functionality for retrieving
+ #
+ # This library provides functionality for retrieving
# email via POP3, the Post Office Protocol version 3. For details
# of POP3, see [RFC1939] (http://www.ietf.org/rfc/rfc1939.txt).
- #
+ #
# == Examples
- #
- # === Retrieving Messages
- #
- # This example retrieves messages from the server and deletes them
+ #
+ # === Retrieving Messages
+ #
+ # This example retrieves messages from the server and deletes them
# on the server.
#
# Messages are written to files named 'inbox/1', 'inbox/2', ....
# Replace 'pop.example.com' with your POP3 server address, and
# 'YourAccount' and 'YourPassword' with the appropriate account
# details.
- #
+ #
# require 'net/pop'
- #
+ #
# pop = Net::POP3.new('pop.example.com')
# pop.start('YourAccount', 'YourPassword') # (1)
# if pop.mails.empty?
@@ -80,19 +80,19 @@ module Net
# puts "#{pop.mails.size} mails popped."
# end
# pop.finish # (3)
- #
+ #
# 1. Call Net::POP3#start and start POP session.
# 2. Access messages by using POP3#each_mail and/or POP3#mails.
# 3. Close POP session by calling POP3#finish or use the block form of #start.
- #
+ #
# === Shortened Code
- #
+ #
# The example above is very verbose. You can shorten the code by using
# some utility methods. First, the block form of Net::POP3.start can
# be used instead of POP3.new, POP3#start and POP3#finish.
- #
+ #
# require 'net/pop'
- #
+ #
# Net::POP3.start('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |pop|
# if pop.mails.empty?
@@ -109,11 +109,11 @@ module Net
# puts "#{pop.mails.size} mails popped."
# end
# end
- #
+ #
# POP3#delete_all is an alternative for #each_mail and #delete.
- #
+ #
# require 'net/pop'
- #
+ #
# Net::POP3.start('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |pop|
# if pop.mails.empty?
@@ -128,11 +128,11 @@ module Net
# end
# end
# end
- #
+ #
# And here is an even shorter example.
- #
+ #
# require 'net/pop'
- #
+ #
# i = 0
# Net::POP3.delete_all('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |m|
@@ -141,14 +141,14 @@ module Net
# end
# i += 1
# end
- #
+ #
# === Memory Space Issues
- #
+ #
# All the examples above get each message as one big string.
# This example avoids this.
- #
+ #
# require 'net/pop'
- #
+ #
# i = 1
# Net::POP3.delete_all('pop.example.com', 110,
# 'YourAccount', 'YourPassword') do |m|
@@ -159,41 +159,41 @@ module Net
# i += 1
# end
# end
- #
+ #
# === Using APOP
- #
+ #
# The net/pop library supports APOP authentication.
# To use APOP, use the Net::APOP class instead of the Net::POP3 class.
# You can use the utility method, Net::POP3.APOP(). For example:
- #
+ #
# require 'net/pop'
- #
+ #
# # Use APOP authentication if $isapop == true
# pop = Net::POP3.APOP($is_apop).new('apop.example.com', 110)
# pop.start(YourAccount', 'YourPassword') do |pop|
# # Rest of the code is the same.
# end
- #
+ #
# === Fetch Only Selected Mail Using 'UIDL' POP Command
- #
+ #
# If your POP server provides UIDL functionality,
# you can grab only selected mails from the POP server.
# e.g.
- #
+ #
# def need_pop?( id )
# # determine if we need pop this mail...
# end
- #
+ #
# Net::POP3.start('pop.example.com', 110,
# 'Your account', 'Your password') do |pop|
# pop.mails.select { |m| need_pop?(m.unique_id) }.each do |m|
# do_something(m.pop)
# end
# end
- #
+ #
# The POPMail#unique_id() method returns the unique-id of the message as a
# String. Normally the unique-id is a hash of the message.
- #
+ #
class POP3 < Protocol
Revision = %q$Revision$.split[1]
@@ -210,7 +210,7 @@ module Net
def POP3.default_pop3_port
110
end
-
+
# The default port for POP3S connections, port 995
def POP3.default_pop3s_port
995
@@ -375,7 +375,7 @@ module Net
# Session management
#
- # Creates a new POP3 object and open the connection. Equivalent to
+ # Creates a new POP3 object and open the connection. Equivalent to
#
# Net::POP3.new(address, port, isapop).start(account, password)
#
@@ -396,7 +396,7 @@ module Net
isapop = false, &block) # :yield: pop
new(address, port, isapop).start(account, password, &block)
end
-
+
# Creates a new POP3 object.
#
# +address+ is the hostname or ip address of your POP3 server.
@@ -412,7 +412,7 @@ module Net
@ssl_params = POP3.ssl_params
@port = port
@apop = isapop
-
+
@command = nil
@socket = nil
@started = false
@@ -434,7 +434,7 @@ module Net
def use_ssl?
return !@ssl_params.nil?
end
-
+
# call-seq:
# Net::POP#enable_ssl(params = {})
#
@@ -451,7 +451,7 @@ module Net
@port = port || @port
end
end
-
+
def disable_ssl
@ssl_params = nil
end
@@ -635,7 +635,7 @@ module Net
# Yields each message to the passed-in block in turn.
# Equivalent to:
- #
+ #
# pop3.mails.each do |popmail|
# ....
# end
@@ -742,7 +742,7 @@ module Net
#
# This method fetches the message. If called with a block, the
# message is yielded to the block one chunk at a time. If called
- # without a block, the message is returned as a String. The optional
+ # without a block, the message is returned as a String. The optional
# +dest+ argument will be prepended to the returned String; this
# argument is essentially obsolete.
#
@@ -753,7 +753,7 @@ module Net
# n = 1
# pop.mails.each do |popmail|
# File.open("inbox/#{n}", 'w') do |f|
- # f.write popmail.pop
+ # f.write popmail.pop
# end
# popmail.delete
# n += 1
@@ -792,7 +792,7 @@ module Net
alias all pop #:nodoc: obsolete
alias mail pop #:nodoc: obsolete
- # Fetches the message header and +lines+ lines of body.
+ # Fetches the message header and +lines+ lines of body.
#
# The optional +dest+ argument is obsolete.
#
@@ -804,7 +804,7 @@ module Net
dest
end
- # Fetches the message header.
+ # Fetches the message header.
#
# The optional +dest+ argument is obsolete.
#
@@ -931,7 +931,7 @@ module Net
@socket.each_message_chunk(&block)
}
end
-
+
def dele(num)
check_response(critical { get_response('DELE %d', num) })
end
diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb
index dc23c14dfa..e1af0b8e0b 100644
--- a/lib/net/protocol.rb
+++ b/lib/net/protocol.rb
@@ -121,7 +121,7 @@ module Net # :nodoc:
return rbuf_consume(@rbuf.size)
end
end
-
+
def readline
readuntil("\n").chop
end
@@ -232,7 +232,7 @@ module Net # :nodoc:
LOG_on()
LOG "read message (#{read_bytes} bytes)"
end
-
+
# *library private* (cannot handle 'break')
def each_list_item
while (str = readuntil("\r\n")) != ".\r\n"
diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb
index e6a4a8699d..2c0d48d982 100644
--- a/lib/net/smtp.rb
+++ b/lib/net/smtp.rb
@@ -1,23 +1,23 @@
# = net/smtp.rb
-#
+#
# Copyright (c) 1999-2007 Yukihiro Matsumoto.
#
# Copyright (c) 1999-2007 Minero Aoki.
-#
+#
# Written & maintained by Minero Aoki <[email protected]>.
#
# Documented by William Webber and Minero Aoki.
-#
+#
# This program is free software. You can re-distribute and/or
# modify this program under the same terms as Ruby itself.
-#
+#
# NOTE: You can find Japanese version of this document at:
# http://www.ruby-lang.org/ja/man/html/net_smtp.html
-#
+#
# $Id$
#
-# See Net::SMTP for documentation.
-#
+# See Net::SMTP for documentation.
+#
require 'net/protocol'
require 'digest/md5'
@@ -69,103 +69,103 @@ module Net
# = Net::SMTP
#
# == What is This Library?
- #
+ #
# This library provides functionality to send internet
# mail via SMTP, the Simple Mail Transfer Protocol. For details of
# SMTP itself, see [RFC2821] (http://www.ietf.org/rfc/rfc2821.txt).
- #
+ #
# == What is This Library NOT?
- #
+ #
# This library does NOT provide functions to compose internet mails.
# You must create them by yourself. If you want better mail support,
# try RubyMail or TMail. You can get both libraries from RAA.
# (http://www.ruby-lang.org/en/raa.html)
- #
+ #
# FYI: the official documentation on internet mail is: [RFC2822] (http://www.ietf.org/rfc/rfc2822.txt).
- #
+ #
# == Examples
- #
+ #
# === Sending Messages
- #
+ #
# You must open a connection to an SMTP server before sending messages.
- # The first argument is the address of your SMTP server, and the second
- # argument is the port number. Using SMTP.start with a block is the simplest
- # way to do this. This way, the SMTP connection is closed automatically
+ # The first argument is the address of your SMTP server, and the second
+ # argument is the port number. Using SMTP.start with a block is the simplest
+ # way to do this. This way, the SMTP connection is closed automatically
# after the block is executed.
- #
+ #
# require 'net/smtp'
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
# # Use the SMTP object smtp only in this block.
# end
- #
+ #
# Replace 'your.smtp.server' with your SMTP server. Normally
# your system manager or internet provider supplies a server
# for you.
- #
+ #
# Then you can send messages.
- #
+ #
# msgstr = <<END_OF_MESSAGE
# From: Your Name <[email protected]>
# To: Destination Address <[email protected]>
# Subject: test message
# Date: Sat, 23 Jun 2001 16:26:43 +0900
# Message-Id: <[email protected]>
- #
+ #
# This is a test message.
# END_OF_MESSAGE
- #
+ #
# require 'net/smtp'
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
# smtp.send_message msgstr,
# end
- #
+ #
# === Closing the Session
- #
- # You MUST close the SMTP session after sending messages, by calling
+ #
+ # You MUST close the SMTP session after sending messages, by calling
# the #finish method:
- #
+ #
# # using SMTP#finish
# smtp = Net::SMTP.start('your.smtp.server', 25)
# smtp.send_message msgstr, 'from@address', 'to@address'
# smtp.finish
- #
+ #
# You can also use the block form of SMTP.start/SMTP#start. This closes
# the SMTP session automatically:
- #
+ #
# # using block form of SMTP.start
# Net::SMTP.start('your.smtp.server', 25) do |smtp|
# smtp.send_message msgstr, 'from@address', 'to@address'
# end
- #
+ #
# I strongly recommend this scheme. This form is simpler and more robust.
- #
+ #
# === HELO domain
- #
+ #
# In almost all situations, you must provide a third argument
# to SMTP.start/SMTP#start. This is the domain name which you are on
# (the host to send mail from). It is called the "HELO domain".
# The SMTP server will judge whether it should send or reject
# the SMTP session by inspecting the HELO domain.
- #
+ #
# Net::SMTP.start('your.smtp.server', 25,
# 'mail.from.domain') { |smtp| ... }
- #
+ #
# === SMTP Authentication
- #
+ #
# The Net::SMTP class supports three authentication schemes;
# PLAIN, LOGIN and CRAM MD5. (SMTP Authentication: [RFC2554])
- # To use SMTP authentication, pass extra arguments to
+ # To use SMTP authentication, pass extra arguments to
# SMTP.start/SMTP#start.
- #
+ #
# # PLAIN
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
# 'Your Account', 'Your Password', :plain)
# # LOGIN
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
# 'Your Account', 'Your Password', :login)
- #
+ #
# # CRAM MD5
# Net::SMTP.start('your.smtp.server', 25, 'mail.from.domain',
# 'Your Account', 'Your Password', :cram_md5)
@@ -196,7 +196,7 @@ module Net
def SMTP.default_ssl_context
OpenSSL::SSL::SSLContext.new
end
-
+
#
# Creates a new Net::SMTP object.
#
@@ -223,7 +223,7 @@ module Net
@starttls = false
@ssl_context = nil
end
-
+
# Provide human-readable stringification of class state.
def inspect
"#<#{self.class} #{@address}:#{@port} started=#{@started}>"
@@ -235,7 +235,7 @@ module Net
end
#
- # Set whether to use ESMTP or not. This should be done before
+ # Set whether to use ESMTP or not. This should be done before
# calling #start. Note that if #start is called in ESMTP mode,
# and the connection fails due to a ProtocolError, the SMTP
# object will automatically switch to plain SMTP mode and
@@ -310,7 +310,7 @@ module Net
end
alias enable_ssl enable_tls
-
+
# Disables SMTP/TLS for this object. Must be called before the
# connection is established to have any effect.
def disable_tls
@@ -336,7 +336,7 @@ module Net
def starttls_auto?
@starttls == :auto
end
-
+
# Enables SMTP/TLS (STARTTLS) for this object.
# +context+ is a OpenSSL::SSL::SSLContext object.
def enable_starttls(context = SMTP.default_ssl_context)
@@ -413,7 +413,7 @@ module Net
# Creates a new Net::SMTP object and connects to the server.
#
# This method is equivalent to:
- #
+ #
# Net::SMTP.new(address, port).start(helo_domain, account, password, authtype)
#
# === Example
@@ -437,7 +437,7 @@ module Net
# +port+ is the port to connect to; it defaults to port 25.
#
# +helo+ is the _HELO_ _domain_ provided by the client to the
- # server (see overview comments); it defaults to 'localhost'.
+ # server (see overview comments); it defaults to 'localhost'.
#
# The remaining arguments are used for SMTP authentication, if required
# or desired. +user+ is the account name; +secret+ is your password
@@ -476,33 +476,33 @@ module Net
# +helo+ is the _HELO_ _domain_ that you'll dispatch mails from; see
# the discussion in the overview notes.
#
- # If both of +user+ and +secret+ are given, SMTP authentication
- # will be attempted using the AUTH command. +authtype+ specifies
+ # If both of +user+ and +secret+ are given, SMTP authentication
+ # will be attempted using the AUTH command. +authtype+ specifies
# the type of authentication to attempt; it must be one of
# :login, :plain, and :cram_md5. See the notes on SMTP Authentication
- # in the overview.
+ # in the overview.
#
# === Block Usage
#
# When this methods is called with a block, the newly-started SMTP
# object is yielded to the block, and automatically closed after
- # the block call finishes. Otherwise, it is the caller's
+ # the block call finishes. Otherwise, it is the caller's
# responsibility to close the session when finished.
#
# === Example
#
# This is very similar to the class method SMTP.start.
#
- # require 'net/smtp'
+ # require 'net/smtp'
# smtp = Net::SMTP.new('smtp.mail.server', 25)
# smtp.start(helo_domain, account, password, authtype) do |smtp|
# smtp.send_message msgstr, '[email protected]', ['[email protected]']
- # end
+ # end
#
# The primary use of this method (as opposed to SMTP.start)
# is probably to set debugging (#set_debug_output) or ESMTP
# (#esmtp=), which must be done before the session is
- # started.
+ # started.
#
# === Errors
#
@@ -548,7 +548,7 @@ module Net
check_auth_method(authtype || DEFAULT_AUTH_TYPE)
check_auth_args user, secret
end
- s = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
+ s = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
logging "Connection opened: #{@address}:#{@port}"
@socket = new_internet_message_io(tls? ? tlsconnect(s) : s)
check_response critical { recv_response() }
@@ -621,7 +621,7 @@ module Net
#
# Sends +msgstr+ as a message. Single CR ("\r") and LF ("\n") found
# in the +msgstr+, are converted into the CR LF pair. You cannot send a
- # binary message with this method. +msgstr+ should include both
+ # binary message with this method. +msgstr+ should include both
# the message headers and body.
#
# +from_addr+ is a String representing the source mail address.
@@ -852,7 +852,7 @@ module Net
# Subject: I found a bug
- #
+ #
# Check vm.c:58879.
# EndMessage
#
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index 91628a8e84..a61579c6ef 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -1,7 +1,7 @@
# = net/telnet.rb - Simple Telnet Client Library
-#
+#
# Author:: Wakou Aoyama <[email protected]>
-# Documentation:: William Webber and Wakou Aoyama
+# Documentation:: William Webber and Wakou Aoyama
#
# This file holds the class Net::Telnet, which provides client-side
# telnet functionality.
@@ -13,7 +13,7 @@ require "socket"
require "delegate"
require "timeout"
require "English"
-
+
module Net
#
@@ -50,11 +50,11 @@ module Net
# have to handle authentication yourself.
#
# For some protocols, it will be possible to specify the +Prompt+
- # option once when you create the Telnet object and use #cmd() calls;
+ # option once when you create the Telnet object and use #cmd() calls;
# for others, you will have to specify the response sequence to
# look for as the Match option to every #cmd() call, or call
- # #puts() and #waitfor() directly; for yet others, you will have
- # to use #sysread() instead of #waitfor() and parse server
+ # #puts() and #waitfor() directly; for yet others, you will have
+ # to use #sysread() instead of #waitfor() and parse server
# responses yourself.
#
# It is worth noting that when you create a new Net::Telnet object,
@@ -63,21 +63,21 @@ module Net
# to already open sockets, or to any read-write IO object. This
# can be useful, for instance, for setting up a test fixture for
# unit testing.
- #
+ #
# == Examples
- #
+ #
# === Log in and send a command, echoing all output to stdout
- #
+ #
# localhost = Net::Telnet::new("Host" => "localhost",
# "Timeout" => 10,
# "Prompt" => /[$%#>] \z/n)
# localhost.login("username", "password") { |c| print c }
# localhost.cmd("command") { |c| print c }
# localhost.close
- #
- #
+ #
+ #
# === Check a POP server to see if you have mail
- #
+ #
# pop = Net::Telnet::new("Host" => "your_destination_host_here",
# "Port" => 110,
# "Telnetmode" => false,
@@ -97,73 +97,73 @@ module Net
# :stopdoc:
IAC = 255.chr # "\377" # "\xff" # interpret as command
- DONT = 254.chr # "\376" # "\xfe" # you are not to use option
- DO = 253.chr # "\375" # "\xfd" # please, you use option
- WONT = 252.chr # "\374" # "\xfc" # I won't use option
- WILL = 251.chr # "\373" # "\xfb" # I will use option
- SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
- GA = 249.chr # "\371" # "\xf9" # you may reverse the line
- EL = 248.chr # "\370" # "\xf8" # erase the current line
- EC = 247.chr # "\367" # "\xf7" # erase the current character
- AYT = 246.chr # "\366" # "\xf6" # are you there
- AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
- IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
- BREAK = 243.chr # "\363" # "\xf3" # break
- DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
- NOP = 241.chr # "\361" # "\xf1" # nop
- SE = 240.chr # "\360" # "\xf0" # end sub negotiation
- EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
- ABORT = 238.chr # "\356" # "\xee" # Abort process
- SUSP = 237.chr # "\355" # "\xed" # Suspend process
- EOF = 236.chr # "\354" # "\xec" # End of file
- SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
-
- OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
- OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
- OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
- OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
- OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
- OPT_STATUS = 5.chr # "\005" # "\x05" # Status
- OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
- OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
- OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
- OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
- OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
- OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
- OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
- OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
- OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
- OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
- OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
- OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
- OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
- OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
- OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
- OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
- OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
- OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
- OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
- OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
- OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
- OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
- OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
- OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
- OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
- OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
- OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
- OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
- OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
- OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
- OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
- OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
- OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
- OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
- OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
-
- NULL = "\000"
- CR = "\015"
- LF = "\012"
- EOL = CR + LF
+ DONT = 254.chr # "\376" # "\xfe" # you are not to use option
+ DO = 253.chr # "\375" # "\xfd" # please, you use option
+ WONT = 252.chr # "\374" # "\xfc" # I won't use option
+ WILL = 251.chr # "\373" # "\xfb" # I will use option
+ SB = 250.chr # "\372" # "\xfa" # interpret as subnegotiation
+ GA = 249.chr # "\371" # "\xf9" # you may reverse the line
+ EL = 248.chr # "\370" # "\xf8" # erase the current line
+ EC = 247.chr # "\367" # "\xf7" # erase the current character
+ AYT = 246.chr # "\366" # "\xf6" # are you there
+ AO = 245.chr # "\365" # "\xf5" # abort output--but let prog finish
+ IP = 244.chr # "\364" # "\xf4" # interrupt process--permanently
+ BREAK = 243.chr # "\363" # "\xf3" # break
+ DM = 242.chr # "\362" # "\xf2" # data mark--for connect. cleaning
+ NOP = 241.chr # "\361" # "\xf1" # nop
+ SE = 240.chr # "\360" # "\xf0" # end sub negotiation
+ EOR = 239.chr # "\357" # "\xef" # end of record (transparent mode)
+ ABORT = 238.chr # "\356" # "\xee" # Abort process
+ SUSP = 237.chr # "\355" # "\xed" # Suspend process
+ EOF = 236.chr # "\354" # "\xec" # End of file
+ SYNCH = 242.chr # "\362" # "\xf2" # for telfunc calls
+
+ OPT_BINARY = 0.chr # "\000" # "\x00" # Binary Transmission
+ OPT_ECHO = 1.chr # "\001" # "\x01" # Echo
+ OPT_RCP = 2.chr # "\002" # "\x02" # Reconnection
+ OPT_SGA = 3.chr # "\003" # "\x03" # Suppress Go Ahead
+ OPT_NAMS = 4.chr # "\004" # "\x04" # Approx Message Size Negotiation
+ OPT_STATUS = 5.chr # "\005" # "\x05" # Status
+ OPT_TM = 6.chr # "\006" # "\x06" # Timing Mark
+ OPT_RCTE = 7.chr # "\a" # "\x07" # Remote Controlled Trans and Echo
+ OPT_NAOL = 8.chr # "\010" # "\x08" # Output Line Width
+ OPT_NAOP = 9.chr # "\t" # "\x09" # Output Page Size
+ OPT_NAOCRD = 10.chr # "\n" # "\x0a" # Output Carriage-Return Disposition
+ OPT_NAOHTS = 11.chr # "\v" # "\x0b" # Output Horizontal Tab Stops
+ OPT_NAOHTD = 12.chr # "\f" # "\x0c" # Output Horizontal Tab Disposition
+ OPT_NAOFFD = 13.chr # "\r" # "\x0d" # Output Formfeed Disposition
+ OPT_NAOVTS = 14.chr # "\016" # "\x0e" # Output Vertical Tabstops
+ OPT_NAOVTD = 15.chr # "\017" # "\x0f" # Output Vertical Tab Disposition
+ OPT_NAOLFD = 16.chr # "\020" # "\x10" # Output Linefeed Disposition
+ OPT_XASCII = 17.chr # "\021" # "\x11" # Extended ASCII
+ OPT_LOGOUT = 18.chr # "\022" # "\x12" # Logout
+ OPT_BM = 19.chr # "\023" # "\x13" # Byte Macro
+ OPT_DET = 20.chr # "\024" # "\x14" # Data Entry Terminal
+ OPT_SUPDUP = 21.chr # "\025" # "\x15" # SUPDUP
+ OPT_SUPDUPOUTPUT = 22.chr # "\026" # "\x16" # SUPDUP Output
+ OPT_SNDLOC = 23.chr # "\027" # "\x17" # Send Location
+ OPT_TTYPE = 24.chr # "\030" # "\x18" # Terminal Type
+ OPT_EOR = 25.chr # "\031" # "\x19" # End of Record
+ OPT_TUID = 26.chr # "\032" # "\x1a" # TACACS User Identification
+ OPT_OUTMRK = 27.chr # "\e" # "\x1b" # Output Marking
+ OPT_TTYLOC = 28.chr # "\034" # "\x1c" # Terminal Location Number
+ OPT_3270REGIME = 29.chr # "\035" # "\x1d" # Telnet 3270 Regime
+ OPT_X3PAD = 30.chr # "\036" # "\x1e" # X.3 PAD
+ OPT_NAWS = 31.chr # "\037" # "\x1f" # Negotiate About Window Size
+ OPT_TSPEED = 32.chr # " " # "\x20" # Terminal Speed
+ OPT_LFLOW = 33.chr # "!" # "\x21" # Remote Flow Control
+ OPT_LINEMODE = 34.chr # "\"" # "\x22" # Linemode
+ OPT_XDISPLOC = 35.chr # "#" # "\x23" # X Display Location
+ OPT_OLD_ENVIRON = 36.chr # "$" # "\x24" # Environment Option
+ OPT_AUTHENTICATION = 37.chr # "%" # "\x25" # Authentication Option
+ OPT_ENCRYPT = 38.chr # "&" # "\x26" # Encryption Option
+ OPT_NEW_ENVIRON = 39.chr # "'" # "\x27" # New Environment Option
+ OPT_EXOPL = 255.chr # "\377" # "\xff" # Extended-Options-List
+
+ NULL = "\000"
+ CR = "\015"
+ LF = "\012"
+ EOL = CR + LF
REVISION = '$Id$'
# :startdoc:
@@ -174,13 +174,13 @@ module Net
# provided: see below). If a block is provided, it is yielded
# status messages on the attempt to connect to the server, of
# the form:
- #
+ #
# Trying localhost...
# Connected to localhost.
#
# +options+ is a hash of options. The following example lists
# all options and their default values.
- #
+ #
# host = Net::Telnet::new(
# "Host" => "localhost", # default: "localhost"
# "Port" => 23, # default: 23
@@ -198,16 +198,16 @@ module Net
#
# The options have the following meanings:
#
- # Host:: the hostname or IP address of the host to connect to, as a String.
+ # Host:: the hostname or IP address of the host to connect to, as a String.
# Defaults to "localhost".
#
# Port:: the port to connect to. Defaults to 23.
#
- # Binmode:: if false (the default), newline substitution is performed.
+ # Binmode:: if false (the default), newline substitution is performed.
# Outgoing LF is
# converted to CRLF, and incoming CRLF is converted to LF. If
# true, this substitution is not performed. This value can
- # also be set with the #binmode() method. The
+ # also be set with the #binmode() method. The
# outgoing conversion only applies to the #puts() and #print()
# methods, not the #write() method. The precise nature of
# the newline conversion is also affected by the telnet options
@@ -217,13 +217,13 @@ module Net
# and all received traffic to. In the case of a proper
# Telnet session, this will include the client input as
# echoed by the host; otherwise, it only includes server
- # responses. Output is appended verbatim to this file.
+ # responses. Output is appended verbatim to this file.
# By default, no output log is kept.
#
# Dump_log:: as for Output_log, except that output is written in hexdump
# format (16 bytes per line as hex pairs, followed by their
# printable equivalent), with connection status messages
- # preceded by '#', sent traffic preceded by '>', and
+ # preceded by '#', sent traffic preceded by '>', and
# received traffic preceded by '<'. By default, not dump log
# is kept.
#
@@ -233,7 +233,7 @@ module Net
# ready to receive a new command. By default, this regular
# expression is /[$%#>] \z/n.
#
- # Telnetmode:: a boolean value, true by default. In telnet mode,
+ # Telnetmode:: a boolean value, true by default. In telnet mode,
# traffic received from the host is parsed for special
# command sequences, and these sequences are escaped
# in outgoing traffic sent using #puts() or #print()
@@ -255,11 +255,11 @@ module Net
# minutes), but other attempts to read data from the host
# will hand indefinitely if no data is forthcoming.
#
- # Waittime:: the amount of time to wait after seeing what looks like a
+ # Waittime:: the amount of time to wait after seeing what looks like a
# prompt (that is, received data that matches the Prompt
# option regular expression) to see if more data arrives.
# If more data does arrive in this time, Net::Telnet assumes
- # that what it saw was not really a prompt. This is to try to
+ # that what it saw was not really a prompt. This is to try to
# avoid false matches, but it can also lead to missing real
# prompts (if, for instance, a background process writes to
# the terminal soon after the prompt is displayed). By
@@ -267,12 +267,12 @@ module Net
#
# Proxy:: a proxy object to used instead of opening a direct connection
# to the host. Must be either another Net::Telnet object or
- # an IO object. If it is another Net::Telnet object, this
+ # an IO object. If it is another Net::Telnet object, this
# instance will use that one's socket for communication. If an
# IO object, it is used directly for communication. Any other
# kind of object will cause an error to be raised.
#
- def initialize(options) # :yield: mesg
+ def initialize(options) # :yield: mesg
@options = options
@options["Host"] = "localhost" unless @options.has_key?("Host")
@options["Port"] = 23 unless @options.has_key?("Port")
@@ -280,7 +280,7 @@ module Net
@options["Timeout"] = 10 unless @options.has_key?("Timeout")
@options["Waittime"] = 0 unless @options.has_key?("Waittime")
unless @options.has_key?("Binmode")
- @options["Binmode"] = false
+ @options["Binmode"] = false
else
unless (true == @options["Binmode"] or false == @options["Binmode"])
raise ArgumentError, "Binmode option must be true or false"
@@ -288,7 +288,7 @@ module Net
end
unless @options.has_key?("Telnetmode")
- @options["Telnetmode"] = true
+ @options["Telnetmode"] = true
else
unless (true == @options["Telnetmode"] or false == @options["Telnetmode"])
raise ArgumentError, "Telnetmode option must be true or false"
@@ -374,7 +374,7 @@ module Net
# The socket the Telnet object is using. Note that this object becomes
# a delegate of the Telnet object, so normally you invoke its methods
# directly on the Telnet object.
- attr :sock
+ attr :sock
# Set telnet command interpretation on (+mode+ == true) or off
# (+mode+ == false), or return the current value (+mode+ not
@@ -408,7 +408,7 @@ module Net
def binmode(mode = nil)
case mode
when nil
- @options["Binmode"]
+ @options["Binmode"]
when true, false
@options["Binmode"] = mode
else
@@ -428,7 +428,7 @@ module Net
# Preprocess received data from the host.
#
# Performs newline conversion and detects telnet command sequences.
- # Called automatically by #waitfor(). You should only use this
+ # Called automatically by #waitfor(). You should only use this
# method yourself if you have read input directly using sysread()
# or similar, and even then only if in telnet mode.
def preprocess(string)
@@ -491,9 +491,9 @@ module Net
# Read data from the host until a certain sequence is matched.
#
# If a block is given, the received data will be yielded as it
- # is read in (not necessarily all in one go), or nil if EOF
+ # is read in (not necessarily all in one go), or nil if EOF
# occurs before any data is received. Whether a block is given
- # or not, all data read will be returned in a single string, or again
+ # or not, all data read will be returned in a single string, or again
# nil if EOF occurs before any data is received. Note that
# received data includes the matched sequence we were looking for.
#
@@ -507,7 +507,7 @@ module Net
# into a regular expression. Used only if Match and
# Prompt are not specified.
# Timeout:: the number of seconds to wait for data from the host
- # before raising a TimeoutError. If set to false,
+ # before raising a TimeoutError. If set to false,
# no timeout will occur. If not specified, the
# Timeout option value specified when this instance
# was created will be used, or, failing that, the
@@ -524,7 +524,7 @@ module Net
# EOFError will be raised. Otherwise, defaults to the old
# behaviour that the function will return whatever data
# has been received already, or nil if nothing was received.
- #
+ #
def waitfor(options) # :yield: recvdata
time_out = @options["Timeout"]
waittime = @options["Waittime"]
@@ -619,7 +619,7 @@ module Net
# Sends a string to the host.
#
# This does _not_ automatically append a newline to the string. Embedded
- # newlines may be converted and telnet command sequences escaped
+ # newlines may be converted and telnet command sequences escaped
# depending upon the values of telnetmode, binmode, and telnet options
# set by the host.
def print(string)
@@ -654,7 +654,7 @@ module Net
# data until is sees the prompt or other matched sequence.
#
# If a block is given, the received data will be yielded to it as
- # it is read in. Whether a block is given or not, the received data
+ # it is read in. Whether a block is given or not, the received data
# will be return as a string. Note that the received data includes
# the prompt and in most cases the host's echo of our command.
#
@@ -701,7 +701,7 @@ module Net
#
# The username and password can either be provided as two string
# arguments in that order, or as a hash with keys "Name" and
- # "Password".
+ # "Password".
#
# This method looks for the strings "login" and "Password" from the
# host to determine when to send the username and password. If the
diff --git a/lib/observer.rb b/lib/observer.rb
index 64c7d81351..3692bbca3d 100644
--- a/lib/observer.rb
+++ b/lib/observer.rb
@@ -7,7 +7,7 @@
#
# The Observer pattern, also known as Publish/Subscribe, provides a simple
# mechanism for one object to inform a set of interested third-party objects
-# when its state changes.
+# when its state changes.
#
# == Mechanism
#
@@ -39,14 +39,14 @@
# contracts are correct, nothing else can warn you.
#
# require "observer"
-#
+#
# class Ticker ### Periodically fetch a stock price.
# include Observable
-#
+#
# def initialize(symbol)
# @symbol = symbol
# end
-#
+#
# def run
# lastPrice = nil
# loop do
@@ -67,14 +67,14 @@
# 60 + rand(80)
# end
# end
-#
+#
# class Warner ### An abstract observer of Ticker objects.
# def initialize(ticker, limit)
# @limit = limit
# ticker.add_observer(self)
# end
# end
-#
+#
# class WarnLow < Warner
# def update(time, price) # callback for observer
# if price < @limit
@@ -82,7 +82,7 @@
# end
# end
# end
-#
+#
# class WarnHigh < Warner
# def update(time, price) # callback for observer
# if price > @limit
@@ -123,7 +123,7 @@ module Observable
def add_observer(observer)
@observer_peers = [] unless defined? @observer_peers
unless observer.respond_to? :update
- raise NoMethodError, "observer needs to respond to `update'"
+ raise NoMethodError, "observer needs to respond to `update'"
end
@observer_peers.push observer
end
diff --git a/lib/open3.rb b/lib/open3.rb
index 268f86f61c..2e032c2ca9 100644
--- a/lib/open3.rb
+++ b/lib/open3.rb
@@ -14,7 +14,7 @@
#
# require "open3"
# include Open3
-#
+#
# stdin, stdout, stderr = popen3('nroff -man')
#
# Open3.popen3 can also take a block which will receive stdin, stdout and
@@ -27,10 +27,10 @@
#
module Open3
- #
+ #
# Open stdin, stdout, and stderr streams and start external executable.
# Non-block form:
- #
+ #
# require 'open3'
#
# stdin, stdout, stderr = Open3.popen3(cmd)
diff --git a/lib/optparse.rb b/lib/optparse.rb
index bece659ec5..364abe2330 100644
--- a/lib/optparse.rb
+++ b/lib/optparse.rb
@@ -1,15 +1,15 @@
#
# optparse.rb - command-line option analysis with the OptionParser class.
-#
+#
# Author:: Nobu Nakada
# Documentation:: Nobu Nakada and Gavin Sinclair.
#
-# See OptionParser for documentation.
+# See OptionParser for documentation.
#
-# == Developer Documentation (not for RDoc output)
-#
+# == Developer Documentation (not for RDoc output)
+#
# === Class tree
#
# - OptionParser:: front end
@@ -51,7 +51,7 @@
# solution.
#
# === Features
-#
+#
# 1. The argument specification and the code to handle it are written in the
# same place.
# 2. It can output an option summary; you don't need to maintain this string
@@ -88,12 +88,12 @@
# require 'optparse/time'
# require 'ostruct'
# require 'pp'
-#
+#
# class OptparseExample
-#
+#
# CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
# CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
-#
+#
# #
# # Return a structure describing the options.
# #
@@ -106,19 +106,19 @@
# options.encoding = "utf8"
# options.transfer_type = :auto
# options.verbose = false
-#
+#
# opts = OptionParser.new do |opts|
# opts.banner = "Usage: example.rb [options]"
-#
+#
# opts.separator ""
# opts.separator "Specific options:"
-#
+#
# # Mandatory argument.
# opts.on("-r", "--require LIBRARY",
# "Require the LIBRARY before executing your script") do |lib|
# options.library << lib
# end
-#
+#
# # Optional argument; multi-line description.
# opts.on("-i", "--inplace [EXTENSION]",
# "Edit ARGV files in place",
@@ -127,28 +127,28 @@
# options.extension = ext || ''
# options.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
# end
-#
+#
# # Cast 'delay' argument to a Float.
# opts.on("--delay N", Float, "Delay N seconds before executing") do |n|
# options.delay = n
# end
-#
+#
# # Cast 'time' argument to a Time object.
# opts.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
# options.time = time
# end
-#
+#
# # Cast to octal integer.
# opts.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
# "Specify record separator (default \\0)") do |rs|
# options.record_separator = rs
# end
-#
+#
# # List of arguments.
# opts.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
# options.list = list
# end
-#
+#
# # Keyword completion. We are specifying a specific set of arguments (CODES
# # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
# # the shortest unambiguous text.
@@ -157,41 +157,41 @@
# " (#{code_list})") do |encoding|
# options.encoding = encoding
# end
-#
+#
# # Optional argument with keyword completion.
# opts.on("--type [TYPE]", [:text, :binary, :auto],
# "Select transfer type (text, binary, auto)") do |t|
# options.transfer_type = t
# end
-#
+#
# # Boolean switch.
# opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
# options.verbose = v
# end
-#
+#
# opts.separator ""
# opts.separator "Common options:"
-#
+#
# # No argument, shows at tail. This will print an options summary.
# # Try it and see!
# opts.on_tail("-h", "--help", "Show this message") do
# puts opts
# exit
# end
-#
+#
# # Another typical switch to print the version.
# opts.on_tail("--version", "Show version") do
# puts OptionParser::Version.join('.')
# exit
# end
# end
-#
+#
# opts.parse!(args)
# options
# end # parse()
-#
+#
# end # class OptparseExample
-#
+#
# options = OptparseExample.parse(ARGV)
# pp options
#
@@ -276,7 +276,7 @@ class OptionParser
# Individual switch class. Not important to the user.
#
# Defined within Switch are several Switch-derived classes: NoArgument,
- # RequiredArgument, etc.
+ # RequiredArgument, etc.
#
class Switch
attr_reader :pattern, :conv, :short, :long, :arg, :desc, :block
@@ -511,13 +511,13 @@ class OptionParser
class List
# Map from acceptable argument types to pattern and converter pairs.
attr_reader :atype
-
+
# Map from short style option switches to actual switch objects.
attr_reader :short
-
+
# Map from long style option switches to actual switch objects.
attr_reader :long
-
+
# List of all switches and summary string.
attr_reader :list
@@ -575,7 +575,7 @@ class OptionParser
#
# Inserts +switch+ at the head of the list, and associates short, long
# and negated long options. Arguments are:
- #
+ #
# +switch+:: OptionParser::Switch instance to be inserted.
# +short_opts+:: List of short style options.
# +long_opts+:: List of long style options.
@@ -591,7 +591,7 @@ class OptionParser
#
# Appends +switch+ at the tail of the list, and associates short, long
# and negated long options. Arguments are:
- #
+ #
# +switch+:: OptionParser::Switch instance to be inserted.
# +short_opts+:: List of short style options.
# +long_opts+:: List of long style options.
@@ -756,7 +756,7 @@ class OptionParser
# Initializes a new instance and evaluates the optional block in context
# of the instance. Arguments +args+ are passed to #new, see there for
# description of parameters.
- #
+ #
# This method is *deprecated*, its behavior corresponds to the older #new
# method.
#
@@ -1049,7 +1049,7 @@ class OptionParser
# There is also a special form which matches character range (not full
# set of regular expression):
# "-[a-z]MANDATORY"
- # "-[a-z][OPTIONAL]"
+ # "-[a-z][OPTIONAL]"
# "-[a-z]"
#
# [Argument style and description:]
@@ -1061,7 +1061,7 @@ class OptionParser
# [Description:]
# Description string for the option.
# "Run verbosely"
- #
+ #
# [Handler:]
# Handler for the parsed argument value. Either give a block or pass a
# Proc or Method as an argument.
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index 45ebb8083e..01057972df 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -12,13 +12,13 @@
# OpenStruct allows you to create data objects and set arbitrary attributes.
# For example:
#
-# require 'ostruct'
+# require 'ostruct'
#
# record = OpenStruct.new
# record.name = "John Smith"
# record.age = 70
# record.pension = 300
-#
+#
# puts record.name # -> "John Smith"
# puts record.address # -> nil
#
@@ -41,7 +41,7 @@ class OpenStruct
#
# p data # -> <OpenStruct country="Australia" population=20000000>
#
- # By default, the resulting OpenStruct object will have no attributes.
+ # By default, the resulting OpenStruct object will have no attributes.
#
def initialize(hash=nil)
@table = {}
@@ -53,7 +53,7 @@ class OpenStruct
end
end
- # Duplicate an OpenStruct object members.
+ # Duplicate an OpenStruct object members.
def initialize_copy(orig)
super
@table = @table.dup
diff --git a/lib/parsearg.rb b/lib/parsearg.rb
index 8133858b93..2a713678ed 100644
--- a/lib/parsearg.rb
+++ b/lib/parsearg.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: parsearg is deprecated after Ruby 1.8.1; use optparse instead"
diff --git a/lib/ping.rb b/lib/ping.rb
index c2966b619c..920f15c23e 100644
--- a/lib/ping.rb
+++ b/lib/ping.rb
@@ -3,7 +3,7 @@
#
# Author:: Yukihiro Matsumoto
# Documentation:: Konrad Meyer
-#
+#
# Performs the function of the basic network testing tool, ping.
# See: Ping.
#
@@ -11,7 +11,7 @@
require 'timeout'
require "socket"
-#
+#
# Ping contains routines to test for the reachability of remote hosts.
# Currently the only routine implemented is pingecho().
#
@@ -23,14 +23,14 @@ require "socket"
# slow. Requiring 'resolv-replace' allows non-blocking name resolution.
#
# Usage:
-#
+#
# require 'ping'
#
# puts "'jimmy' is alive and kicking" if Ping.pingecho('jimmy', 10)
#
module Ping
- #
+ #
# Return true if we can open a connection to the hostname or IP address
# +host+ on port +service+ (which defaults to the "echo" port) waiting up
# to +timeout+ seconds.
diff --git a/lib/pp.rb b/lib/pp.rb
index 14fe62ee95..1a4ebe16d3 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -1,10 +1,10 @@
# == Pretty-printer for Ruby objects.
-#
+#
# = Which seems better?
-#
+#
# non-pretty-printed output by #p is:
# #<PP:0x81fedf0 @genspace=#<Proc:0x81feda0>, @group_queue=#<PrettyPrint::GroupQueue:0x81fed3c @queue=[[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], []]>, @buffer=[], @newline="\n", @group_stack=[#<PrettyPrint::Group:0x81fed78 @breakables=[], @depth=0, @break=false>], @buffer_width=0, @indent=0, @maxwidth=79, @output_width=2, @output=#<IO:0x8114ee4>>
-#
+#
# pretty-printed output by #pp is:
# #<PP:0x81fedf0
# @buffer=[],
@@ -22,17 +22,17 @@
# @newline="\n",
# @output=#<IO:0x8114ee4>,
# @output_width=2>
-#
+#
# I like the latter. If you do too, this library is for you.
-#
+#
# = Usage
-#
+#
# pp(obj)
#
# output +obj+ to +$>+ in pretty printed format.
-#
+#
# It returns +nil+.
-#
+#
# = Output Customization
# To define your customized pretty printing function for your classes,
# redefine a method #pretty_print(+pp+) in the class.
@@ -67,10 +67,10 @@ end
class PP < PrettyPrint
# Outputs +obj+ to +out+ in pretty printed format of
# +width+ columns in width.
- #
+ #
# If +out+ is omitted, +$>+ is assumed.
# If +width+ is omitted, 79 is assumed.
- #
+ #
# PP.pp returns +out+.
def PP.pp(obj, out=$>, width=79)
q = PP.new(out, width)
@@ -82,7 +82,7 @@ class PP < PrettyPrint
# Outputs +obj+ to +out+ like PP.pp but with no indent and
# newline.
- #
+ #
# PP.singleline_pp returns +out+.
def PP.singleline_pp(obj, out=$>)
q = SingleLine.new(out)
@@ -124,7 +124,7 @@ class PP < PrettyPrint
# Adds +obj+ to the pretty printing buffer
# using Object#pretty_print or Object#pretty_print_cycle.
- #
+ #
# Object#pretty_print_cycle is used when +obj+ is already
# printed, a.k.a the object reference chain has a cycle.
def pp(obj)
@@ -144,7 +144,7 @@ class PP < PrettyPrint
end
# A convenience method which is same as follows:
- #
+ #
# group(1, '#<' + obj.class.name, '>') { ... }
def object_group(obj, &block) # :yield:
group(1, '#<' + obj.class.name, '>', &block)
@@ -157,7 +157,7 @@ class PP < PrettyPrint
end
# A convenience method which is same as follows:
- #
+ #
# text ','
# breakable
def comma_breakable
@@ -167,23 +167,23 @@ class PP < PrettyPrint
# Adds a separated list.
# The list is separated by comma with breakable space, by default.
- #
+ #
# #seplist iterates the +list+ using +iter_method+.
# It yields each object to the block given for #seplist.
# The procedure +separator_proc+ is called between each yields.
- #
+ #
# If the iteration is zero times, +separator_proc+ is not called at all.
- #
+ #
# If +separator_proc+ is nil or not given,
# +lambda { comma_breakable }+ is used.
# If +iter_method+ is not given, :each is used.
- #
+ #
# For example, following 3 code fragments has similar effect.
- #
+ #
# q.seplist([1,2,3]) {|v| xxx v }
- #
+ #
# q.seplist([1,2,3], lambda { comma_breakable }, :each) {|v| xxx v }
- #
+ #
# xxx 1
# q.comma_breakable
# xxx 2
@@ -247,11 +247,11 @@ class PP < PrettyPrint
# A default pretty printing method for general objects.
# It calls #pretty_print_instance_variables to list instance variables.
- #
+ #
# If +self+ has a customized (redefined) #inspect method,
# the result of self.inspect is used but it obviously has no
# line break hints.
- #
+ #
# This module provides predefined #pretty_print methods for some of
# the most commonly used built-in classes for convenience.
def pretty_print(q)
@@ -274,7 +274,7 @@ class PP < PrettyPrint
end
# Returns a sorted array of instance variable names.
- #
+ #
# This method should return an array of names of instance variables as symbols or strings as:
# +[:@a, :@b]+.
def pretty_print_instance_variables
@@ -283,7 +283,7 @@ class PP < PrettyPrint
# Is #inspect implementation using #pretty_print.
# If you implement #pretty_print, it can be used as follows.
- #
+ #
# alias inspect pretty_print_inspect
#
# However, doing this requires that every class that #inspect is called on
@@ -583,7 +583,7 @@ if __FILE__ == $0
result = PP.pp(a, '')
assert_equal("#{a.inspect}\n", result)
end
-
+
def test_to_s_without_iv
a = Object.new
def a.to_s() "aaa" end
diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb
index 315c422e9e..48f2ebf1e4 100644
--- a/lib/prettyprint.rb
+++ b/lib/prettyprint.rb
@@ -2,7 +2,7 @@
# This class implements a pretty printing algorithm. It finds line breaks and
# nice indentations for grouped structure.
-#
+#
# By default, the class assumes that primitive elements are strings and each
# byte in the strings have single column in width. But it can be used for
# other situations by giving suitable arguments for some methods:
@@ -18,28 +18,28 @@
# == Bugs
# * Box based formatting?
# * Other (better) model/algorithm?
-#
+#
# == References
# Christian Lindig, Strictly Pretty, March 2000,
# http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
-#
+#
# Philip Wadler, A prettier printer, March 1998,
# http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
-#
+#
# == Author
# Tanaka Akira <[email protected]>
-#
+#
class PrettyPrint
# This is a convenience method which is same as follows:
- #
+ #
# begin
# q = PrettyPrint.new(output, maxwidth, newline, &genspace)
# ...
# q.flush
# output
# end
- #
+ #
def PrettyPrint.format(output='', maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n})
q = PrettyPrint.new(output, maxwidth, newline, &genspace)
yield q
diff --git a/lib/pstore.rb b/lib/pstore.rb
index ab495d9ed7..e6e9a12485 100644
--- a/lib/pstore.rb
+++ b/lib/pstore.rb
@@ -13,49 +13,49 @@ require "digest/md5"
#
# PStore implements a file based persistence mechanism based on a Hash. User
# code can store hierarchies of Ruby objects (values) into the data store file
-# by name (keys). An object hierarchy may be just a single object. User code
+# by name (keys). An object hierarchy may be just a single object. User code
# may later read values back from the data store or even update data, as needed.
-#
+#
# The transactional behavior ensures that any changes succeed or fail together.
# This can be used to ensure that the data store is not left in a transitory
# state, where some values were updated but others were not.
-#
-# Behind the scenes, Ruby objects are stored to the data store file with
-# Marshal. That carries the usual limitations. Proc objects cannot be
+#
+# Behind the scenes, Ruby objects are stored to the data store file with
+# Marshal. That carries the usual limitations. Proc objects cannot be
# marshalled, for example.
#
# == Usage example:
-#
+#
# require "pstore"
-#
+#
# # a mock wiki object...
# class WikiPage
# def initialize( page_name, author, contents )
# @page_name = page_name
# @revisions = Array.new
-#
+#
# add_revision(author, contents)
# end
-#
+#
# attr_reader :page_name
-#
+#
# def add_revision( author, contents )
# @revisions << { :created => Time.now,
# :author => author,
# :contents => contents }
# end
-#
+#
# def wiki_page_references
# [@page_name] + @revisions.last[:contents].scan(/\b(?:[A-Z]+[a-z]+){2,}/)
# end
-#
+#
# # ...
# end
-#
+#
# # create a new page...
# home_page = WikiPage.new( "HomePage", "James Edward Gray II",
# "A page about the JoysOfDocumentation..." )
-#
+#
# # then we want to update page data and the index together, or not at all...
# wiki = PStore.new("wiki_pages.pstore")
# wiki.transaction do # begin transaction; do all of this or none of it
@@ -66,9 +66,9 @@ require "digest/md5"
# # update wiki index...
# wiki[:wiki_index].push(*home_page.wiki_page_references)
# end # commit changes to wiki data store file
-#
+#
# ### Some time later... ###
-#
+#
# # read wiki data...
# wiki.transaction(true) do # begin read-only transaction, no changes allowed
# wiki.roots.each do |data_root_name|
@@ -87,10 +87,10 @@ class PStore
class Error < StandardError
end
- #
- # To construct a PStore object, pass in the _file_ path where you would like
+ #
+ # To construct a PStore object, pass in the _file_ path where you would like
# the data to be stored.
- #
+ #
def initialize(file)
dir = File::dirname(file)
unless File::directory? dir
@@ -108,10 +108,10 @@ class PStore
def in_transaction
raise PStore::Error, "not in transaction" unless @transaction
end
- #
+ #
# Raises PStore::Error if the calling code is not in a PStore#transaction or
# if the code is in a read-only PStore#transaction.
- #
+ #
def in_transaction_wr()
in_transaction()
raise PStore::Error, "in read-only transaction" if @rdonly
@@ -119,9 +119,9 @@ class PStore
private :in_transaction, :in_transaction_wr
#
- # Retrieves a value from the PStore file data, by _name_. The hierarchy of
+ # Retrieves a value from the PStore file data, by _name_. The hierarchy of
# Ruby objects stored under that root _name_ will be returned.
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction. It will
# raise PStore::Error if called at any other time.
#
@@ -130,12 +130,12 @@ class PStore
@table[name]
end
#
- # This method is just like PStore#[], save that you may also provide a
- # _default_ value for the object. In the event the specified _name_ is not
- # found in the data store, your _default_ will be returned instead. If you do
- # not specify a default, PStore::Error will be raised if the object is not
+ # This method is just like PStore#[], save that you may also provide a
+ # _default_ value for the object. In the event the specified _name_ is not
+ # found in the data store, your _default_ will be returned instead. If you do
+ # not specify a default, PStore::Error will be raised if the object is not
# found.
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction. It will
# raise PStore::Error if called at any other time.
#
@@ -154,11 +154,11 @@ class PStore
# Stores an individual Ruby object or a hierarchy of Ruby objects in the data
# store file under the root _name_. Assigning to a _name_ already in the data
# store clobbers the old data.
- #
+ #
# == Example:
- #
+ #
# require "pstore"
- #
+ #
# store = PStore.new("data_file.pstore")
# store.transaction do # begin transaction
# # load some data into the store...
@@ -166,7 +166,7 @@ class PStore
# store[:obj_heirarchy] = { "Kev Jackson" => ["rational.rb", "pstore.rb"],
# "James Gray" => ["erb.rb", "pstore.rb"] }
# end # commit changes to data store file
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction and it cannot
# be read-only. It will raise PStore::Error if called at any other time.
#
@@ -176,7 +176,7 @@ class PStore
end
#
# Removes an object hierarchy from the data store, by _name_.
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction and it cannot
# be read-only. It will raise PStore::Error if called at any other time.
#
@@ -187,7 +187,7 @@ class PStore
#
# Returns the names of all object hierarchies currently in the store.
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction. It will
# raise PStore::Error if called at any other time.
#
@@ -197,7 +197,7 @@ class PStore
end
#
# Returns true if the supplied _name_ is currently in the data store.
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction. It will
# raise PStore::Error if called at any other time.
#
@@ -213,22 +213,22 @@ class PStore
#
# Ends the current PStore#transaction, committing any changes to the data
# store immediately.
- #
+ #
# == Example:
- #
+ #
# require "pstore"
- #
+ #
# store = PStore.new("data_file.pstore")
# store.transaction do # begin transaction
# # load some data into the store...
# store[:one] = 1
# store[:two] = 2
- #
+ #
# store.commit # end transaction here, committing changes
- #
+ #
# store[:three] = 3 # this change is never reached
# end
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction. It will
# raise PStore::Error if called at any other time.
#
@@ -240,21 +240,21 @@ class PStore
#
# Ends the current PStore#transaction, discarding any changes to the data
# store.
- #
+ #
# == Example:
- #
+ #
# require "pstore"
- #
+ #
# store = PStore.new("data_file.pstore")
# store.transaction do # begin transaction
# store[:one] = 1 # this change is not applied, see below...
# store[:two] = 2 # this change is not applied, see below...
- #
+ #
# store.abort # end transaction here, discard all changes
- #
+ #
# store[:three] = 3 # this change is never reached
# end
- #
+ #
# *WARNING*: This method is only valid in a PStore#transaction. It will
# raise PStore::Error if called at any other time.
#
@@ -266,19 +266,19 @@ class PStore
#
# Opens a new transaction for the data store. Code executed inside a block
- # passed to this method may read and write data to and from the data store
+ # passed to this method may read and write data to and from the data store
# file.
- #
+ #
# At the end of the block, changes are committed to the data store
- # automatically. You may exit the transaction early with a call to either
+ # automatically. You may exit the transaction early with a call to either
# PStore#commit or PStore#abort. See those methods for details about how
- # changes are handled. Raising an uncaught Exception in the block is
+ # changes are handled. Raising an uncaught Exception in the block is
# equivalent to calling PStore#abort.
- #
+ #
# If _read_only_ is set to +true+, you will only be allowed to read from the
# data store during the transaction and any attempts to change the data will
# raise a PStore::Error.
- #
+ #
# Note that PStore does not support nested transactions.
#
def transaction(read_only=false) # :yields: pstore
diff --git a/lib/rdoc/code_objects.rb b/lib/rdoc/code_objects.rb
index d6c4f1bdb9..16481b9ff9 100644
--- a/lib/rdoc/code_objects.rb
+++ b/lib/rdoc/code_objects.rb
@@ -107,7 +107,7 @@ module RDoc
end
- # A Context is something that can hold modules, classes, methods,
+ # A Context is something that can hold modules, classes, methods,
# attributes, aliases, requires, and includes. Classes, modules, and
# files are all Contexts.
@@ -133,7 +133,7 @@ module RDoc
# Set the comment for this section from the original comment block
# If the first line contains :section:, strip it and use the rest. Otherwise
- # remove lines up to the line containing :section:, and look for
+ # remove lines up to the line containing :section:, and look for
# those lines again at the end and remove them. This lets us write
#
# # ---------------------
@@ -349,7 +349,7 @@ module RDoc
@method_list.each {|m| yield m}
end
- def each_attribute
+ def each_attribute
@attributes.each {|a| yield a}
end
@@ -418,12 +418,12 @@ module RDoc
end
result
end
-
+
def find_local_symbol(symbol)
res = find_method_named(symbol) ||
find_constant_named(symbol) ||
find_attribute_named(symbol) ||
- find_module_named(symbol)
+ find_module_named(symbol)
end
# Handle sections
@@ -454,7 +454,7 @@ module RDoc
def find_attribute_named(name)
@attributes.find {|m| m.name == name}
end
-
+
end
@@ -465,7 +465,7 @@ module RDoc
attr_accessor :file_relative_name
attr_accessor :file_absolute_name
attr_accessor :diagram
-
+
@@all_classes = {}
@@all_modules = {}
@@ -521,7 +521,7 @@ module RDoc
def TopLevel.find_class_named(name)
@@all_classes.each_value do |c|
- res = c.find_class_named(name)
+ res = c.find_class_named(name)
return res if res
end
nil
@@ -582,7 +582,7 @@ module RDoc
# to_s is simply for debugging
def to_s
- res = self.class.name + ": " + @name
+ res = self.class.name + ": " + @name
res << @comment.to_s
res << super
res
@@ -689,7 +689,7 @@ $stderr.puts p
# with a particular context
class Alias < CodeObject
attr_accessor :text, :old_name, :new_name, :comment
-
+
def initialize(text, old_name, new_name, comment)
super()
@text = text
diff --git a/lib/rdoc/diagram.rb b/lib/rdoc/diagram.rb
index 9fdc49c02e..904c2decde 100644
--- a/lib/rdoc/diagram.rb
+++ b/lib/rdoc/diagram.rb
@@ -43,7 +43,7 @@ module RDoc
# Draw the diagrams. We traverse the files, drawing a diagram for
# each. We also traverse each top-level class and module in that
- # file drawing a diagram for these too.
+ # file drawing a diagram for these too.
def draw
unless @options.quiet
@@ -60,21 +60,21 @@ module RDoc
'fontsize' => '8',
'bgcolor' => 'lightcyan1',
'compound' => 'true')
-
+
# it's a little hack %) i'm too lazy to create a separate class
# for default node
graph << DOT::DOTNode.new('name' => 'node',
'fontname' => FONT,
'color' => 'black',
'fontsize' => 8)
-
+
i.modules.each do |mod|
draw_module(mod, graph, true, i.file_relative_name)
end
add_classes(i, graph, i.file_relative_name)
i.diagram = convert_to_png("f_#{file_count}", graph)
-
+
# now go through and document each top level class and
# module independently
i.modules.each_with_index do |mod, count|
@@ -93,8 +93,8 @@ module RDoc
'color' => 'black',
'fontsize' => 8)
draw_module(mod, graph, true)
- mod.diagram = convert_to_png("m_#{file_count}_#{count}",
- graph)
+ mod.diagram = convert_to_png("m_#{file_count}_#{count}",
+ graph)
end
end
$stderr.puts unless @options.quiet
@@ -130,11 +130,11 @@ module RDoc
m = DOT::DOTSubgraph.new('name' => "cluster_#{mod.full_name.gsub( /:/,'_' )}",
'label' => mod.name,
'fontname' => FONT,
- 'color' => 'blue',
- 'style' => 'filled',
+ 'color' => 'blue',
+ 'style' => 'filled',
'URL' => %{"#{url}"},
'fillcolor' => toplevel ? 'palegreen1' : 'palegreen3')
-
+
@done_modules[mod.full_name] = m
add_classes(mod, m, file)
graph << m
@@ -175,8 +175,8 @@ module RDoc
if container.full_name
graph << DOT::DOTNode.new('name' => "#{container.full_name.gsub( /:/,'_' )}",
'label' => "",
- 'width' => (container.classes.empty? and
- container.modules.empty?) ?
+ 'width' => (container.classes.empty? and
+ container.modules.empty?) ?
'0.75' : '0.01',
'height' => '0.01',
'shape' => 'plaintext')
@@ -197,16 +197,16 @@ module RDoc
next if cl.name == 'Object' || cl.name[0,2] == "<<"
url = cl.http_url("classes")
-
+
label = cl.name.dup
if use_fileboxes && cl.in_files.length > 1
- label << '\n[' +
+ label << '\n[' +
cl.in_files.collect {|i|
- i.file_relative_name
+ i.file_relative_name
}.sort.join( '\n' ) +
']'
- end
-
+ end
+
attrs = {
'name' => "#{cl.full_name.gsub( /:/, '_' )}",
'fontcolor' => 'black',
@@ -218,20 +218,20 @@ module RDoc
}
c = DOT::DOTNode.new(attrs)
-
+
if use_fileboxes
- files[last_file].push c
+ files[last_file].push c
else
graph << c
end
end
-
+
if use_fileboxes
files.each_value do |val|
graph << val
end
end
-
+
unless container.classes.empty?
container.classes.each_with_index do |cl, cl_index|
cl.includes.each do |m|
@@ -275,7 +275,7 @@ module RDoc
container.modules.each do |submod|
draw_module(submod, graph)
end
-
+
end
def convert_to_png(file_base, graph)
@@ -294,7 +294,7 @@ module RDoc
File.open(src, 'w+' ) do |f|
f << str << "\n"
end
-
+
system "dot", "-T#{op_type}", src, "-o", dot
# Now construct the imagemap wrapper around
@@ -318,7 +318,7 @@ module RDoc
$stderr.puts "Unexpected output from dot:\n#{area}"
return nil
end
-
+
xs, ys = [$1.to_i, $3.to_i], [$2.to_i, $4.to_i]
url, area_name = $5, $6
diff --git a/lib/rdoc/generators/chm_generator.rb b/lib/rdoc/generators/chm_generator.rb
index 51eeda8dd1..ca58045f59 100644
--- a/lib/rdoc/generators/chm_generator.rb
+++ b/lib/rdoc/generators/chm_generator.rb
@@ -11,7 +11,7 @@ module Generators
CHMGenerator.new(options)
end
-
+
def initialize(*args)
super
@op_name = @options.op_name || "rdoc"
@@ -28,7 +28,7 @@ module Generators
"\n\nYou can download a copy for free from:\n\n" <<
" http://msdn.microsoft.com/library/default.asp?" <<
"url=/library/en-us/htmlhelp/html/hwMicrosoftHTMLHelpDownloads.asp\n\n"
-
+
exit 99
end
@@ -60,7 +60,7 @@ module Generators
end
values['all_html_files'] = files
-
+
File.open(@project_name, "w") do |f|
template.write_html_on(f, values)
end
@@ -98,7 +98,7 @@ module Generators
template = TemplatePage.new(RDoc::Page::CHM_INDEX)
File.open("index.hhk", "w") do |f|
template.write_html_on(f, values)
- end
+ end
end
# Invoke the windows help compiler to compiler the project
diff --git a/lib/rdoc/generators/html_generator.rb b/lib/rdoc/generators/html_generator.rb
index 1f9b808e8d..8e5bac5390 100644
--- a/lib/rdoc/generators/html_generator.rb
+++ b/lib/rdoc/generators/html_generator.rb
@@ -9,8 +9,8 @@
# [classes] an html file for each class or module encountered.
# These classes are not grouped by file: if a file
# contains four classes, we'll generate an html
-# file for the file itself, and four html files
-# for the individual classes.
+# file for the file itself, and four html files
+# for the individual classes.
#
# [indices] we generate three indices for files, classes,
# and methods. These are displayed in a browser
@@ -49,19 +49,19 @@ module Generators
FILE_DIR = "files"
CLASS_DIR = "classes"
CSS_NAME = "rdoc-style.css"
-
+
##
# Build a hash of all items that can be cross-referenced.
- # This is used when we output required and included names:
+ # This is used when we output required and included names:
# if the names appear in this hash, we can generate
# an html cross reference to the appropriate description.
- # We also use this when parsing comment blocks: any decorated
+ # We also use this when parsing comment blocks: any decorated
# words matching an entry in this list are hyperlinked.
class AllReferences
@@refs = {}
-
+
def AllReferences::reset
@@refs = {}
end
@@ -155,7 +155,7 @@ module Generators
end
end
- if (type == "http" || type == "link") &&
+ if (type == "http" || type == "link") &&
url =~ /\.(gif|png|jpg|jpeg|bmp)$/
"<img src=\"#{url}\" />"
@@ -179,11 +179,11 @@ module Generators
# HEre's a hypedlink where the label is different to the URL
# <label>[url]
#
-
+
def handle_special_TIDYLINK(special)
text = special.text
# unless text =~ /(\S+)\[(.*?)\]/
- unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
+ unless text =~ /\{(.*?)\}\[(.*?)\]/ or text =~ /(\S+)\[(.*?)\]/
return text
end
label = $1
@@ -194,7 +194,7 @@ module Generators
end
-
+
#####################################################################
#
# Handle common markup tasks for the various Html classes
@@ -217,9 +217,9 @@ module Generators
| \#\w+(\([.\w\*\/\+\-\=\<\>]+\))? # meth(**) (for operator in Fortran95)
| \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
| \b([A-Z]\w+(::\w+)*) # A::B..
- | \#\w+[!?=]? # #meth_name
+ | \#\w+[!?=]? # #meth_name
| \b\w+([_\/\.]+\w+)*[!?=]? # meth_name
- )/x,
+ )/x,
:CROSSREF)
# external hyperlinks
@@ -284,18 +284,18 @@ module Generators
# A Context is built by the parser to represent a container: contexts
# hold classes, modules, methods, require lists and include lists.
# ClassModule and TopLevel are the context objects we process here
- #
+ #
class ContextUser
include MarkUp
attr_reader :context
-
+
def initialize(context, options)
@context = context
@options = options
end
-
+
# convenience method to build a hyperlink
def href(link, cls, name)
%{<a href="#{link}" class="#{cls}">#{name}</a>} #"
@@ -334,7 +334,7 @@ module Generators
meths.each do |meth|
res << {
"name" => CGI.escapeHTML(meth.name),
- "aref" => "#{path_prefix}\##{meth.aref}"
+ "aref" => "#{path_prefix}\##{meth.aref}"
}
end
res
@@ -358,7 +358,7 @@ module Generators
end
values
end
-
+
# Build a list of constants
def build_constants_summary_list(section)
values = []
@@ -373,7 +373,7 @@ module Generators
end
values
end
-
+
def build_requires_list(context)
potentially_referenced_list(context.requires) {|fn| [fn + ".rb"] }
end
@@ -394,12 +394,12 @@ module Generators
def potentially_referenced_list(array)
res = []
array.each do |i|
- ref = AllReferences[i.name]
+ ref = AllReferences[i.name]
# if !ref
# container = @context.parent
# while !ref && container
# name = container.name + "::" + i.name
-# ref = AllReferences[name]
+# ref = AllReferences[name]
# container = container.parent
# end
# end
@@ -434,12 +434,12 @@ module Generators
methods = @methods.sort
for singleton in [true, false]
- for vis in [ :public, :protected, :private ]
+ for vis in [ :public, :protected, :private ]
res = []
methods.each do |m|
if m.section == section and
- m.document_self and
- m.visibility == vis and
+ m.document_self and
+ m.visibility == vis and
m.singleton == singleton
row = {}
if m.call_seq
@@ -459,7 +459,7 @@ module Generators
alias_names << {
'name' => other.name,
'aref' => other.viewer.as_href(path)
- }
+ }
end
end
unless alias_names.empty?
@@ -479,7 +479,7 @@ module Generators
res << row
end
end
- if res.size > 0
+ if res.size > 0
outer << {
"type" => vis.to_s.capitalize,
"category" => singleton ? "Class" : "Instance",
@@ -492,7 +492,7 @@ module Generators
end
# Build the structured list of classes and modules contained
- # in this context.
+ # in this context.
def build_class_list(level, from, section, infile=nil)
res = ""
@@ -502,7 +502,7 @@ module Generators
next unless mod.section == section
next if infile && !mod.defined_in?(infile)
if mod.document_self
- res <<
+ res <<
prefix <<
"Module " <<
href(url(mod.viewer.path), "link", mod.full_name) <<
@@ -516,7 +516,7 @@ module Generators
next if infile && !cls.defined_in?(infile)
if cls.document_self
res <<
- prefix <<
+ prefix <<
"Class " <<
href(url(cls.viewer.path), "link", cls.full_name) <<
"<br />\n" <<
@@ -526,7 +526,7 @@ module Generators
res
end
-
+
def url(target)
HTMLGenerator.gen_url(path, target)
end
@@ -561,7 +561,7 @@ module Generators
end
# create table of contents if we contain sections
-
+
def add_table_of_sections
toc = []
@context.sections.each do |section|
@@ -572,7 +572,7 @@ module Generators
}
end
end
-
+
@values['toc'] = toc unless toc.empty?
end
@@ -664,16 +664,16 @@ module Generators
al = build_alias_summary_list(section)
secdata["aliases"] = al unless al.empty?
-
+
co = build_constants_summary_list(section)
secdata["constants"] = co unless co.empty?
-
+
al = build_attribute_list(section)
secdata["attributes"] = al unless al.empty?
-
+
cl = build_class_list(0, @context, section)
secdata["classlist"] = cl unless cl.empty?
-
+
mdl = build_method_detail_list(section)
secdata["method_list"] = mdl unless mdl.empty?
@@ -690,8 +690,8 @@ module Generators
next unless att.section == section
if att.visibility == :public || att.visibility == :protected || @options.show_all
entry = {
- "name" => CGI.escapeHTML(att.name),
- "rw" => att.rw,
+ "name" => CGI.escapeHTML(att.name),
+ "rw" => att.rw,
"a_desc" => markup(att.comment, true)
}
unless att.visibility == :public || att.visibility == :protected
@@ -851,16 +851,16 @@ module Generators
al = build_alias_summary_list(section)
secdata["aliases"] = al unless al.empty?
-
+
co = build_constants_summary_list(section)
@values["constants"] = co unless co.empty?
secdata
end
-
+
@values
end
-
+
def write_on(f)
value_hash
template = TemplatePage.new(RDoc::Page::BODY,
@@ -872,7 +872,7 @@ module Generators
def file_attribute_values
full_path = @context.file_absolute_name
short_name = File.basename(full_path)
-
+
@values["title"] = CGI.escapeHTML("File: #{short_name}")
if @context.diagram
@@ -931,7 +931,7 @@ module Generators
AllReferences.add(name, self)
end
-
+
# return a reference to outselves to be used as an href=
# the form depends on whether we're all in one file
# or in multiple files
@@ -1005,7 +1005,7 @@ module Generators
p = @context.params.gsub(/\s*\#.*/, '')
p = p.tr("\n", " ").squeeze(" ")
p = "(" + p + ")" unless p[0] == ?(
-
+
if (block = @context.block_params)
# If this method has explicit block parameters, remove any
# explicit &block
@@ -1022,7 +1022,7 @@ module Generators
end
CGI.escapeHTML(p)
end
-
+
def create_source_code_file(code_body)
meth_path = @html_class.path.sub(/\.html$/, '.src')
File.makedirs(meth_path)
@@ -1089,7 +1089,7 @@ module Generators
end
# we rely on the fact that the first line of a source code
- # listing has
+ # listing has
# # File xxxxx, line dddd
def add_line_numbers(src)
@@ -1100,7 +1100,7 @@ module Generators
real_fmt = "%#{size}d: "
fmt = " " * (size+2)
src.gsub!(/^/) do
- res = sprintf(fmt, first)
+ res = sprintf(fmt, first)
first += 1
fmt = real_fmt
res
@@ -1134,19 +1134,19 @@ module Generators
##
# convert a target url to one that is relative to a given
# path
-
+
def HTMLGenerator.gen_url(path, target)
from = File.dirname(path)
to, to_file = File.split(target)
-
+
from = from.split("/")
to = to.split("/")
-
+
while from.size > 0 and to.size > 0 and from[0] == to[0]
from.shift
to.shift
end
-
+
from.fill("..")
from.concat(to)
from << to_file
@@ -1184,7 +1184,7 @@ module Generators
##
# Build the initial indices and output objects
# based on an array of TopLevel objects containing
- # the extracted information.
+ # the extracted information.
def generate(toplevels)
@toplevels = toplevels
@@ -1219,7 +1219,7 @@ module Generators
##
# Write out the style sheet used by the main frames
#
-
+
def write_style_sheet
template = TemplatePage.new(RDoc::Page::STYLE)
unless @options.css
@@ -1236,7 +1236,7 @@ module Generators
def gen_sub_directories
File.makedirs(FILE_DIR, CLASS_DIR)
- rescue
+ rescue
$stderr.puts $!.message
exit 1
end
@@ -1280,7 +1280,7 @@ module Generators
gen_class_index
gen_method_index
gen_main_index
-
+
# this method is defined in the template file
write_extra_pages if defined? write_extra_pages
end
@@ -1297,8 +1297,8 @@ module Generators
end
def gen_file_index
- gen_an_index(@files, 'Files',
- RDoc::Page::FILE_INDEX,
+ gen_an_index(@files, 'Files',
+ RDoc::Page::FILE_INDEX,
"fr_file_index.html")
end
@@ -1309,12 +1309,12 @@ module Generators
end
def gen_method_index
- gen_an_index(HtmlMethod.all_methods, 'Methods',
+ gen_an_index(HtmlMethod.all_methods, 'Methods',
RDoc::Page::METHOD_INDEX,
"fr_method_index.html")
end
-
+
def gen_an_index(collection, title, template, filename)
template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
res = []
@@ -1373,7 +1373,7 @@ module Generators
unless ref
for file in @files
if file.document_self
- ref = file.path
+ ref = file.path
break
end
end
@@ -1404,7 +1404,7 @@ module Generators
##
# Build the initial indices and output objects
# based on an array of TopLevel objects containing
- # the extracted information.
+ # the extracted information.
def generate(info)
@toplevels = info
@@ -1449,13 +1449,13 @@ module Generators
# all the information in to one big hash
#
def generate_xml
- values = {
+ values = {
'charset' => @options.charset,
'files' => gen_into(@files),
'classes' => gen_into(@classes),
'title' => CGI.escapeHTML(@options.title),
}
-
+
# this method is defined in the template file
write_extra_pages if defined? write_extra_pages
@@ -1489,7 +1489,7 @@ module Generators
gen_an_index(HtmlMethod.all_methods, 'Methods')
end
-
+
def gen_an_index(collection, title)
res = []
collection.sort.each do |f|
diff --git a/lib/rdoc/generators/ri_generator.rb b/lib/rdoc/generators/ri_generator.rb
index c7d0bbd8f0..7020d44ce7 100644
--- a/lib/rdoc/generators/ri_generator.rb
+++ b/lib/rdoc/generators/ri_generator.rb
@@ -9,8 +9,8 @@
# [classes] an html file for each class or module encountered.
# These classes are not grouped by file: if a file
# contains four classes, we'll generate an html
-# file for the file itself, and four html files
-# for the individual classes.
+# file for the file itself, and four html files
+# for the individual classes.
#
# [indices] we generate three indices for files, classes,
# and methods. These are displayed in a browser
@@ -78,7 +78,7 @@ module Generators
##
# Build the initial indices and output objects
# based on an array of TopLevel objects containing
- # the extracted information.
+ # the extracted information.
def generate(toplevels)
RDoc::TopLevel.all_classes_and_modules.each do |cls|
@@ -187,17 +187,17 @@ module Generators
end
return c,i
end
-
+
def params_of(method)
if method.call_seq
method.call_seq
else
params = method.params || ""
-
+
p = params.gsub(/\s*\#.*/, '')
p = p.tr("\n", " ").squeeze(" ")
p = "(" + p + ")" unless p[0] == ?(
-
+
if (block = method.block_params)
block.gsub!(/\s*\#.*/, '')
block = block.tr("\n", " ").squeeze(" ")
@@ -215,7 +215,7 @@ module Generators
# Convert leading comment markers to spaces, but only
# if all non-blank lines have them
-
+
if comment =~ /^(?>\s*)[^\#]/
content = comment
else
@@ -244,7 +244,7 @@ module Generators
$stderr.puts "documentation. This file references a class or "
$stderr.puts "module called #{cls_desc.name} which I don't"
$stderr.puts "have existing documentation for."
- $stderr.puts
+ $stderr.puts
$stderr.puts "Perhaps you need to generate its documentation first"
exit 1
else
diff --git a/lib/rdoc/generators/template/html/hefss.rb b/lib/rdoc/generators/template/html/hefss.rb
index e68ca85823..f0372d2bec 100644
--- a/lib/rdoc/generators/template/html/hefss.rb
+++ b/lib/rdoc/generators/template/html/hefss.rb
@@ -5,11 +5,11 @@ module Page
FONTS = "Verdana, Arial, Helvetica, sans-serif"
STYLE = %{
-body,p { font-family: Verdana, Arial, Helvetica, sans-serif;
+body,p { font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000040; background: #BBBBBB;
}
-td { font-family: Verdana, Arial, Helvetica, sans-serif;
+td { font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000040;
}
@@ -21,7 +21,7 @@ td { font-family: Verdana, Arial, Helvetica, sans-serif;
.big-title-font { color: white;
font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: large;
+ font-size: large;
height: 50px}
.small-title-font { color: purple;
@@ -281,7 +281,7 @@ START:methods
<table width="100%" cellspacing="0" cellpadding="5" border="0">
<tr><td class="methodtitle">
<a name="%aref%">
-<b>%name%</b>%params%
+<b>%name%</b>%params%
IF:codeurl
<a href="%codeurl%" target="source" class="srclink">src</a>
ENDIF:codeurl
@@ -343,10 +343,10 @@ FILE_INDEX = %{
<!--
body {
background-color: #bbbbbb;
- font-family: #{FONTS};
- font-size: 11px;
+ font-family: #{FONTS};
+ font-size: 11px;
font-style: normal;
- line-height: 14px;
+ line-height: 14px;
color: #000040;
}
div.banner {
@@ -360,7 +360,7 @@ div.banner {
text-align: center;
width: 100%;
}
-
+
-->
</style>
<base target="docwin">
diff --git a/lib/rdoc/generators/template/html/html.rb b/lib/rdoc/generators/template/html/html.rb
index 7f9e599465..6cb96079e7 100644
--- a/lib/rdoc/generators/template/html/html.rb
+++ b/lib/rdoc/generators/template/html/html.rb
@@ -236,11 +236,11 @@ div.method-source-code pre { color: #ffdead; overflow: hidden; }
#####################################################################
-### H E A D E R T E M P L A T E
+### H E A D E R T E M P L A T E
#####################################################################
XHTML_PREAMBLE = %{<?xml version="1.0" encoding="%charset%"?>
-<!DOCTYPE html
+<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
}
@@ -268,7 +268,7 @@ HEADER = XHTML_PREAMBLE + %{
return false;
elemStyle = elem.style;
-
+
if ( elemStyle.display != "block" ) {
elemStyle.display = "block"
} else {
@@ -277,10 +277,10 @@ HEADER = XHTML_PREAMBLE + %{
return true;
}
-
+
// Make codeblocks hidden by default
document.writeln( "<style type=\\"text/css\\">div.method-source-code { display: none }</style>" )
-
+
// ]]>
</script>
@@ -461,7 +461,7 @@ IF:sectitle
IF:seccomment
<div class="section-comment">
%seccomment%
- </div>
+ </div>
ENDIF:seccomment
ENDIF:sectitle
@@ -542,7 +542,7 @@ END:attributes
</div>
</div>
ENDIF:attributes
-
+
<!-- if method_list -->
@@ -577,7 +577,7 @@ IF:sourcecode
</a>
ENDIF:sourcecode
</div>
-
+
<div class="method-description">
IF:m_desc
%m_desc%
@@ -678,7 +678,7 @@ CLASS_INDEX = FILE_INDEX
METHOD_INDEX = FILE_INDEX
INDEX = %{<?xml version="1.0" encoding="%charset%"?>
-<!DOCTYPE html
+<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
diff --git a/lib/rdoc/generators/template/html/kilmer.rb b/lib/rdoc/generators/template/html/kilmer.rb
index 55071fc026..52e4793eba 100644
--- a/lib/rdoc/generators/template/html/kilmer.rb
+++ b/lib/rdoc/generators/template/html/kilmer.rb
@@ -5,7 +5,7 @@ module Page
FONTS = "Verdana, Arial, Helvetica, sans-serif"
STYLE = %{
-body,td,p { font-family: %fonts%;
+body,td,p { font-family: %fonts%;
color: #000040;
}
@@ -15,11 +15,11 @@ body,td,p { font-family: %fonts%;
color: #000010;
}
-.big-title-font {
+.big-title-font {
color: black;
font-weight: bold;
- font-family: %fonts%;
- font-size: large;
+ font-family: %fonts%;
+ font-size: large;
height: 60px;
padding: 10px 3px 10px 3px;
}
@@ -31,7 +31,7 @@ body,td,p { font-family: %fonts%;
.aqua { color: black }
.method-name, .attr-name {
- font-family: font-family: %fonts%;
+ font-family: font-family: %fonts%;
font-weight: bold;
font-size: small;
margin-left: 20px;
@@ -67,7 +67,7 @@ body,td,p { font-family: %fonts%;
font-weight: bold;
text-decoration: none;
color: #000033;
- background-color: white;
+ background-color: white;
}
.srclink {
@@ -147,7 +147,7 @@ IF:sectitle
IF:seccomment
<div class="section-comment">
%seccomment%
- </div>
+ </div>
ENDIF:seccomment
ENDIF:sectitle
@@ -355,10 +355,10 @@ FILE_INDEX = %{
<!--
body {
background-color: #ddddff;
- font-family: #{FONTS};
- font-size: 11px;
+ font-family: #{FONTS};
+ font-size: 11px;
font-style: normal;
- line-height: 14px;
+ line-height: 14px;
color: #000040;
}
div.banner {
@@ -372,7 +372,7 @@ div.banner {
text-align: center;
width: 100%;
}
-
+
-->
</style>
<base target="docwin">
diff --git a/lib/rdoc/generators/template/html/old_html.rb b/lib/rdoc/generators/template/html/old_html.rb
index ca66302a08..459b84d3ed 100644
--- a/lib/rdoc/generators/template/html/old_html.rb
+++ b/lib/rdoc/generators/template/html/old_html.rb
@@ -22,7 +22,7 @@ module RDoc
# entry in the array is itself a hash. These are used to generate
# lists using the START: construct. For example, given a hash
# containing
-#
+#
# { 'people' => [ { 'name' => 'Fred', 'age' => '12' },
# { 'name' => 'Mary', 'age' => '21' } ]
#
@@ -46,7 +46,7 @@ module RDoc
# [*STYLE*] a CSS section (without the <style> or comments). This is
# used to generate a style.css file
#
-# [*BODY*]
+# [*BODY*]
# The main body of all non-index RDoc pages. BODY will contain
# two !INCLUDE!s. The first is used to include a document-type
# specific header (FILE_PAGE or CLASS_PAGE). The second include
@@ -73,19 +73,19 @@ module RDoc
# an optional list of %aref%/%name%, one for each method
# documented on this page. This is intended to be an index.
#
-# %attributes%::
+# %attributes%::
# An optional list. For each attribute it contains:
# %name%:: the attribute name
# %rw%:: r/o, w/o, or r/w
# %a_desc%:: description of the attribute
#
-# %classlist%::
+# %classlist%::
# An optional string containing an already-formatted list of
# classes and modules documented in this file
#
# For FILE_PAGE entries, the body will be passed
#
-# %short_name%::
+# %short_name%::
# The name of the file
#
# %full_path%::
@@ -115,7 +115,7 @@ module RDoc
# For both files and classes, the body is passed the following information
# on includes and methods:
#
-# %includes%::
+# %includes%::
# Optional list of included modules. For each, it receives
# %aref%:: optional URL to RDoc page for the module
# %name%:: the name of the module
@@ -155,7 +155,7 @@ module RDoc
#
# [*INDEX*]
# The top-level index page. For a browser-like environment
-# define a frame set that includes the file, class, and
+# define a frame set that includes the file, class, and
# method indices. Passed
# %title%:: title of page
# %initial_page% :: url of initial page to display
@@ -186,7 +186,7 @@ module Page
FONTS = "Verdana, Arial, Helvetica, sans-serif"
STYLE = %{
-body,td,p { font-family: %fonts%;
+body,td,p { font-family: %fonts%;
color: #000040;
}
@@ -198,7 +198,7 @@ body,td,p { font-family: %fonts%;
.big-title-font { color: white;
font-family: %fonts%;
- font-size: large;
+ font-size: large;
height: 50px}
.small-title-font { color: aqua;
@@ -250,7 +250,7 @@ body,td,p { font-family: %fonts%;
font-size: medium;
text-decoration: none;
color: #0000AA;
- background: white;
+ background: white;
}
.paramsig {
@@ -308,7 +308,7 @@ HEADER = %{
<script type="text/javascript" language="JavaScript">
<!--
function popCode(url) {
- window.open(url, "Code",
+ window.open(url, "Code",
"resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}
//-->
@@ -594,10 +594,10 @@ FILE_INDEX = %{
<!--
body {
background-color: #ddddff;
- font-family: #{FONTS};
- font-size: 11px;
+ font-family: #{FONTS};
+ font-size: 11px;
font-style: normal;
- line-height: 14px;
+ line-height: 14px;
color: #000040;
}
div.banner {
@@ -671,7 +671,7 @@ IF:aref
ENDIF:aref
IFNOT:aref
<li>%name%</li>
-ENDIF:aref
+ENDIF:aref
END:requires
</ul>
ENDIF:requires
@@ -694,7 +694,7 @@ IF:aref
ENDIF:aref
IFNOT:aref
<li>%name%</li>
-ENDIF:aref
+ENDIF:aref
END:includes
</ul>
ENDIF:includes
diff --git a/lib/rdoc/generators/template/html/one_page_html.rb b/lib/rdoc/generators/template/html/one_page_html.rb
index 19441f4725..ae92089f31 100644
--- a/lib/rdoc/generators/template/html/one_page_html.rb
+++ b/lib/rdoc/generators/template/html/one_page_html.rb
@@ -19,7 +19,7 @@ IF:aref
ENDIF:aref
IFNOT:aref
<li>%name%</li>
-ENDIF:aref
+ENDIF:aref
END:requires
</ul>
ENDIF:requires
@@ -42,7 +42,7 @@ IF:aref
ENDIF:aref
IFNOT:aref
<li>%name%</li>
-ENDIF:aref
+ENDIF:aref
END:includes
</ul>
ENDIF:includes
@@ -52,7 +52,7 @@ IF:method_list
START:method_list
IF:methods
START:methods
-<h4>%type% %category% method:
+<h4>%type% %category% method:
IF:callseq
<a name="%aref%">%callseq%</a>
ENDIF:callseq
diff --git a/lib/rdoc/generators/template/xml/xml.rb b/lib/rdoc/generators/template/xml/xml.rb
index 4a0c8c9ac4..3673f68481 100644
--- a/lib/rdoc/generators/template/xml/xml.rb
+++ b/lib/rdoc/generators/template/xml/xml.rb
@@ -14,7 +14,7 @@ IF:requires
<required-file-list>
START:requires
<required-file name="%name%"
-IF:aref
+IF:aref
href="%aref%"
ENDIF:aref
/>
@@ -90,7 +90,7 @@ START:classes
<%classmod% name="%full_name%" id="%full_name%">
<classmod-info>
IF:infiles
- <infiles>
+ <infiles>
START:infiles
<infile>HREF:full_path_url:full_path:</infile>
END:infiles
diff --git a/lib/rdoc/generators/xml_generator.rb b/lib/rdoc/generators/xml_generator.rb
index 8c1a76d62b..f36a33f855 100644
--- a/lib/rdoc/generators/xml_generator.rb
+++ b/lib/rdoc/generators/xml_generator.rb
@@ -17,7 +17,7 @@ module Generators
XMLGenerator.new(options)
end
-
+
def initialize(*args)
super
end
@@ -25,7 +25,7 @@ module Generators
##
# Build the initial indices and output objects
# based on an array of TopLevel objects containing
- # the extracted information.
+ # the extracted information.
def generate(info)
@info = info
@@ -70,12 +70,12 @@ module Generators
# all the information in to one big hash
#
def generate_xml
- values = {
+ values = {
'charset' => @options.charset,
'files' => gen_into(@files),
'classes' => gen_into(@classes)
}
-
+
# this method is defined in the template file
write_extra_pages if defined? write_extra_pages
@@ -109,7 +109,7 @@ module Generators
gen_an_index(HtmlMethod.all_methods, 'Methods')
end
-
+
def gen_an_index(collection, title)
res = []
collection.sort.each do |f|
diff --git a/lib/rdoc/markup/sample/sample.rb b/lib/rdoc/markup/sample/sample.rb
index a375b54564..1c0a3b369a 100644
--- a/lib/rdoc/markup/sample/sample.rb
+++ b/lib/rdoc/markup/sample/sample.rb
@@ -1,5 +1,5 @@
# This program illustrates the basic use of the SimpleMarkup
-# class. It extracts the first comment block from the
+# class. It extracts the first comment block from the
# simple_markup.rb file and converts it into HTML on
# standard output. Run it using
#
@@ -7,7 +7,7 @@
#
# You should be in the sample/ directory when you do this,
# as it hardwires the path to the files it needs to require.
-# This isn't necessary in the code you write once you've
+# This isn't necessary in the code you write once you've
# installed the package.
#
# For a better way of formatting code comment blocks (and more)
diff --git a/lib/rdoc/markup/simple_markup.rb b/lib/rdoc/markup/simple_markup.rb
index 8193ca02d4..74c34608ee 100644
--- a/lib/rdoc/markup/simple_markup.rb
+++ b/lib/rdoc/markup/simple_markup.rb
@@ -65,7 +65,7 @@
#
# ant:: a little insect that is known
# to enjoy picnics
-#
+#
# This latter style guarantees that the list bodies' left margins are
# aligned: think of them as a two column table.
#
@@ -107,7 +107,7 @@
#
# = Using SimpleMarkup
#
-# For information on using SimpleMarkup programatically,
+# For information on using SimpleMarkup programatically,
# see SM::SimpleMarkup.
#
# Author:: Dave Thomas, [email protected]
@@ -210,7 +210,7 @@ module SM #:nodoc:
end
##
- # Add to the sequences used to add formatting to an individual word
+ # Add to the sequences used to add formatting to an individual word
# (such as *bold*). Matching entries will generate attibutes
# that the output formatters can recognize by their +name+
@@ -232,7 +232,7 @@ module SM #:nodoc:
#
# parser.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
#
- # Each wiki word will be presented to the output formatter
+ # Each wiki word will be presented to the output formatter
# via the accept_special method
#
@@ -247,7 +247,7 @@ module SM #:nodoc:
# using a Visitor to display the result
def convert(str, op)
- @lines = Lines.new(str.split(/\r?\n/).collect { |aLine|
+ @lines = Lines.new(str.split(/\r?\n/).collect { |aLine|
Line.new(aLine) })
return "" if @lines.empty?
@lines.normalize
@@ -276,12 +276,12 @@ module SM #:nodoc:
line.stamp(Line::BLANK, level)
next
end
-
+
# if a line contains non-blanks before the margin, then it must belong
# to an outer level
text = line.text
-
+
for i in 0...margin
if text[i] != SPACE
@lines.unget
@@ -349,9 +349,9 @@ module SM #:nodoc:
line.strip_leading(margin + prefix_length)
next
end
-
+
# If the character's a space, then we have verbatim text,
- # otherwise
+ # otherwise
if active_line[0] == SPACE
line.strip_leading(margin) if margin > 0
@@ -378,7 +378,7 @@ module SM #:nodoc:
# here is a more reasonably indented block which
# will ab attached to the label.
#
-
+
def handled_labeled_list(line, level, margin, offset, prefix)
prefix_length = prefix.length
text = line.text
@@ -392,15 +392,15 @@ module SM #:nodoc:
prefix.chop!
else raise "Invalid List Type: #{self.inspect}"
end
-
+
# body is on the next line
-
+
if text.length <= offset
original_line = line
line = @lines.next
return(false) unless line
text = line.text
-
+
for i in 0..margin
if text[i] != SPACE
@lines.unget
@@ -418,7 +418,7 @@ module SM #:nodoc:
@lines.delete(original_line)
end
end
-
+
line.stamp(Line::LIST, level+1, prefix, flag)
text[margin, prefix_length] = " " * prefix_length
assign_types_to_lines(offset, level + 1)
diff --git a/lib/rdoc/markup/simple_markup/fragments.rb b/lib/rdoc/markup/simple_markup/fragments.rb
index 6ca06382ab..1a0302a4c7 100644
--- a/lib/rdoc/markup/simple_markup/fragments.rb
+++ b/lib/rdoc/markup/simple_markup/fragments.rb
@@ -123,7 +123,7 @@ module SM
# will end up containing a flow of text
class LineCollection
-
+
def initialize
@fragments = []
end
@@ -194,17 +194,17 @@ module SM
# normal paragraph text.
#
# this is code
- #
+ #
# and more code
#
- # You'll end up with the fragments Paragraph, BlankLine,
+ # You'll end up with the fragments Paragraph, BlankLine,
# Verbatim, BlankLine, Verbatim, BlankLine, etc
#
# The BlankLine in the middle of the verbatim chunk needs to
# be changed to a real verbatim newline, and the two
# verbatim blocks merged
#
- #
+ #
def change_verbatim_blank_lines
frag_block = nil
blank_count = 0
@@ -308,9 +308,9 @@ module SM
def tidy_blank_lines
(@fragments.size - 1).times do |i|
- if @fragments[i].kind_of?(BlankLine) and
+ if @fragments[i].kind_of?(BlankLine) and
@fragments[i+1].kind_of?(ListEnd)
- @fragments[i], @fragments[i+1] = @fragments[i+1], @fragments[i]
+ @fragments[i], @fragments[i+1] = @fragments[i+1], @fragments[i]
end
end
@@ -324,5 +324,5 @@ module SM
end
end
-
+
end
diff --git a/lib/rdoc/markup/simple_markup/inline.rb b/lib/rdoc/markup/simple_markup/inline.rb
index d54fe1e667..eb7fac85c4 100644
--- a/lib/rdoc/markup/simple_markup/inline.rb
+++ b/lib/rdoc/markup/simple_markup/inline.rb
@@ -84,7 +84,7 @@ module SM
"Special: type=#{type}, text=#{text.dump}"
end
end
-
+
class AttributeManager
NULL = "\000".freeze
@@ -159,7 +159,7 @@ module SM
# then non-matching
unless WORD_PAIR_MAP.empty?
WORD_PAIR_MAP.each do |regexp, attr|
- str.gsub!(regexp) {
+ str.gsub!(regexp) {
attrs.set_attrs($`.length + $1.length, $2.length, attr)
NULL*$1.length + $2 + NULL*$3.length
}
@@ -192,7 +192,7 @@ module SM
# A \ in front of a character that would normally be
# processed turns off processing. We do this by turning
# \< into <#{PROTECT}
-
+
PROTECTABLE = [ "<" << "\\" ] #"
@@ -209,7 +209,7 @@ module SM
add_word_pair("*", "*", :BOLD)
add_word_pair("_", "_", :EM)
add_word_pair("+", "+", :TT)
-
+
add_html("em", :EM)
add_html("i", :EM)
add_html("b", :BOLD)
@@ -248,7 +248,7 @@ module SM
puts("Before flow, str='#{@str.dump}'") if $DEBUG
mask_protected_sequences
-
+
@attrs = AttrSpan.new(@str.length)
puts("After protecting, str='#{@str.dump}'") if $DEBUG
@@ -290,7 +290,7 @@ module SM
current_attr = 0
str = ""
-
+
str_len = @str.length
# skip leading invisible text
@@ -323,7 +323,7 @@ module SM
i += 1
end while i < str_len and @str[i].zero?
end
-
+
# tidy up trailing text
if start_pos < str_len
res << copy_string(start_pos, str_len)
diff --git a/lib/rdoc/markup/simple_markup/lines.rb b/lib/rdoc/markup/simple_markup/lines.rb
index 4e294f27dc..b3e950f8b7 100644
--- a/lib/rdoc/markup/simple_markup/lines.rb
+++ b/lib/rdoc/markup/simple_markup/lines.rb
@@ -15,7 +15,7 @@ module SM
RULE = :RULE
PARAGRAPH = :PARAGRAPH
VERBATIM = :VERBATIM
-
+
# line type
attr_accessor :type
@@ -37,7 +37,7 @@ module SM
# true if this line has been deleted from the list of lines
attr_accessor :deleted
-
+
def initialize(text)
@text = text.dup
diff --git a/lib/rdoc/markup/simple_markup/preprocess.rb b/lib/rdoc/markup/simple_markup/preprocess.rb
index 101c9bdeb1..e0421569b8 100644
--- a/lib/rdoc/markup/simple_markup/preprocess.rb
+++ b/lib/rdoc/markup/simple_markup/preprocess.rb
@@ -1,6 +1,6 @@
module SM
- ##
+ ##
# Handle common directives that can occur in a block of text:
#
# : include : filename
@@ -15,10 +15,10 @@ module SM
# Look for common options in a chunk of text. Options that
# we don't handle are passed back to our caller
- # as |directive, param|
+ # as |directive, param|
def handle(text)
- text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
+ text.gsub!(/^([ \t#]*):(\w+):\s*(.+)?\n/) do
prefix = $1
directive = $2.downcase
param = $3
diff --git a/lib/rdoc/markup/simple_markup/to_flow.rb b/lib/rdoc/markup/simple_markup/to_flow.rb
index 048e71abce..563bfa6583 100644
--- a/lib/rdoc/markup/simple_markup/to_flow.rb
+++ b/lib/rdoc/markup/simple_markup/to_flow.rb
@@ -67,7 +67,7 @@ module SM
tag
end
- ##
+ ##
# Here's the client side of the visitor pattern
def start_accepting
diff --git a/lib/rdoc/markup/simple_markup/to_html.rb b/lib/rdoc/markup/simple_markup/to_html.rb
index 26b5f4ce70..ddf93f8fbc 100644
--- a/lib/rdoc/markup/simple_markup/to_html.rb
+++ b/lib/rdoc/markup/simple_markup/to_html.rb
@@ -51,7 +51,7 @@ module SM
tag
end
- ##
+ ##
# Here's the client side of the visitor pattern
def start_accepting
@@ -189,8 +189,8 @@ module SM
def convert_string(item)
CGI.escapeHTML(item).
-
-
+
+
# convert -- to em-dash, (-- to en-dash)
gsub(/---?/, '&#8212;'). #gsub(/--/, '&#8211;').
@@ -233,8 +233,8 @@ module SM
def convert_heading(level, flow)
res =
- annotate("<h#{level}>") +
- convert_flow(flow) +
+ annotate("<h#{level}>") +
+ convert_flow(flow) +
annotate("</h#{level}>\n")
end
@@ -256,14 +256,14 @@ module SM
when ListBase::LABELED
annotate("<dt>") +
- convert_flow(am.flow(fragment.param)) +
+ convert_flow(am.flow(fragment.param)) +
annotate("</dt>") +
annotate("<dd>")
when ListBase::NOTE
annotate("<tr>") +
annotate("<td valign=\"top\">") +
- convert_flow(am.flow(fragment.param)) +
+ convert_flow(am.flow(fragment.param)) +
annotate("</td>") +
annotate("<td>")
else
diff --git a/lib/rdoc/markup/simple_markup/to_latex.rb b/lib/rdoc/markup/simple_markup/to_latex.rb
index 6c16278652..1cca40e561 100644
--- a/lib/rdoc/markup/simple_markup/to_latex.rb
+++ b/lib/rdoc/markup/simple_markup/to_latex.rb
@@ -36,7 +36,7 @@ module SM
ListBase::LOWERALPHA => [ l("\\begin{enumerate}"), l("\\end{enumerate}"), "\\alph" ],
ListBase::LABELED => [ l("\\begin{description}"), l("\\end{description}") ],
ListBase::NOTE => [
- l("\\begin{tabularx}{\\linewidth}{@{} l X @{}}"),
+ l("\\begin{tabularx}{\\linewidth}{@{} l X @{}}"),
l("\\end{tabularx}") ],
}
@@ -86,7 +86,7 @@ module SM
end
- ##
+ ##
# Here's the client side of the visitor pattern
def start_accepting
@@ -225,8 +225,8 @@ module SM
def convert_string(item)
escape(item).
-
-
+
+
# convert ... to elipsis (and make sure .... becomes .<elipsis>)
gsub(/\.\.\.\./, '.\ldots{}').gsub(/\.\.\./, '\ldots{}').
@@ -270,7 +270,7 @@ module SM
when 4 then "\\subsubsection{"
else "\\paragraph{"
end +
- convert_flow(flow) +
+ convert_flow(flow) +
"}\n"
end
diff --git a/lib/rdoc/markup/test/TestInline.rb b/lib/rdoc/markup/test/TestInline.rb
index a067d4c24c..ee41db28b9 100644
--- a/lib/rdoc/markup/test/TestInline.rb
+++ b/lib/rdoc/markup/test/TestInline.rb
@@ -12,20 +12,20 @@ class TestInline < Test::Unit::TestCase
@bold_on = @am.changed_attribute_by_name([], [:BOLD])
@bold_off = @am.changed_attribute_by_name([:BOLD], [])
-
+
@tt_on = @am.changed_attribute_by_name([], [:TT])
@tt_off = @am.changed_attribute_by_name([:TT], [])
-
+
@em_on = @am.changed_attribute_by_name([], [:EM])
@em_off = @am.changed_attribute_by_name([:EM], [])
-
+
@bold_em_on = @am.changed_attribute_by_name([], [:BOLD] | [:EM])
@bold_em_off = @am.changed_attribute_by_name([:BOLD] | [:EM], [])
-
+
@em_then_bold = @am.changed_attribute_by_name([:EM], [:EM] | [:BOLD])
-
+
@em_to_bold = @am.changed_attribute_by_name([:EM], [:BOLD])
-
+
@am.add_word_pair("{", "}", :WOMBAT)
@wombat_on = @am.changed_attribute_by_name([], [:WOMBAT])
@wombat_off = @am.changed_attribute_by_name([:WOMBAT], [])
@@ -44,9 +44,9 @@ class TestInline < Test::Unit::TestCase
\b([A-Z]\w+(::\w+)*)
| \#\w+[!?=]?
| \b\w+([_\/\.]+\w+)+[!?=]?
- )/x,
+ )/x,
:CROSSREF)
-
+
assert_equal(["cat"], @am.flow("cat"))
assert_equal(["cat ", crossref("#fred"), " dog"].flatten,
@@ -101,35 +101,35 @@ class TestInline < Test::Unit::TestCase
assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
@am.flow("cat _and_ *dog*"))
- assert_equal(["cat ", @em_on, "a__nd", @em_off, " ", @bold_on, "dog", @bold_off],
+ assert_equal(["cat ", @em_on, "a__nd", @em_off, " ", @bold_on, "dog", @bold_off],
@am.flow("cat _a__nd_ *dog*"))
end
def test_html_like
assert_equal(["cat ", @tt_on, "dog", @tt_off], @am.flow("cat <tt>dog</Tt>"))
- assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
+ assert_equal(["cat ", @em_on, "and", @em_off, " ", @bold_on, "dog", @bold_off],
@am.flow("cat <i>and</i> <B>dog</b>"))
-
- assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
+
+ assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
@am.flow("cat <i>and <B>dog</B></I>"))
-
- assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+
+ assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
@am.flow("cat <i>and </i><b>dog</b>"))
-
- assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+
+ assert_equal(["cat ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
@am.flow("cat <i>and <b></i>dog</b>"))
-
- assert_equal([@tt_on, "cat", @tt_off, " ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
+
+ assert_equal([@tt_on, "cat", @tt_off, " ", @em_on, "and ", @em_to_bold, "dog", @bold_off],
@am.flow("<tt>cat</tt> <i>and <b></i>dog</b>"))
- assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
+ assert_equal(["cat ", @em_on, "and ", @em_then_bold, "dog", @bold_em_off],
@am.flow("cat <i>and <b>dog</b></i>"))
-
- assert_equal(["cat ", @bold_em_on, "and", @bold_em_off, " dog"],
+
+ assert_equal(["cat ", @bold_em_on, "and", @bold_em_off, " dog"],
@am.flow("cat <i><b>and</b></i> dog"))
-
-
+
+
end
def test_protect
@@ -137,12 +137,12 @@ class TestInline < Test::Unit::TestCase
assert_equal(["cat <tt>dog</Tt>"], @am.flow("cat \\<tt>dog</Tt>"))
- assert_equal(["cat ", @em_on, "and", @em_off, " <B>dog</b>"],
+ assert_equal(["cat ", @em_on, "and", @em_off, " <B>dog</b>"],
@am.flow("cat <i>and</i> \\<B>dog</b>"))
-
+
assert_equal(["*word* or <b>text</b>"], @am.flow("\\*word* or \\<b>text</b>"))
- assert_equal(["_cat_", @em_on, "dog", @em_off],
+ assert_equal(["_cat_", @em_on, "dog", @em_off],
@am.flow("\\_cat_<i>dog</i>"))
end
diff --git a/lib/rdoc/markup/test/TestParse.rb b/lib/rdoc/markup/test/TestParse.rb
index 3ec541ce7a..881ef4cca2 100644
--- a/lib/rdoc/markup/test/TestParse.rb
+++ b/lib/rdoc/markup/test/TestParse.rb
@@ -12,7 +12,7 @@ class TestParse < Test::Unit::TestCase
def start_accepting
@res = []
end
-
+
def end_accepting
@res
end
@@ -73,7 +73,7 @@ class TestParse < Test::Unit::TestCase
if block != expected
rows = (0...([expected.size, block.size].max)).collect{|i|
- [expected[i]||"nil", block[i]||"nil"]
+ [expected[i]||"nil", block[i]||"nil"]
}
printf "\n\n%35s %35s\n", "Expected", "Got"
rows.each {|e,g| printf "%35s %35s\n", e.dump, g.dump }
@@ -348,7 +348,7 @@ class TestParse < Test::Unit::TestCase
"L0: Paragraph\nthe time"
])
-
+
end
def test_verbatim_merge
@@ -440,7 +440,7 @@ class TestParse < Test::Unit::TestCase
end
-
+
def test_list_split
str = %{\
now is
@@ -469,29 +469,29 @@ class TestParse < Test::Unit::TestCase
def test_headings
str = "= heading one"
- line_groups(str,
+ line_groups(str,
[ "L0: Heading\nheading one"
])
str = "=== heading three"
- line_groups(str,
+ line_groups(str,
[ "L0: Heading\nheading three"
])
str = "text\n === heading three"
- line_groups(str,
+ line_groups(str,
[ "L0: Paragraph\ntext",
"L0: Verbatim\n === heading three\n"
])
str = "text\n code\n === heading three"
- line_groups(str,
+ line_groups(str,
[ "L0: Paragraph\ntext",
"L0: Verbatim\n code\n === heading three\n"
])
str = "text\n code\n=== heading three"
- line_groups(str,
+ line_groups(str,
[ "L0: Paragraph\ntext",
"L0: Verbatim\n code\n",
"L0: Heading\nheading three"
@@ -499,5 +499,5 @@ class TestParse < Test::Unit::TestCase
end
-
+
end
diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb
index 7e35abdb0b..fa28cabd33 100644
--- a/lib/rdoc/options.rb
+++ b/lib/rdoc/options.rb
@@ -15,14 +15,14 @@ class Options
# the name of the output directory
attr_accessor :op_dir
-
+
# the name to use for the output
attr_reader :op_name
# include private and protected methods in the
# output
attr_accessor :show_all
-
+
# name of the file, class or module to display in
# the initial index page (if not specified
# the first file we encounter is used)
@@ -103,7 +103,7 @@ class Options
"friends. Option may be repeated. Each accessorname\n" +
"may have '=text' appended, in which case that text\n" +
"appears where the r/w/rw appears for normal accessors."],
-
+
[ "--all", "-a", nil,
"include all methods (not just public)\nin the output" ],
@@ -242,9 +242,9 @@ class Options
def OptionList.options
OPTION_LIST.map do |long, short, arg,|
- [ long,
- short,
- arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT
+ [ long,
+ short,
+ arg ? GetoptLong::REQUIRED_ARGUMENT : GetoptLong::NO_ARGUMENT
]
end
end
@@ -268,9 +268,9 @@ class Options
end
# Show usage and exit
-
+
def OptionList.usage(generator_names)
-
+
puts
puts(VERSION_STRING)
puts
@@ -323,7 +323,7 @@ class Options
used, and on the options you give.
- HTML output is normally produced into a number of separate files
- (one per class, module, and file, along with various indices).
+ (one per class, module, and file, along with various indices).
These files will appear in the directory given by the --op
option (doc/ by default).
@@ -410,7 +410,7 @@ class Options
when "--title" then @title = arg
when "--webcvs" then @webcvs = arg
- when "--accessor"
+ when "--accessor"
arg.split(/,/).each do |accessor|
if accessor =~ /^(\w+)(=(.*))?$/
accessors << $1
@@ -429,10 +429,10 @@ class Options
@generator_name = arg.downcase
setup_generator(generators)
- when "--help"
+ when "--help"
OptionList.usage(generators.keys)
- when "--help-output"
+ when "--help-output"
OptionList.help_output
when "--image-format"
@@ -442,13 +442,13 @@ class Options
raise GetoptLong::InvalidOption.new("unknown image format: #{arg}")
end
- when "--include"
+ when "--include"
@rdoc_include.concat arg.split(/\s*,\s*/)
when "--ri", "--ri-site", "--ri-system"
@generator_name = "ri"
@op_dir = case opt
- when "--ri" then RI::Paths::HOMEDIR
+ when "--ri" then RI::Paths::HOMEDIR
when "--ri-site" then RI::Paths::SITEDIR
when "--ri-system" then RI::Paths::SYSDIR
else fail opt
@@ -458,7 +458,7 @@ class Options
when "--tab-width"
begin
@tab_width = Integer(arg)
- rescue
+ rescue
$stderr.puts "Invalid tab width: '#{arg}'"
exit 1
end
@@ -499,7 +499,7 @@ class Options
# Generate a regexp from the accessors
unless accessors.empty?
- re = '^(' + accessors.map{|a| Regexp.quote(a)}.join('|') + ')$'
+ re = '^(' + accessors.map{|a| Regexp.quote(a)}.join('|') + ')$'
@extra_accessors = Regexp.new(re)
end
@@ -515,8 +515,8 @@ class Options
def title
@title ||= "RDoc Documentation"
end
-
- # Set the title, but only if not already set. This means that a title set from
+
+ # Set the title, but only if not already set. This means that a title set from
# the command line trumps one set in a source file
def title=(string)
@@ -532,7 +532,7 @@ class Options
if !@generator
OptionList.error("Invalid output formatter")
end
-
+
if @generator_name == "xml"
@all_one_file = true
@inline_source = true
@@ -540,7 +540,7 @@ class Options
end
# Check that the right version of 'dot' is available.
- # Unfortuately this doesn't work correctly under Windows NT,
+ # Unfortuately this doesn't work correctly under Windows NT,
# so we'll bypass the test under Windows
def check_diagram
@@ -568,9 +568,9 @@ class Options
# exit
end
end
-
+
# Check that the files on the command line exist
-
+
def check_files
@files.each do |f|
stat = File.stat f rescue error("File not found: #{f}")
diff --git a/lib/rdoc/parsers/parse_c.rb b/lib/rdoc/parsers/parse_c.rb
index a648fe2a56..f7dbe4e35d 100644
--- a/lib/rdoc/parsers/parse_c.rb
+++ b/lib/rdoc/parsers/parse_c.rb
@@ -134,23 +134,23 @@ module RDoc
# Because C source doesn't give descriptive names to Ruby-level parameters,
# you need to document the calling sequence explicitly
#
- # In addition, RDoc assumes by default that the C method implementing a
+ # In addition, RDoc assumes by default that the C method implementing a
# Ruby function is in the same source file as the rb_define_method call.
- # If this isn't the case, add the comment
+ # If this isn't the case, add the comment
#
# rb_define_method(....); // in filename
#
# As an example, we might have an extension that defines multiple classes
# in its Init_xxx method. We could document them using
#
- #
+ #
# /*
# * Document-class: MyClass
# *
# * Encapsulate the writing and reading of the configuration
# * file. ...
# */
- #
+ #
# /*
# * Document-method: read_value
# *
@@ -226,7 +226,7 @@ module RDoc
def remove_commented_out_lines
@body.gsub!(%r{//.*rb_define_}, '//')
end
-
+
def handle_class_module(var_name, class_mod, class_name, parent, in_module)
progress(class_mod[0, 1])
@@ -250,7 +250,7 @@ module RDoc
enclosure = @top_level
end
- if class_mod == "class"
+ if class_mod == "class"
cm = enclosure.add_class(NormalClass, class_name, parent_name)
@stats.num_classes += 1
else
@@ -312,26 +312,26 @@ module RDoc
end
class_meth.comment = mangle_comment(comment) if comment
end
-
+
############################################################
def do_classes
- @body.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
+ @body.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
|var_name, class_name|
handle_class_module(var_name, "module", class_name, nil, nil)
end
-
+
# The '.' lets us handle SWIG-generated files
@body.scan(/([\w\.]+)\s* = \s*rb_define_class\s*
- \(
+ \(
\s*"(\w+)",
\s*(\w+)\s*
- \)/mx) do
-
+ \)/mx) do
+
|var_name, class_name, parent|
handle_class_module(var_name, "class", class_name, parent, nil)
end
-
+
@body.scan(/(\w+)\s*=\s*boot_defclass\s*\(\s*"(\w+?)",\s*(\w+?)\s*\)/) do
|var_name, class_name, parent|
parent = nil if parent == "0"
@@ -339,26 +339,26 @@ module RDoc
end
@body.scan(/(\w+)\s* = \s*rb_define_module_under\s*
- \(
+ \(
\s*(\w+),
\s*"(\w+)"
- \s*\)/mx) do
-
+ \s*\)/mx) do
+
|var_name, in_module, class_name|
handle_class_module(var_name, "module", class_name, nil, in_module)
end
-
+
@body.scan(/([\w\.]+)\s* = \s*rb_define_class_under\s*
- \(
+ \(
\s*(\w+),
\s*"(\w+)",
\s*(\w+)\s*
- \s*\)/mx) do
-
+ \s*\)/mx) do
+
|var_name, in_module, class_name, parent|
handle_class_module(var_name, "class", class_name, parent, in_module)
end
-
+
end
###########################################################
@@ -371,20 +371,20 @@ module RDoc
const |
global_const |
)
- \s*\(
+ \s*\(
(?:\s*(\w+),)?
\s*"(\w+)",
\s*(.*?)\s*\)\s*;
}xm) do
-
+
|type, var_name, const_name, definition|
var_name = "rb_cObject" if !var_name or var_name == "rb_mKernel"
handle_constants(type, var_name, const_name, definition)
end
end
-
+
############################################################
-
+
def do_methods
@body.scan(%r{rb_define_
@@ -401,16 +401,16 @@ module RDoc
(?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
}xm) do
|type, var_name, meth_name, meth_body, param_count, source_file|
- #"
+ #"
# Ignore top-object and weird struct.c dynamic stuff
- next if var_name == "ruby_top_self"
+ next if var_name == "ruby_top_self"
next if var_name == "nstr"
next if var_name == "envtbl"
next if var_name == "argf" # it'd be nice to handle this one
var_name = "rb_cObject" if var_name == "rb_mKernel"
- handle_method(type, var_name, meth_name,
+ handle_method(type, var_name, meth_name,
meth_body, param_count, source_file)
end
@@ -421,7 +421,7 @@ module RDoc
\s*(\d+)\s*\);
}xm) do #"
|var_name, attr_name, attr_reader, attr_writer|
-
+
#var_name = "rb_cObject" if var_name == "rb_mKernel"
handle_attr(var_name, attr_name,
attr_reader.to_i != 0,
@@ -435,23 +435,23 @@ module RDoc
(?:;\s*/[*/]\s+in\s+(\w+?\.[cy]))?
}xm) do #"
|meth_name, meth_body, param_count, source_file|
- handle_method("method", "rb_mKernel", meth_name,
+ handle_method("method", "rb_mKernel", meth_name,
meth_body, param_count, source_file)
end
-
+
@body.scan(/define_filetest_function\s*\(
\s*"([^"]+)",
\s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
\s*(-?\w+)\s*\)/xm) do #"
|meth_name, meth_body, param_count|
-
+
handle_method("method", "rb_mFileTest", meth_name, meth_body, param_count)
handle_method("singleton_method", "rb_cFile", meth_name, meth_body, param_count)
end
end
############################################################
-
+
def do_aliases
@body.scan(%r{rb_define_alias\s*\(\s*(\w+),\s*"([^"]+)",\s*"([^"]+)"\s*\)}m) do
|var_name, new_name, old_name|
@@ -477,7 +477,7 @@ module RDoc
def handle_constants(type, var_name, const_name, definition)
#@stats.num_constants += 1
class_name = @known_classes[var_name]
-
+
return unless class_name
class_obj = find_class(var_name, class_name)
@@ -486,7 +486,7 @@ module RDoc
warn("Enclosing class/module '#{const_name}' for not known")
return
end
-
+
comment = find_const_comment(type, const_name)
# In the case of rb_define_const, the definition and comment are in
@@ -535,7 +535,7 @@ module RDoc
def handle_attr(var_name, attr_name, reader, writer)
rw = ''
- if reader
+ if reader
#@stats.num_methods += 1
rw << 'R'
end
@@ -547,7 +547,7 @@ module RDoc
class_name = @known_classes[var_name]
return unless class_name
-
+
class_obj = find_class(var_name, class_name)
if class_obj
@@ -576,7 +576,7 @@ module RDoc
###########################################################
- def handle_method(type, var_name, meth_name,
+ def handle_method(type, var_name, meth_name,
meth_body, param_count, source_file = nil)
progress(".")
@@ -586,7 +586,7 @@ module RDoc
return unless class_name
class_obj = find_class(var_name, class_name)
-
+
if class_obj
if meth_name == "initialize"
meth_name = "new"
@@ -594,17 +594,17 @@ module RDoc
end
meth_obj = AnyMethod.new("", meth_name)
meth_obj.singleton =
- %w{singleton_method module_function}.include?(type)
-
+ %w{singleton_method module_function}.include?(type)
+
p_count = (Integer(param_count) rescue -1)
-
+
if p_count < 0
meth_obj.params = "(...)"
elsif p_count == 0
meth_obj.params = "()"
else
meth_obj.params = "(" +
- (1..p_count).map{|i| "p#{i}"}.join(", ") +
+ (1..p_count).map{|i| "p#{i}"}.join(", ") +
")"
end
@@ -619,7 +619,7 @@ module RDoc
end
end
end
-
+
############################################################
# Find the C code corresponding to a Ruby method
@@ -633,7 +633,7 @@ module RDoc
remove_private_comments(comment) if comment
# see if we can find the whole body
-
+
re = Regexp.escape(body_text) + '[^(]*^\{.*?^\}'
if Regexp.new(re, Regexp::MULTILINE).match(body)
body_text = $&
@@ -650,7 +650,7 @@ module RDoc
comment = override_comment if override_comment
find_modifiers(comment, meth_obj) if comment
-
+
# meth_obj.params = params
meth_obj.start_collecting_tokens
meth_obj.add_token(RubyToken::Token.new(1,1).set_text(body_text))
@@ -729,7 +729,7 @@ module RDoc
##
# Remove the /*'s and leading asterisks from C comments
-
+
def mangle_comment(comment)
comment.sub!(%r{/\*+}) { " " * $&.length }
comment.sub!(%r{\*+/}) { " " * $&.length }
@@ -739,7 +739,7 @@ module RDoc
def find_class(raw_name, name)
unless @classes[raw_name]
- if raw_name =~ /^rb_m/
+ if raw_name =~ /^rb_m/
@classes[raw_name] = @top_level.add_module(NormalModule, name)
else
@classes[raw_name] = @top_level.add_class(NormalClass, name, nil)
@@ -762,11 +762,11 @@ module RDoc
##
# Removes #ifdefs that would otherwise confuse us
-
+
def handle_ifdefs_in(body)
body.gsub(/^#ifdef HAVE_PROTOTYPES.*?#else.*?\n(.*?)#endif.*?\n/m) { $1 }
end
-
+
end
end
diff --git a/lib/rdoc/parsers/parse_f95.rb b/lib/rdoc/parsers/parse_f95.rb
index f1a1ae4d4b..c9ac788ba2 100644
--- a/lib/rdoc/parsers/parse_f95.rb
+++ b/lib/rdoc/parsers/parse_f95.rb
@@ -32,9 +32,9 @@
#
#=== Components parsed by default
#
-#By default, documentation on public components (subroutines, functions,
-#variables, constants, derived-types, defined operators,
-#defined assignments) are generated.
+#By default, documentation on public components (subroutines, functions,
+#variables, constants, derived-types, defined operators,
+#defined assignments) are generated.
#With "--all" option, documentation on all components
#are generated (almost same as the Ruby parser).
#
@@ -49,7 +49,7 @@
#
#Aliases by interface statement are described in the item of 'Methods'.
#
-#Components which are imported from other modules and published again
+#Components which are imported from other modules and published again
#are described in the item of 'Methods'.
#
#=== Format of comment blocks
@@ -299,7 +299,7 @@ module RDoc
f9x_module = @top_level.add_module NormalClass, module_name
f9x_module.record_location @top_level
- f9x_comment = COMMENTS_ARE_UPPER ?
+ f9x_comment = COMMENTS_ARE_UPPER ?
find_comments(pre_comment.join("\n")) + "\n" + module_trailing :
module_trailing + "\n" + find_comments(module_code.sub(/^.*$\n/i, ''))
f9x_module.comment = f9x_comment
@@ -324,8 +324,8 @@ module RDoc
program_code = module_program_code
program_trailing = module_program_trailing
progress "p"
- program_comment = COMMENTS_ARE_UPPER ?
- find_comments(pre_comment.join("\n")) + "\n" + program_trailing :
+ program_comment = COMMENTS_ARE_UPPER ?
+ find_comments(pre_comment.join("\n")) + "\n" + program_trailing :
program_trailing + "\n" + find_comments(program_code.sub(/^.*$\n/i, ''))
program_comment = "\n\n= <i>Program</i> <tt>#{program_name}</tt>\n\n" \
+ program_comment
@@ -414,12 +414,12 @@ module RDoc
# This information is used when "add_method" and
# "set_visibility_for" are called.
#
- visibility_default, visibility_info =
+ visibility_default, visibility_info =
parse_visibility(remaining_lines.join("\n"), visibility, container)
@@public_methods.concat visibility_info
if visibility_default == :public
if !cascaded_modules_list.empty?
- cascaded_modules =
+ cascaded_modules =
Attr.new("Cascaded Modules",
"Imported modules all of whose components are published again",
"",
@@ -503,7 +503,7 @@ module RDoc
type_trailing = find_comments($4)
next if type_trailing =~ /^:nodoc:/
type_visibility = $1
- type_comment = COMMENTS_ARE_UPPER ?
+ type_comment = COMMENTS_ARE_UPPER ?
find_comments($~.pre_match) + "\n" + type_trailing :
type_trailing + "\n" + find_comments(type_code.sub(/^.*$\n/i, ''))
type_element_visibility_public = true
@@ -570,8 +570,8 @@ module RDoc
end
if !derived_types_comment.empty?
- derived_types_table =
- Attr.new("Derived Types", "Derived_Types", "",
+ derived_types_table =
+ Attr.new("Derived Types", "Derived_Types", "",
derived_types_comment)
container.add_attribute(derived_types_table)
end
@@ -735,8 +735,8 @@ module RDoc
subroutine_trailing = procedure_trailing
subroutine_code = procedure_code
- subroutine_comment = COMMENTS_ARE_UPPER ?
- pre_comment.join("\n") + "\n" + subroutine_trailing :
+ subroutine_comment = COMMENTS_ARE_UPPER ?
+ pre_comment.join("\n") + "\n" + subroutine_trailing :
subroutine_trailing + "\n" + subroutine_code.sub(/^.*$\n/i, '')
subroutine = AnyMethod.new("subroutine", subroutine_name)
parse_subprogram(subroutine, subroutine_params,
@@ -788,7 +788,7 @@ module RDoc
# The visibility of procedure is specified
#
- set_visibility(container, procedure_name,
+ set_visibility(container, procedure_name,
visibility_default, @@public_methods)
# The alias for this procedure from external modules
@@ -872,11 +872,11 @@ module RDoc
next if !old_meth
nolink = old_meth.visibility == :private ? true : nil
nolink = nil if @options.show_all
- new_meth =
- initialize_external_method(generic_name, proc,
- old_meth.params, nil,
- old_meth.comment,
- old_meth.clone.token_stream[0].text,
+ new_meth =
+ initialize_external_method(generic_name, proc,
+ old_meth.params, nil,
+ old_meth.comment,
+ old_meth.clone.token_stream[0].text,
true, nolink)
new_meth.singleton = old_meth.singleton
@@ -938,10 +938,10 @@ module RDoc
end
if indicated_method
- external_method =
- initialize_external_method(generic_name, proc,
- indicated_method.params,
- indicated_file,
+ external_method =
+ initialize_external_method(generic_name, proc,
+ indicated_method.params,
+ indicated_file,
indicated_method.comment)
progress "e"
@@ -1004,12 +1004,12 @@ module RDoc
# Parse arguments, comment, code of subroutine and function.
# Return AnyMethod object.
#
- def parse_subprogram(subprogram, params, comment, code,
+ def parse_subprogram(subprogram, params, comment, code,
before_contains=nil, function=nil, prefix=nil)
subprogram.singleton = false
prefix = "" if !prefix
arguments = params.sub(/\(/, "").sub(/\)/, "").split(",") if params
- args_comment, params_opt =
+ args_comment, params_opt =
find_arguments(arguments, code.sub(/^s*?contains\s*?(!.*?)?$.*/im, ""),
nil, nil, true)
params_opt = "( " + params_opt + " ) " if params_opt
@@ -1084,7 +1084,7 @@ module RDoc
if arg == defitem.varname.strip.chomp || all
args_rdocforms << <<-"EOF"
-#{indent}<tt><b>#{defitem.varname.chomp.strip}#{defitem.arraysuffix}</b> #{defitem.inivalue}</tt> ::
+#{indent}<tt><b>#{defitem.varname.chomp.strip}#{defitem.arraysuffix}</b> #{defitem.inivalue}</tt> ::
#{indent} <tt>#{defitem.types.chomp.strip}</tt>
EOF
if !defitem.comment.chomp.strip.empty?
@@ -1094,7 +1094,7 @@ EOF
}
args_rdocforms << <<-"EOF"
-#{indent} <tt></tt> ::
+#{indent} <tt></tt> ::
#{indent} <tt></tt>
#{indent} #{comment.chomp.strip}
EOF
@@ -1127,7 +1127,7 @@ EOF
before_contains = "" if !before_contains
while lines =~ /^\s*?namelist\s+\/\s*?(\w+)\s*?\/([\s\w\,]+)$/i
lines = $~.post_match
- nml_comment = COMMENTS_ARE_UPPER ?
+ nml_comment = COMMENTS_ARE_UPPER ?
find_comments($~.pre_match) : find_comments($~.post_match)
nml_name = $1
nml_args = $2.split(",")
@@ -1197,7 +1197,7 @@ EOF
if internal
external_alias_header = "#{INTERNAL_ALIAS_MES} "
- external_alias_text = external_alias_header + old
+ external_alias_text = external_alias_header + old
elsif file
external_alias_header = "#{EXTERNAL_ALIAS_MES} "
external_alias_text = external_alias_header + file + "#" + old
@@ -1331,8 +1331,8 @@ EOF
subname.upcase == alias_item["old_name"].upcase &&
@options.ignore_case
- new_meth = initialize_external_method(alias_item["new_name"],
- subname, params, @file_name,
+ new_meth = initialize_external_method(alias_item["new_name"],
+ subname, params, @file_name,
comment)
new_meth.visibility = alias_item["visibility"]
@@ -1408,7 +1408,7 @@ EOF
brank_flag = false
now_continuing = false
next ""
- else
+ else
brank_flag = false
now_continuing = false
ignore = false
@@ -1601,7 +1601,7 @@ EOF
comment_block = Array.new
checked = false
lines.each do |line|
- if !checked
+ if !checked
if /^\s?#{INTERNAL_ALIAS_MES}/ =~ line ||
/^\s?#{EXTERNAL_ALIAS_MES}/ =~ line
checked = true
@@ -1680,9 +1680,9 @@ EOF
def to_s
return <<-EOF
-<Fortran95Definition:
+<Fortran95Definition:
varname=#{@varname}, types=#{types},
- inivalue=#{@inivalue}, arraysuffix=#{@arraysuffix}, nodoc=#{@nodoc},
+ inivalue=#{@inivalue}, arraysuffix=#{@arraysuffix}, nodoc=#{@nodoc},
comment=
#{@comment}
>
diff --git a/lib/rdoc/parsers/parse_rb.rb b/lib/rdoc/parsers/parse_rb.rb
index cf59725462..b4aac3de84 100644
--- a/lib/rdoc/parsers/parse_rb.rb
+++ b/lib/rdoc/parsers/parse_rb.rb
@@ -7,9 +7,9 @@
# This file contains stuff stolen outright from:
#
-# rtags.rb -
+# rtags.rb -
# ruby-lex.rb - ruby lexcal analyzer
-# ruby-token.rb - ruby tokens
+# ruby-token.rb - ruby tokens
# by Keiju ISHITSUKA (Nippon Rational Inc.)
#
@@ -35,7 +35,7 @@ module RubyToken
EXPR_FNAME = :EXPR_FNAME
EXPR_DOT = :EXPR_DOT
EXPR_CLASS = :EXPR_CLASS
-
+
class Token
NO_TEXT = "??".freeze
attr :text
@@ -117,8 +117,8 @@ module RubyToken
if (tk = source[token]).nil?
IRB.fail TkReading2TokenNoKey, token
end
- tk = Token(tk[0], value)
- else
+ tk = Token(tk[0], value)
+ else
tk = if (token.ancestors & [TkId, TkVal, TkOPASGN, TkUnknownChar]).empty?
token.new(@prev_line_no, @prev_char_no)
else
@@ -218,14 +218,14 @@ module RubyToken
[:TkASSOC, TkOp, "=>"],
[:TkQUESTION, TkOp, "?"], #?
[:TkCOLON, TkOp, ":"], #:
-
+
[:TkfLPAREN], # func( #
[:TkfLBRACK], # func[ #
[:TkfLBRACE], # func{ #
[:TkSTAR], # *arg
[:TkAMPER], # &arg #
[:TkSYMBOL, TkId], # :SYMBOL
- [:TkSYMBEG, TkId],
+ [:TkSYMBEG, TkId],
[:TkGT, TkOp, ">"],
[:TkLT, TkOp, "<"],
[:TkPLUS, TkOp, "+"],
@@ -276,7 +276,7 @@ module RubyToken
token_c = Class.new super_token
RubyToken.const_set token_n, token_c
# token_c.inspect
-
+
if reading
if TkReading2Token[reading]
IRB.fail TkReading2TokenDuplicateError, token_n, reading
@@ -340,11 +340,11 @@ class RubyLex
# here document. Once complete, it needs to read the rest of the
# original line, but then skip the here document body.
#
-
+
class BufferedReader
-
+
attr_reader :line_num
-
+
def initialize(content)
if /\t/ =~ content
tab_width = Options.instance.tab_width
@@ -363,34 +363,34 @@ class RubyLex
@last_newline = 0
@newline_pending = false
end
-
+
def column
@offset - @last_newline
end
-
+
def getc
return nil if @offset >= @size
ch = @content[@offset, 1]
-
+
@offset += 1
@hwm = @offset if @hwm < @offset
-
+
if @newline_pending
@line_num += 1
@last_newline = @offset - 1
@newline_pending = false
end
-
+
if ch == "\n"
@newline_pending = true
end
ch
end
-
+
def getc_already_read
getc
end
-
+
def ungetc(ch)
raise "unget past beginning of file" if @offset <= 0
@offset -= 1
@@ -398,13 +398,13 @@ class RubyLex
@newline_pending = false
end
end
-
+
def get_read
res = @content[@read_back_offset...@offset]
@read_back_offset = @offset
res
end
-
+
def peek(at)
pos = @offset + at
if pos >= @size
@@ -413,11 +413,11 @@ class RubyLex
@content[pos, 1]
end
end
-
+
def peek_equal(str)
@content[@offset, str.length] == str
end
-
+
def divert_read_from(reserve)
@content[@offset, 0] = reserve
@size = @content.size
@@ -430,10 +430,10 @@ class RubyLex
def_exception(:AlreadyDefinedToken, "Already defined token(%s)")
def_exception(:TkReading2TokenNoKey, "key nothing(key='%s')")
def_exception(:TkSymbol2TokenNoKey, "key nothing(key='%s')")
- def_exception(:TkReading2TokenDuplicateError,
+ def_exception(:TkReading2TokenDuplicateError,
"key duplicate(token_n='%s', key='%s')")
def_exception(:SyntaxError, "%s")
-
+
include RubyToken
include IRB
@@ -457,7 +457,7 @@ class RubyLex
@quoted = nil
@lex_state = EXPR_BEG
@space_seen = false
-
+
@continue = false
@line = ""
@@ -548,7 +548,7 @@ class RubyLex
p tk if $DEBUG
tk
end
-
+
ENINDENT_CLAUSE = [
"case", "class", "def", "do", "for", "if",
"module", "unless", "until", "while", "begin" #, "when"
@@ -563,7 +563,7 @@ class RubyLex
"r" => "/",
"w" => "]"
}
-
+
PERCENT_PAREN = {
"{" => "}",
"[" => "]",
@@ -646,10 +646,10 @@ class RubyLex
Token(TkNL).set_text("\n")
end
- @OP.def_rules("*", "**",
+ @OP.def_rules("*", "**",
"!", "!=", "!~",
- "=", "==", "===",
- "=~", "<=>",
+ "=", "==", "===",
+ "=~", "<=>",
"<", "<=",
">", ">=", ">>") do
|op, io|
@@ -716,8 +716,8 @@ class RubyLex
@lex_state = EXPR_BEG
Token(op).set_text(op)
end
-
- @OP.def_rules("+=", "-=", "*=", "**=",
+
+ @OP.def_rules("+=", "-=", "*=", "**=",
"&=", "|=", "^=", "<<=", ">>=", "||=", "&&=") do
|op, io|
@lex_state = EXPR_BEG
@@ -771,7 +771,7 @@ class RubyLex
lex_int2
end
-
+
def lex_int2
@OP.def_rules("]", "}", ")") do
|op, io|
@@ -813,7 +813,7 @@ class RubyLex
Token(TkOPASGN, :/).set_text("/=") #")
elsif @lex_state == EXPR_ARG and @space_seen and peek(0) !~ /\s/
identify_string(op)
- else
+ else
@lex_state = EXPR_BEG
Token("/").set_text(op)
end
@@ -828,7 +828,7 @@ class RubyLex
# @lex_state = EXPR_BEG
# Token(TkOPASGN, :^)
# end
-
+
@OP.def_rules(",", ";") do
|op, io|
@lex_state = EXPR_BEG
@@ -844,7 +844,7 @@ class RubyLex
@lex_state = EXPR_BEG
Token("~").set_text("~@")
end
-
+
@OP.def_rule("(") do
@indent += 1
if @lex_state == EXPR_BEG || @lex_state == EXPR_MID
@@ -894,15 +894,15 @@ class RubyLex
end
@OP.def_rule('\\') do #'
- if getc == "\n"
+ if getc == "\n"
@space_seen = true
@continue = true
Token(TkSPACE).set_text("\\\n")
- else
+ else
ungetc
Token("\\").set_text("\\") #"
- end
- end
+ end
+ end
@OP.def_rule('%') do
|op, io|
@@ -932,7 +932,7 @@ class RubyLex
end
end
- # @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
+ # @OP.def_rule("def", proc{|op, io| /\s/ =~ io.peek(0)}) do
# |op, io|
# @indent += 1
# @lex_state = EXPR_FNAME
@@ -957,10 +957,10 @@ class RubyLex
printf "MATCH: end %s: %s\n", op, io.inspect if RubyLex.debug?
t
end
-
+
p @OP if RubyLex.debug?
end
-
+
def identify_gvar
@lex_state = EXPR_END
str = "$"
@@ -969,15 +969,15 @@ class RubyLex
when /[~_*$?!@\/\\;,=:<>".]/ #"
str << ch
Token(TkGVAR, str)
-
+
when "-"
str << "-" << getc
Token(TkGVAR, str)
-
+
when "&", "`", "'", "+"
str << ch
Token(TkBACK_REF, str)
-
+
when /[1-9]/
str << ch
while (ch = getc) =~ /[0-9]/
@@ -989,13 +989,13 @@ class RubyLex
ungetc
ungetc
return identify_identifier
- else
+ else
ungetc
- Token("$")
+ Token("$")
end
tk.set_text(str)
end
-
+
def identify_identifier
token = ""
token.concat getc if peek(0) =~ /[$@]/
@@ -1006,7 +1006,7 @@ class RubyLex
token.concat ch
end
ungetc
-
+
if ch == "!" or ch == "?"
token.concat getc
end
@@ -1021,7 +1021,7 @@ class RubyLex
@lex_state = EXPR_END
return Token(TkIVAR, token).set_text(token)
end
-
+
if @lex_state != EXPR_DOT
print token, "\n" if RubyLex.debug?
@@ -1119,7 +1119,7 @@ class RubyLex
@lex_state = EXPR_END
Token(Ltype2Token[lt], str).set_text(str.dump)
end
-
+
def identify_quotation(initial_char)
ch = getc
if lt = PERCENT_LTYPE[ch]
@@ -1200,7 +1200,7 @@ class RubyLex
end
Token(type).set_text(str)
end
-
+
def identify_string(ltype, quoted = ltype, opener=nil, initial_char = nil)
@ltype = ltype
@quoted = quoted
@@ -1212,9 +1212,9 @@ class RubyLex
nest = 0
begin
- while ch = getc
+ while ch = getc
str << ch
- if @quoted == ch
+ if @quoted == ch
if nest == 0
break
else
@@ -1275,7 +1275,7 @@ class RubyLex
if ch == "\n"
ch = " "
else
- comment << "\\"
+ comment << "\\"
end
else
if ch == "\n"
@@ -1288,7 +1288,7 @@ class RubyLex
end
return Token(TkCOMMENT).set_text(comment)
end
-
+
def read_escape
res = ""
case ch = getc
@@ -1305,7 +1305,7 @@ class RubyLex
end
res << ch
end
-
+
when "x"
res << ch
2.times do
@@ -1371,7 +1371,7 @@ module RDoc
CONSTANT_MODIFIERS = GENERAL_MODIFIERS
- METHOD_MODIFIERS = GENERAL_MODIFIERS +
+ METHOD_MODIFIERS = GENERAL_MODIFIERS +
[ 'arg', 'args', 'yield', 'yields', 'notnew', 'not-new', 'not_new', 'doc' ]
@@ -1408,14 +1408,14 @@ module RDoc
$stderr.puts "\n\n"
$stderr.puts "RDoc failure in #@input_file_name at or around " +
"line #{@scanner.line_no} column #{@scanner.char_no}"
- $stderr.puts
+ $stderr.puts
$stderr.puts "Before reporting this, could you check that the file"
$stderr.puts "you're documenting compiles cleanly--RDoc is not a"
$stderr.puts "full Ruby parser, and gets confused easily if fed"
$stderr.puts "invalid programs."
$stderr.puts
$stderr.puts "The internal error was:\n\n"
-
+
e.set_backtrace(e.backtrace[0,4])
raise
end
@@ -1424,7 +1424,7 @@ module RDoc
@top_level
end
- private
+ private
def make_message(msg)
prefix = "\n" + @input_file_name + ":"
@@ -1573,24 +1573,24 @@ module RDoc
container.comment = comment unless comment.empty?
parse_statements(container, NORMAL, nil, comment)
end
-
+
def parse_statements(container, single=NORMAL, current_method=nil, comment='')
nest = 1
save_visibility = container.visibility
-
+
# if container.kind_of?(TopLevel)
# else
# comment = ''
# end
non_comment_seen = true
-
+
while tk = get_tk
-
+
keep_comment = false
-
+
non_comment_seen = true unless tk.kind_of?(TkCOMMENT)
-
+
case tk
when TkNL
@@ -1603,12 +1603,12 @@ module RDoc
end
while tk.kind_of?(TkCOMMENT)
comment << tk.text << "\n"
- tk = get_tk # this is the newline
+ tk = get_tk # this is the newline
skip_tkspace(false) # leading spaces
tk = get_tk
end
unless comment.empty?
- look_for_directives_in(container, comment)
+ look_for_directives_in(container, comment)
if container.done_documenting
container.ongoing_visibility = save_visibility
# return
@@ -1700,7 +1700,7 @@ module RDoc
end
end
end
-
+
case tk.name
when "require"
parse_require(container, comment)
@@ -1729,7 +1729,7 @@ module RDoc
end
end
-
+
def parse_class(container, single, tk, comment, &block)
progress("c")
@@ -1884,11 +1884,11 @@ module RDoc
@stats.num_methods += 1
line_no = tk.line_no
column = tk.char_no
-
+
start_collecting_tokens
add_token(tk)
add_token_listener(self)
-
+
@scanner.instance_eval{@lex_state = EXPR_FNAME}
skip_tkspace(false)
name_t = get_tk
@@ -1982,9 +1982,9 @@ module RDoc
meth.visibility = :public
end
end
-
+
parse_statements(container, single, meth)
-
+
remove_token_listener(meth)
# Look for a 'call-seq' in the comment, and override the
@@ -1995,19 +1995,19 @@ module RDoc
seq.gsub!(/^\s*\#\s*/, '')
meth.call_seq = seq
end
-
+
meth.comment = comment
end
-
+
def skip_method(container)
meth = AnyMethod.new("", "anon")
parse_method_parameters(meth)
parse_statements(container, false, meth)
end
-
+
# Capture the method's parameters. Along the way,
- # look for a comment containing
+ # look for a comment containing
#
# # yields: ....
#
@@ -2084,7 +2084,7 @@ module RDoc
unget_tk(tk) unless tk.kind_of?(TkIN)
end
- # while, until, and for have an optional
+ # while, until, and for have an optional
def skip_optional_do_after_expression
skip_tkspace(false)
tk = get_tk
@@ -2123,19 +2123,19 @@ module RDoc
get_tk
end
end
-
+
# Return a superclass, which can be either a constant
# of an expression
def get_class_specification
tk = get_tk
return "self" if tk.kind_of?(TkSELF)
-
+
res = ""
while tk.kind_of?(TkCOLON2) ||
tk.kind_of?(TkCOLON3) ||
- tk.kind_of?(TkCONSTANT)
-
+ tk.kind_of?(TkCONSTANT)
+
res += tk.text
tk = get_tk
end
@@ -2206,21 +2206,21 @@ module RDoc
while tk.kind_of?(TkCOLON2) ||
tk.kind_of?(TkCOLON3) ||
- tk.kind_of?(TkCONSTANT)
-
+ tk.kind_of?(TkCONSTANT)
+
res += tk.text
tk = get_tk
end
# if res.empty?
# warn("Unexpected token #{tk} in constant")
-# end
+# end
unget_tk(tk)
res
end
# Get a constant that may be surrounded by parens
-
+
def get_constant_with_optional_parens
skip_tkspace(false)
nest = 0
@@ -2250,12 +2250,12 @@ module RDoc
# class SM # :nodoc:
#
# we return the directive name and any parameters as a two element array
-
+
def read_directive(allowed)
tk = get_tk
puts "directive: #{tk.inspect}" if $DEBUG
result = nil
- if tk.kind_of?(TkCOMMENT)
+ if tk.kind_of?(TkCOMMENT)
if tk.text =~ /\s*:?(\w+):\s*(.*)/
directive = $1.downcase
if allowed.include?(directive)
@@ -2268,7 +2268,7 @@ module RDoc
result
end
-
+
def read_documentation_modifiers(context, allow)
dir = read_directive(allow)
@@ -2298,11 +2298,11 @@ module RDoc
end if dir
end
-
+
# Look for directives in a normal comment block:
#
# #-- - don't display comment from this point forward
- #
+ #
#
# This routine modifies it's parameter
@@ -2339,7 +2339,7 @@ module RDoc
when "section"
context.set_current_section(param, comment)
comment.replace("") # 1.8 doesn't support #clear
- break
+ break
else
warn "Unrecognized directive '#{directive}'"
break
@@ -2369,7 +2369,7 @@ module RDoc
raise "Name or symbol expected (got #{tk})"
end
end
-
+
def parse_alias(context, single, tk, comment)
skip_tkspace
if (peek_tk.kind_of? TkLPAREN)
@@ -2475,7 +2475,7 @@ module RDoc
end
else
warn("'attr' ignored - looks like a variable")
- end
+ end
end
@@ -2493,7 +2493,7 @@ module RDoc
:public
else raise "Invalid visibility: #{tk.name}"
end
-
+
skip_tkspace_comment(false)
case peek_tk
# Ryan Davis suggested the extension to ignore modifiers, because he
@@ -2502,7 +2502,7 @@ module RDoc
# protected unless $TESTING
#
when TkNL, TkUNLESS_MOD, TkIF_MOD
-# error("Missing argument") if singleton
+# error("Missing argument") if singleton
container.ongoing_visibility = vis
else
args = parse_symbol_arg
@@ -2528,11 +2528,11 @@ module RDoc
else
rw = @options.extra_accessor_flags[tk.name]
end
-
+
for name in args
att = Attr.new(get_tkread, name, rw, comment)
context.add_attribute(att)
- end
+ end
end
def skip_tkspace_comment(skip_nl = true)
@@ -2555,7 +2555,7 @@ module RDoc
args.push tk1
break if no and args.size >= no
end
-
+
skip_tkspace_comment
case tk2 = get_tk
when TkRPAREN
@@ -2578,11 +2578,11 @@ module RDoc
skip_tkspace(false)
tk1 = get_tk
- unless tk1.kind_of?(TkCOMMA)
+ unless tk1.kind_of?(TkCOMMA)
unget_tk tk1
break
end
-
+
skip_tkspace_comment
if tk = parse_symbol_in_arg
args.push tk
diff --git a/lib/rdoc/parsers/parse_simple.rb b/lib/rdoc/parsers/parse_simple.rb
index 3f1a546964..6f9eea706a 100644
--- a/lib/rdoc/parsers/parse_simple.rb
+++ b/lib/rdoc/parsers/parse_simple.rb
@@ -1,4 +1,4 @@
-# Parse a non-source file. We basically take the whole thing
+# Parse a non-source file. We basically take the whole thing
# as one big comment. If the first character in the file
# is '#', we strip leading pound signs.
@@ -10,24 +10,24 @@ module RDoc
# See rdoc/parsers/parse_c.rb
class SimpleParser
-
+
# prepare to parse a plain file
def initialize(top_level, file_name, body, options, stats)
-
+
preprocess = SM::PreProcess.new(file_name, options.rdoc_include)
-
+
preprocess.handle(body) do |directive, param|
$stderr.puts "Unrecognized directive '#{directive}' in #{file_name}"
end
-
+
@body = body
@options = options
@top_level = top_level
end
-
+
# Extract the file contents and attach them to the toplevel as a
# comment
-
+
def scan
# @body.gsub(/^(\s\n)+/, '')
@top_level.comment = remove_private_comments(@body)
diff --git a/lib/rdoc/parsers/parserfactory.rb b/lib/rdoc/parsers/parserfactory.rb
index 00a82cf4b1..064d48e11d 100644
--- a/lib/rdoc/parsers/parserfactory.rb
+++ b/lib/rdoc/parsers/parserfactory.rb
@@ -15,23 +15,23 @@ module RDoc
# to return an appropriately parsed TopLevel code object.
#
# The ParseFactory is used to redirect to the correct parser given a filename
- # extension. This magic works because individual parsers have to register
+ # extension. This magic works because individual parsers have to register
# themselves with us as they are loaded in. The do this using the following
# incantation
#
#
# require "rdoc/parsers/parsefactory"
- #
+ #
# module RDoc
- #
+ #
# class XyzParser
# extend ParseFactory <<<<
# parse_files_matching /\.xyz$/ <<<<
- #
+ #
# def initialize(file_name, body, options)
# ...
# end
- #
+ #
# def scan
# ...
# end
@@ -74,7 +74,7 @@ module RDoc
true
end
- # Find the correct parser for a particular file name. Return a
+ # Find the correct parser for a particular file name. Return a
# SimpleParser for ones that we don't know
def ParserFactory.parser_for(top_level, file_name, body, options, stats)
@@ -88,7 +88,7 @@ module RDoc
end
parser_description = can_parse(file_name)
if parser_description
- parser = parser_description.parser
+ parser = parser_description.parser
else
parser = SimpleParser
end
diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb
index 91f5611196..63afe4211a 100644
--- a/lib/rdoc/rdoc.rb
+++ b/lib/rdoc/rdoc.rb
@@ -1,6 +1,6 @@
# See README.
#
-
+
VERSION_STRING = %{RDoc V1.0.1 - 20041108}
@@ -62,17 +62,17 @@ module RDoc
# rdoc.document(args)
#
# where _args_ is an array of strings, each corresponding to
- # an argument you'd give rdoc on the command line. See rdoc/rdoc.rb
+ # an argument you'd give rdoc on the command line. See rdoc/rdoc.rb
# for details.
-
+
class RDoc
##
# This is the list of output generators that we
# support
-
+
Generator = Struct.new(:file_name, :class_name, :key)
-
+
GENERATORS = {}
$:.collect {|d|
File::expand_path(d)
@@ -88,7 +88,7 @@ module RDoc
type)
end
}
- }
+ }
#######
private
@@ -96,22 +96,22 @@ module RDoc
##
# Report an error message and exit
-
+
def error(msg)
raise RDocError.new(msg)
end
-
+
##
# Create an output dir if it doesn't exist. If it does
# exist, but doesn't contain the flag file <tt>created.rid</tt>
# then we refuse to use it, as we may clobber some
# manually generated documentation
-
+
def setup_output_dir(op_dir, force)
flag_file = output_flag_file(op_dir)
if File.exist?(op_dir)
unless File.directory?(op_dir)
- error "'#{op_dir}' exists, and is not a directory"
+ error "'#{op_dir}' exists, and is not a directory"
end
begin
created = File.read(flag_file)
@@ -158,12 +158,12 @@ module RDoc
# Given a list of files and directories, create a list
- # of all the Ruby files they contain.
+ # of all the Ruby files they contain.
#
# If +force_doc+ is true, we always add the given files.
# If false, only add files that we guarantee we can parse
# It is true when looking at files given on the command line,
- # false when recursing through subdirectories.
+ # false when recursing through subdirectories.
#
# The effect of this is that if you want a file with a non-
# standard extension parsed, you must name it explicity.
@@ -208,7 +208,7 @@ module RDoc
# directories
def parse_files(options)
-
+
file_info = []
files = options.files
@@ -218,7 +218,7 @@ module RDoc
file_list.each do |fn|
$stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
-
+
content = File.open(fn, "r") {|f| f.read}
top_level = TopLevel.new(fn)
diff --git a/lib/rdoc/ri/ri_cache.rb b/lib/rdoc/ri/ri_cache.rb
index 1844ac969e..9e91803f56 100644
--- a/lib/rdoc/ri/ri_cache.rb
+++ b/lib/rdoc/ri/ri_cache.rb
@@ -4,7 +4,7 @@ module RI
attr_reader :name
attr_reader :path_names
-
+
def initialize(path_name, name, in_class)
@path_names = [ path_name ]
@name = name
@@ -137,7 +137,7 @@ module RI
end
def module_named(name)
-
+
end
end
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb
index e5ea9f2fbf..fdcbd9cb82 100644
--- a/lib/rdoc/ri/ri_descriptions.rb
+++ b/lib/rdoc/ri/ri_descriptions.rb
@@ -76,9 +76,9 @@ module RI
@name <=> other.name
end
end
-
+
class ModuleDescription < Description
-
+
attr_accessor :class_methods
attr_accessor :instance_methods
attr_accessor :attributes
@@ -121,7 +121,7 @@ module RI
into.replace(names.keys.sort.map {|n| names[n]})
end
end
-
+
class ClassDescription < ModuleDescription
attr_accessor :superclass
@@ -140,7 +140,7 @@ module RI
class MethodDescription < Description
-
+
attr_accessor :is_class_method
attr_accessor :visibility
attr_accessor :block_params
@@ -150,5 +150,5 @@ module RI
attr_accessor :params
end
-
+
end
diff --git a/lib/rdoc/ri/ri_display.rb b/lib/rdoc/ri/ri_display.rb
index 67962fc2c1..a4669559b7 100644
--- a/lib/rdoc/ri/ri_display.rb
+++ b/lib/rdoc/ri/ri_display.rb
@@ -7,7 +7,7 @@ require 'rdoc/ri/ri_options'
# own 'ri' display module (perhaps because you'r writing
# an IDE or somesuch beast), you simply write a class
# which implements the various 'display' methods in 'DefaultDisplay',
-# and include the 'RiDisplay' module in that class.
+# and include the 'RiDisplay' module in that class.
#
# To access your class from the command line, you can do
#
@@ -41,11 +41,11 @@ class DefaultDisplay
def initialize(options)
@options = options
@formatter = @options.formatter.new(@options, " ")
- end
-
-
+ end
+
+
######################################################################
-
+
def display_usage
page do
RI::Options::OptionList.usage(short_form=true)
@@ -54,7 +54,7 @@ class DefaultDisplay
######################################################################
-
+
def display_method_info(method)
page do
@formatter.draw_line(method.full_name)
@@ -64,31 +64,31 @@ class DefaultDisplay
if method.aliases && !method.aliases.empty?
@formatter.blankline
aka = "(also known as "
- aka << method.aliases.map {|a| a.name }.join(", ")
+ aka << method.aliases.map {|a| a.name }.join(", ")
aka << ")"
@formatter.wrap(aka)
end
end
end
-
+
######################################################################
-
+
def display_class_info(klass, ri_reader)
- page do
+ page do
superclass = klass.superclass_string
-
+
if superclass
superclass = " < " + superclass
else
superclass = ""
end
-
+
@formatter.draw_line(klass.display_name + ": " +
klass.full_name + superclass)
-
+
display_flow(klass.comment)
- @formatter.draw_line
-
+ @formatter.draw_line
+
unless klass.includes.empty?
@formatter.blankline
@formatter.display_heading("Includes:", 2, "")
@@ -106,7 +106,7 @@ class DefaultDisplay
end
@formatter.wrap(incs.sort.join(', '))
end
-
+
unless klass.constants.empty?
@formatter.blankline
@formatter.display_heading("Constants:", 2, "")
@@ -114,23 +114,23 @@ class DefaultDisplay
klass.constants.each { |c| len = c.name.length if c.name.length > len }
len += 2
klass.constants.each do |c|
- @formatter.wrap(c.value,
+ @formatter.wrap(c.value,
@formatter.indent+((c.name+":").ljust(len)))
- end
+ end
end
-
+
unless klass.class_methods.empty?
@formatter.blankline
@formatter.display_heading("Class methods:", 2, "")
@formatter.wrap(klass.class_methods.map{|m| m.name}.sort.join(', '))
end
-
+
unless klass.instance_methods.empty?
@formatter.blankline
@formatter.display_heading("Instance methods:", 2, "")
@formatter.wrap(klass.instance_methods.map{|m| m.name}.sort.join(', '))
end
-
+
unless klass.attributes.empty?
@formatter.blankline
@formatter.wrap("Attributes:", "")
@@ -138,11 +138,11 @@ class DefaultDisplay
end
end
end
-
+
######################################################################
-
+
# Display a list of method names
-
+
def display_method_list(methods)
page do
puts "More than one method matched your request. You can refine"
@@ -150,9 +150,9 @@ class DefaultDisplay
@formatter.wrap(methods.map {|m| m.full_name} .join(", "))
end
end
-
+
######################################################################
-
+
def display_class_list(namespaces)
page do
puts "More than one class or module matched your request. You can refine"
@@ -160,14 +160,14 @@ class DefaultDisplay
@formatter.wrap(namespaces.map {|m| m.full_name}.join(", "))
end
end
-
+
######################################################################
def list_known_classes(classes)
if classes.empty?
warn_no_database
else
- page do
+ page do
@formatter.draw_line("Known classes and modules")
@formatter.blankline
@formatter.wrap(classes.sort.join(", "))
@@ -181,7 +181,7 @@ class DefaultDisplay
if names.empty?
warn_no_database
else
- page do
+ page do
names.each {|n| @formatter.raw_print_line(n)}
end
end
@@ -219,7 +219,7 @@ class DefaultDisplay
end
######################################################################
-
+
def display_params(method)
params = method.params
@@ -232,12 +232,12 @@ class DefaultDisplay
end
end
params.split(/\n/).each do |p|
- @formatter.wrap(p)
+ @formatter.wrap(p)
@formatter.break_to_newline
end
end
######################################################################
-
+
def display_flow(flow)
if !flow || flow.empty?
@formatter.wrap("(no description...)")
@@ -247,7 +247,7 @@ class DefaultDisplay
end
######################################################################
-
+
def warn_no_database
puts "Before using ri, you need to generate documentation"
puts "using 'rdoc' with the --ri option"
diff --git a/lib/rdoc/ri/ri_driver.rb b/lib/rdoc/ri/ri_driver.rb
index a00f20ee3b..8d0b90e674 100644
--- a/lib/rdoc/ri/ri_driver.rb
+++ b/lib/rdoc/ri/ri_driver.rb
@@ -27,7 +27,7 @@ class RiDriver
@ri_reader = RI::RiReader.new(RI::RiCache.new(path))
@display = @options.displayer
end
-
+
# Couldn't find documentation in +path+, so tell the user what to do
def report_missing_documentation(path)
@@ -38,14 +38,14 @@ class RiDriver
STDERR.puts "\nWas rdoc run to create documentation?\n\n"
RDoc::usage("Installing Documentation")
end
-
+
######################################################################
-
+
# If the list of matching methods contains exactly one entry, or
# if it contains an entry that exactly matches the requested method,
# then display that entry, otherwise display the list of
# matching method names
-
+
def report_method_stuff(requested_method_name, methods)
if methods.size == 1
method = @ri_reader.get_method(methods[0])
@@ -60,14 +60,14 @@ class RiDriver
end
end
end
-
+
######################################################################
-
+
def report_class_stuff(namespaces)
if namespaces.size == 1
klass = @ri_reader.get_class(namespaces[0])
@display.display_class_info(klass, @ri_reader)
- else
+ else
# entries = namespaces.find_all {|m| m.full_name == requested_class_name}
# if entries.size == 1
# klass = @ri_reader.get_class(entries[0])
@@ -77,15 +77,15 @@ class RiDriver
# end
end
end
-
+
######################################################################
-
-
+
+
def get_info_for(arg)
desc = NameDescriptor.new(arg)
namespaces = @ri_reader.top_level_namespace
-
+
for class_name in desc.class_names
namespaces = @ri_reader.lookup_namespace_in(class_name, namespaces)
if namespaces.empty?
@@ -103,7 +103,7 @@ class RiDriver
if desc.method_name.nil?
report_class_stuff(namespaces)
else
- methods = @ri_reader.find_methods(desc.method_name,
+ methods = @ri_reader.find_methods(desc.method_name,
desc.is_class_method,
namespaces)
diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb
index 34eb561ca3..3ddba118e9 100644
--- a/lib/rdoc/ri/ri_formatter.rb
+++ b/lib/rdoc/ri/ri_formatter.rb
@@ -2,29 +2,29 @@ module RI
class TextFormatter
attr_reader :indent
-
+
def initialize(options, indent)
@options = options
@width = options.width
@indent = indent
end
-
-
+
+
######################################################################
-
+
def draw_line(label=nil)
len = @width
len -= (label.size+1) if label
print "-"*len
if label
print(" ")
- bold_print(label)
+ bold_print(label)
end
puts
end
-
+
######################################################################
-
+
def wrap(txt, prefix=@indent, linelen=@width)
return unless txt && !txt.empty?
work = conv_markup(txt)
@@ -51,7 +51,7 @@ module RI
def blankline
puts
end
-
+
######################################################################
# called when we want to ensure a nbew 'wrap' starts on a newline
@@ -60,7 +60,7 @@ module RI
def break_to_newline
end
-
+
######################################################################
def bold_print(txt)
@@ -82,7 +82,7 @@ module RI
gsub(/&lt;/, '<').
gsub(/&quot;/, '"').
gsub(/&amp;/, '&')
-
+
end
# convert markup into display form
@@ -99,7 +99,7 @@ module RI
def display_list(list)
case list.type
- when SM::ListBase::BULLET
+ when SM::ListBase::BULLET
prefixer = proc { |ignored| @indent + "* " }
when SM::ListBase::NUMBER,
@@ -116,7 +116,7 @@ module RI
start = start.succ
res
end
-
+
when SM::ListBase::LABELED
prefixer = proc do |li|
li.label
@@ -156,7 +156,7 @@ module RI
when SM::Flow::P, SM::Flow::LI
wrap(conv_html(item.body), prefix)
blankline
-
+
when SM::Flow::LIST
display_list(item)
@@ -194,7 +194,7 @@ module RI
puts text.upcase
puts ul
# puts
-
+
when 2
ul = "-" * text.length
puts
@@ -215,7 +215,7 @@ module RI
def strip_attributes(txt)
tokens = txt.split(%r{(</?(?:b|code|em|i|tt)>)})
- text = []
+ text = []
attributes = 0
tokens.each do |tok|
case tok
@@ -230,16 +230,16 @@ module RI
end
-
-
+
+
######################################################################
# Handle text with attributes. We're a base class: there are
# different presentation classes (one, for example, uses overstrikes
# to handle bold and underlining, while another using ANSI escape
# sequences
-
+
class AttributeFormatter < TextFormatter
-
+
BOLD = 1
ITALIC = 2
CODE = 4
@@ -263,7 +263,7 @@ module RI
end
end
-
+
class AttributeString
attr_reader :txt
@@ -363,7 +363,7 @@ module RI
##################################################
-
+
# This formatter generates overstrike-style formatting, which
# works with pagers such as man and less.
@@ -395,7 +395,7 @@ module RI
end
##################################################
-
+
# This formatter uses ANSI escape sequences
# to colorize stuff
# works with pages such as man and less.
@@ -441,7 +441,7 @@ module RI
print strip_attributes(text)
puts heading[1]
end
-
+
private
ATTR_MAP = {
@@ -462,7 +462,7 @@ module RI
end
##################################################
-
+
# This formatter uses HTML.
class HtmlFormatter < AttributeFormatter
@@ -508,13 +508,13 @@ module RI
tag("h#{level}") { text }
puts
end
-
+
######################################################################
def display_list(list)
case list.type
- when SM::ListBase::BULLET
+ when SM::ListBase::BULLET
list_type = "ul"
prefixer = proc { |ignored| "<li>" }
@@ -523,7 +523,7 @@ module RI
SM::ListBase::LOWERALPHA
list_type = "ol"
prefixer = proc { |ignored| "<li>" }
-
+
when SM::ListBase::LABELED
list_type = "dl"
prefixer = proc do |li|
@@ -602,7 +602,7 @@ module RI
end
##################################################
-
+
# This formatter reduces extra lines for a simpler output.
# It improves way output looks for tools like IRC bots.
@@ -621,7 +621,7 @@ module RI
def draw_line(label=nil)
unless label.nil? then
- bold_print(label)
+ bold_print(label)
puts
end
end
@@ -656,7 +656,7 @@ module RI
"plain" => TextFormatter,
"simple" => SimpleFormatter,
}
-
+
def TextFormatter.list
FORMATTERS.keys.sort.join(", ")
end
diff --git a/lib/rdoc/ri/ri_options.rb b/lib/rdoc/ri/ri_options.rb
index 179ef96cea..466c0576db 100644
--- a/lib/rdoc/ri/ri_options.rb
+++ b/lib/rdoc/ri/ri_options.rb
@@ -9,10 +9,10 @@ module RI
VERSION_STRING = "ri v1.0.1 - 20041108"
class Options
-
+
require 'singleton'
require 'getoptlong'
-
+
include Singleton
# No not use a pager. Writable, because ri sets it if it
@@ -35,7 +35,7 @@ module RI
attr_reader :doc_dir
module OptionList
-
+
OPTION_LIST = [
[ "--help", "-h", nil,
"you're looking at it" ],
@@ -80,7 +80,7 @@ module RI
],
[ "--no-pager", "-T", nil,
- "Send output directly to stdout."
+ "Send output directly to stdout."
],
[ "--width", "-w", "output width",
@@ -110,10 +110,10 @@ module RI
text.gsub!(/^#{leading_spaces}/, '')
$stdout.puts text
end
-
-
+
+
# Show an error and exit
-
+
def OptionList.error(msg)
$stderr.puts
$stderr.puts msg
@@ -121,15 +121,15 @@ module RI
$stderr.puts "\nFor help on options, try '#{name} --help'\n\n"
exit 1
end
-
+
# Show usage and exit
-
+
def OptionList.usage(short_form=false)
-
+
puts
puts(RI::VERSION_STRING)
puts
-
+
name = File.basename($0)
directories = [
@@ -225,7 +225,7 @@ module RI
def initialize
@use_stdout = !STDOUT.tty?
@width = 72
- @formatter = RI::TextFormatter.for("plain")
+ @formatter = RI::TextFormatter.for("plain")
@list_classes = false
@list_names = false
@@ -241,7 +241,7 @@ module RI
# Parse command line options.
def parse(args)
-
+
old_argv = ARGV.dup
ARGV.replace(args)
@@ -282,7 +282,7 @@ module RI
when "--width"
begin
@width = Integer(arg)
- rescue
+ rescue
$stderr.puts "Invalid width: '#{arg}'"
exit 1
end
@@ -309,7 +309,7 @@ module RI
# Return an instance of the displayer (the thing that actually writes
# the information). This allows us to load in new displayer classes
# at runtime (for example to help with IDE integration)
-
+
def displayer
::RiDisplay.new(self)
end
diff --git a/lib/rdoc/ri/ri_paths.rb b/lib/rdoc/ri/ri_paths.rb
index 9768f12b7d..1af4739061 100644
--- a/lib/rdoc/ri/ri_paths.rb
+++ b/lib/rdoc/ri/ri_paths.rb
@@ -23,7 +23,7 @@ module RI
#:stopdoc:
require 'rbconfig'
-
+
DOC_DIR = "doc/rdoc"
version = Config::CONFIG['ruby_version']
diff --git a/lib/rdoc/ri/ri_util.rb b/lib/rdoc/ri/ri_util.rb
index 8a01255897..66c70ac653 100644
--- a/lib/rdoc/ri/ri_util.rb
+++ b/lib/rdoc/ri/ri_util.rb
@@ -38,7 +38,7 @@ class NameDescriptor
# Skip leading '::', but remember we potentially have an inst
# leading stuff must be class names
-
+
while tokens[0] =~ /^[A-Z]/
@class_names << tokens.shift
unless tokens.empty?
@@ -46,7 +46,7 @@ class NameDescriptor
break unless separator == "::"
end
end
-
+
# Now must have a single token, the method name, or an empty
# array
unless tokens.empty?
@@ -58,7 +58,7 @@ class NameDescriptor
end
if @method_name =~ /::|\.|#/ or !tokens.empty?
- raise RiError.new("Bad argument: #{arg}")
+ raise RiError.new("Bad argument: #{arg}")
end
if separator && separator != '.'
@is_class_method = separator == "::"
diff --git a/lib/rdoc/ri/ri_writer.rb b/lib/rdoc/ri/ri_writer.rb
index 78c68e8409..a4f5db53a3 100644
--- a/lib/rdoc/ri/ri_writer.rb
+++ b/lib/rdoc/ri/ri_writer.rb
@@ -7,7 +7,7 @@ module RI
File.join(dir, "cdesc-" + class_desc.name + ".yaml")
end
-
+
# Convert a name from internal form (containing punctuation)
# to an external form (where punctuation is replaced
# by %xx)
diff --git a/lib/rdoc/template.rb b/lib/rdoc/template.rb
index 469e10fb4b..4bf77b750e 100644
--- a/lib/rdoc/template.rb
+++ b/lib/rdoc/template.rb
@@ -1,4 +1,4 @@
-# Cheap-n-cheerful HTML page template system. You create a
+# Cheap-n-cheerful HTML page template system. You create a
# template containing:
#
# * variable names between percent signs (<tt>%fred%</tt>)
@@ -88,7 +88,7 @@ class TemplatePage
@lines = lines
end
- # read the next line
+ # read the next line
def read
@lines.shift
end
@@ -99,7 +99,7 @@ class TemplatePage
res = []
while line = read
if pattern.match(line)
- return LineReader.new(res)
+ return LineReader.new(res)
else
res << line
end
@@ -137,7 +137,7 @@ class TemplatePage
@lines = LineReader.new(result.split($/))
end
- # Render the templates into HTML, storing the result on +op+
+ # Render the templates into HTML, storing the result on +op+
# using the method <tt><<</tt>. The <tt>value_hash</tt> contains
# key/value pairs used to drive the substitution (as described above)
@@ -147,10 +147,10 @@ class TemplatePage
end
- # Substitute a set of key/value pairs into the given template.
+ # Substitute a set of key/value pairs into the given template.
# Keys with scalar values have them substituted directly into
# the page. Those with array values invoke <tt>substitute_array</tt>
- # (below), which examples a block of the template once for each
+ # (below), which examples a block of the template once for each
# row in the array.
#
# This routine also copes with the <tt>IF:</tt>_key_ directive,
@@ -195,7 +195,7 @@ class TemplatePage
result.join("\n")
end
- # Given an individual line, we look for %xxx% constructs and
+ # Given an individual line, we look for %xxx% constructs and
# HREF:ref:name: constructs, substituting for each.
def expand_line(line)
@@ -218,7 +218,7 @@ class TemplatePage
# meaningful to the regexp (like \1)
line = line.gsub(/%([a-zA-Z]\w*)%/) {
- val = @context.find_scalar($1)
+ val = @context.find_scalar($1)
val.tr('\\', "\000")
}
diff --git a/lib/rdoc/usage.rb b/lib/rdoc/usage.rb
index def516b3d7..b11abda8e3 100644
--- a/lib/rdoc/usage.rb
+++ b/lib/rdoc/usage.rb
@@ -48,12 +48,12 @@
#
# # Display information in the Author and Copyright
# # sections, then exit 0.
-#
+#
# RDoc::usage('Author', 'Copyright')
#
# # Display information in the Author and Copyright
# # sections, but don't exit
-#
+#
# RDoc::usage_no_exit('Author', 'Copyright')
#
# = Author
@@ -105,7 +105,7 @@ module RDoc
markup = SM::SimpleMarkup.new
flow_convertor = SM::ToFlow.new
-
+
flow = markup.convert(comment, flow_convertor)
format = "plain"
diff --git a/lib/readbytes.rb b/lib/readbytes.rb
index ebb5fc0bd4..f6ff8fb2fb 100644
--- a/lib/readbytes.rb
+++ b/lib/readbytes.rb
@@ -23,7 +23,7 @@ class IO
raise EOFError, "End of file reached"
end
if str.size < n
- raise TruncatedDataError.new("data truncated", str)
+ raise TruncatedDataError.new("data truncated", str)
end
str
end
diff --git a/lib/rexml/attlistdecl.rb b/lib/rexml/attlistdecl.rb
index ef4721b5ce..817fef32e5 100644
--- a/lib/rexml/attlistdecl.rb
+++ b/lib/rexml/attlistdecl.rb
@@ -31,7 +31,7 @@ module REXML
@element_name, @pairs, @contents = *source
end
end
-
+
# Access the attlist attribute/value pairs.
# value = attlist_decl[ attribute_name ]
def [](key)
diff --git a/lib/rexml/attribute.rb b/lib/rexml/attribute.rb
index 89c1ada36c..489e72d585 100644
--- a/lib/rexml/attribute.rb
+++ b/lib/rexml/attribute.rb
@@ -14,24 +14,24 @@ module REXML
attr_reader :element
# The normalized value of this attribute. That is, the attribute with
# entities intact.
- attr_writer :normalized
+ attr_writer :normalized
PATTERN = /\s*(#{NAME_STR})\s*=\s*(["'])(.*?)\2/um
# Constructor.
# FIXME: The parser doesn't catch illegal characters in attributes
#
- # first::
+ # first::
# Either: an Attribute, which this new attribute will become a
# clone of; or a String, which is the name of this attribute
# second::
# If +first+ is an Attribute, then this may be an Element, or nil.
# If nil, then the Element parent of this attribute is the parent
- # of the +first+ Attribute. If the first argument is a String,
- # then this must also be a String, and is the content of the attribute.
+ # of the +first+ Attribute. If the first argument is a String,
+ # then this must also be a String, and is the content of the attribute.
# If this is the content, it must be fully normalized (contain no
# illegal characters).
# parent::
- # Ignored unless +first+ is a String; otherwise, may be the Element
+ # Ignored unless +first+ is a String; otherwise, may be the Element
# parent of this attribute, or nil.
#
#
@@ -59,7 +59,7 @@ module REXML
end
# Returns the namespace of the attribute.
- #
+ #
# e = Element.new( "elns:myelement" )
# e.add_attribute( "nsa:a", "aval" )
# e.add_attribute( "b", "bval" )
@@ -76,7 +76,7 @@ module REXML
end
# Returns the namespace URL, if defined, or nil otherwise
- #
+ #
# e = Element.new("el")
# e.add_attributes({"xmlns:ns", "http://url"})
# e.namespace( "ns" ) # -> "http://url"
@@ -154,7 +154,7 @@ module REXML
end
# Removes this Attribute from the tree, and returns true if successfull
- #
+ #
# This method is usually not called directly.
def remove
@element.attributes.delete self.name unless @element.nil?
diff --git a/lib/rexml/cdata.rb b/lib/rexml/cdata.rb
index efcb71160a..7743c7b8bb 100644
--- a/lib/rexml/cdata.rb
+++ b/lib/rexml/cdata.rb
@@ -17,7 +17,7 @@ module REXML
end
# Make a copy of this object
- #
+ #
# _Examples_
# c = CData.new( "Some text" )
# d = c.clone
diff --git a/lib/rexml/child.rb b/lib/rexml/child.rb
index 6d3c9df5e6..e6cd841470 100644
--- a/lib/rexml/child.rb
+++ b/lib/rexml/child.rb
@@ -15,8 +15,8 @@ module REXML
# if supplied, the parent of this child will be set to the
# supplied value, and self will be added to the parent
def initialize( parent = nil )
- @parent = nil
- # Declare @parent, but don't define it. The next line sets the
+ @parent = nil
+ # Declare @parent, but don't define it. The next line sets the
# parent.
parent.add( self ) if parent
end
@@ -68,7 +68,7 @@ module REXML
parent.insert_after self, other
end
- # Sets the previous sibling of this child. This can be used to insert a
+ # Sets the previous sibling of this child. This can be used to insert a
# child before some other child.
# a = Element.new("a")
# b = a.add_element("b")
diff --git a/lib/rexml/comment.rb b/lib/rexml/comment.rb
index 2b9b4b89c9..2cd69a111b 100644
--- a/lib/rexml/comment.rb
+++ b/lib/rexml/comment.rb
@@ -14,11 +14,11 @@ module REXML
##
# Constructor. The first argument can be one of three types:
- # @param first If String, the contents of this comment are set to the
+ # @param first If String, the contents of this comment are set to the
# argument. If Comment, the argument is duplicated. If
# Source, the argument is scanned for a comment.
- # @param second If the first argument is a Source, this argument
- # should be nil, not supplied, or a Parent to be set as the parent
+ # @param second If the first argument is a Source, this argument
+ # should be nil, not supplied, or a Parent to be set as the parent
# of this object
def initialize( first, second = nil )
#puts "IN COMMENT CONSTRUCTOR; SECOND IS #{second.type}"
diff --git a/lib/rexml/doctype.rb b/lib/rexml/doctype.rb
index 05cd4ab331..f41fe600b5 100644
--- a/lib/rexml/doctype.rb
+++ b/lib/rexml/doctype.rb
@@ -15,11 +15,11 @@ module REXML
STOP = ">"
SYSTEM = "SYSTEM"
PUBLIC = "PUBLIC"
- DEFAULT_ENTITIES = {
- 'gt'=>EntityConst::GT,
- 'lt'=>EntityConst::LT,
- 'quot'=>EntityConst::QUOT,
- "apos"=>EntityConst::APOS
+ DEFAULT_ENTITIES = {
+ 'gt'=>EntityConst::GT,
+ 'lt'=>EntityConst::LT,
+ 'quot'=>EntityConst::QUOT,
+ "apos"=>EntityConst::APOS
}
# name is the name of the doctype
@@ -33,7 +33,7 @@ module REXML
# dt = DocType.new( doctype_to_clone )
# # Incomplete. Shallow clone of doctype
#
- # +Note+ that the constructor:
+ # +Note+ that the constructor:
#
# Doctype.new( Source.new( "<!DOCTYPE foo 'bar'>" ) )
#
@@ -140,8 +140,8 @@ module REXML
@entities = DEFAULT_ENTITIES.clone if @entities == DEFAULT_ENTITIES
@entities[ child.name ] = child if child.kind_of? Entity
end
-
- # This method retrieves the public identifier identifying the document's
+
+ # This method retrieves the public identifier identifying the document's
# DTD.
#
# Method contributed by Henrik Martensson
@@ -153,7 +153,7 @@ module REXML
strip_quotes(@long_name)
end
end
-
+
# This method retrieves the system identifier identifying the document's DTD
#
# Method contributed by Henrik Martensson
@@ -165,16 +165,16 @@ module REXML
@uri.kind_of?(String) ? strip_quotes(@uri) : nil
end
end
-
+
# This method returns a list of notations that have been declared in the
- # _internal_ DTD subset. Notations in the external DTD subset are not
+ # _internal_ DTD subset. Notations in the external DTD subset are not
# listed.
#
# Method contributed by Henrik Martensson
def notations
children().select {|node| node.kind_of?(REXML::NotationDecl)}
end
-
+
# Retrieves a named notation. Only notations declared in the internal
# DTD subset can be retrieved.
#
@@ -184,9 +184,9 @@ module REXML
notation_decl.name == name
}
end
-
+
private
-
+
# Method contributed by Henrik Martensson
def strip_quotes(quoted_string)
quoted_string =~ /^[\'\"].*[\´\"]$/ ?
@@ -218,7 +218,7 @@ module REXML
output << to_s
end
end
-
+
public
class ElementDecl < Declaration
def initialize( src )
@@ -251,7 +251,7 @@ module REXML
def to_s
"<!NOTATION #@name #@middle#{
- @public ? ' ' + public.inspect : ''
+ @public ? ' ' + public.inspect : ''
}#{
@system ? ' ' [email protected] : ''
}>"
@@ -260,7 +260,7 @@ module REXML
def write( output, indent=-1 )
output << to_s
end
-
+
# This method retrieves the name of the notation.
#
# Method contributed by Henrik Martensson
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb
index 3d1300a06b..563dc3aa1c 100644
--- a/lib/rexml/document.rb
+++ b/lib/rexml/document.rb
@@ -25,7 +25,7 @@ module REXML
DECLARATION = XMLDecl.default
# Constructor
- # @param source if supplied, must be a Document, String, or IO.
+ # @param source if supplied, must be a Document, String, or IO.
# Documents have their context and Element attributes cloned.
# Strings are expected to be valid XML documents. IOs are expected
# to be sources of valid XML documents.
@@ -69,11 +69,11 @@ module REXML
@children.unshift child
child.parent = self
elsif child.kind_of? DocType
- # Find first Element or DocType node and insert the decl right
+ # Find first Element or DocType node and insert the decl right
# before it. If there is no such node, just insert the child at the
# end. If there is a child and it is an DocType, then replace it.
insert_before_index = 0
- @children.find { |x|
+ @children.find { |x|
insert_before_index += 1
x.kind_of?(Element) || x.kind_of?(DocType)
}
@@ -167,7 +167,7 @@ module REXML
# indent::
# An integer. If -1, no indenting will be used; otherwise, the
# indentation will be twice this number of spaces, and children will be
- # indented an additional amount. For a value of 3, every item will be
+ # indented an additional amount. For a value of 3, every item will be
# indented 3 more levels, or 6 more spaces (2 * 3). Defaults to -1
# trans::
# If transitive is true and indent is >= 0, then the output will be
@@ -178,7 +178,7 @@ module REXML
# Internet Explorer is the worst piece of crap to have ever been
# written, with the possible exception of Windows itself. Since IE is
# unable to parse proper XML, we have to provide a hack to generate XML
- # that IE's limited abilities can handle. This hack inserts a space
+ # that IE's limited abilities can handle. This hack inserts a space
# before the /> on empty tags. Defaults to false
def write( output=$stdout, indent=-1, trans=false, ie_hack=false )
if xml_decl.encoding != "UTF-8" && !output.kind_of?(Output)
@@ -196,7 +196,7 @@ module REXML
formatter.write( self, output )
end
-
+
def Document::parse_stream( source, listener )
Parsers::StreamParser.new( source, listener ).parse
end
@@ -214,7 +214,7 @@ module REXML
end
attr_reader :entity_expansion_count
-
+
def record_entity_expansion
@entity_expansion_count += 1
if @entity_expansion_count > @@entity_expansion_limit
diff --git a/lib/rexml/dtd/entitydecl.rb b/lib/rexml/dtd/entitydecl.rb
index a5f1520f2b..4dc6d967ab 100644
--- a/lib/rexml/dtd/entitydecl.rb
+++ b/lib/rexml/dtd/entitydecl.rb
@@ -49,7 +49,7 @@ module REXML
def EntityDecl.parse_source source, listener
md = source.match( PATTERN_RE, true )
thing = md[0].squeeze(" \t\n\r")
- listener.send inspect.downcase, thing
+ listener.send inspect.downcase, thing
end
end
end
diff --git a/lib/rexml/dtd/notationdecl.rb b/lib/rexml/dtd/notationdecl.rb
index a47ff8f24b..67f7b162a4 100644
--- a/lib/rexml/dtd/notationdecl.rb
+++ b/lib/rexml/dtd/notationdecl.rb
@@ -32,7 +32,7 @@ module REXML
def NotationDecl.parse_source source, listener
md = source.match( PATTERN_RE, true )
thing = md[0].squeeze(" \t\n\r")
- listener.send inspect.downcase, thing
+ listener.send inspect.downcase, thing
end
end
end
diff --git a/lib/rexml/element.rb b/lib/rexml/element.rb
index 1f443956c8..a7732ae639 100644
--- a/lib/rexml/element.rb
+++ b/lib/rexml/element.rb
@@ -30,13 +30,13 @@ module REXML
attr_accessor :context
# Constructor
- # arg::
+ # arg::
# if not supplied, will be set to the default value.
# If a String, the name of this object will be set to the argument.
- # If an Element, the object will be shallowly cloned; name,
+ # If an Element, the object will be shallowly cloned; name,
# attributes, and namespaces will be copied. Children will +not+ be
# copied.
- # parent::
+ # parent::
# if supplied, must be a Parent, and will be used as
# the parent of this object.
# context::
@@ -97,7 +97,7 @@ module REXML
self.class.new self
end
- # Evaluates to the root node of the document that this element
+ # Evaluates to the root node of the document that this element
# belongs to. If this element doesn't belong to a document, but does
# belong to another Element, the parent's root will be returned, until the
# earliest ancestor is found.
@@ -137,8 +137,8 @@ module REXML
# is the case if:
# 1. Neither :+respect_whitespace+ nor :+compress_whitespace+ has any value
# 2. The context has :+respect_whitespace+ set to :+all+ or
- # an array containing the name of this element, and
- # :+compress_whitespace+ isn't set to :+all+ or an array containing the
+ # an array containing the name of this element, and
+ # :+compress_whitespace+ isn't set to :+all+ or an array containing the
# name of this element.
# The evaluation is tested against +expanded_name+, and so is namespace
# sensitive.
@@ -162,7 +162,7 @@ module REXML
@ignore_whitespace_nodes = false
if @context
if @context[:ignore_whitespace_nodes]
- @ignore_whitespace_nodes =
+ @ignore_whitespace_nodes =
(@context[:ignore_whitespace_nodes] == :all or
@context[:ignore_whitespace_nodes].include? expanded_name)
end
@@ -206,13 +206,13 @@ module REXML
return namespaces
end
- # Evalutas to the URI for a prefix, or the empty string if no such
+ # Evalutas to the URI for a prefix, or the empty string if no such
# namespace is declared for this element. Evaluates recursively for
# ancestors. Returns the default namespace, if there is one.
- # prefix::
+ # prefix::
# the prefix to search for. If not supplied, returns the default
# namespace if one exists
- # Returns::
+ # Returns::
# the namespace URI as a String, or nil if no such namespace
# exists. If the namespace is undefined, returns an empty string
# doc = Document.new("<a xmlns='1' xmlns:y='2'><b/><c xmlns:z='3'/></a>")
@@ -235,10 +235,10 @@ module REXML
end
# Adds a namespace to this element.
- # prefix::
+ # prefix::
# the prefix string, or the namespace URI if +uri+ is not
# supplied
- # uri::
+ # uri::
# the namespace URI. May be nil, in which +prefix+ is used as
# the URI
# Evaluates to: this Element
@@ -280,12 +280,12 @@ module REXML
# Adds a child to this element, optionally setting attributes in
# the element.
- # element::
+ # element::
# optional. If Element, the element is added.
# Otherwise, a new Element is constructed with the argument (see
# Element.initialize).
- # attrs::
- # If supplied, must be a Hash containing String name,value
+ # attrs::
+ # If supplied, must be a Hash containing String name,value
# pairs, which will be used to set the attributes of the new Element.
# Returns:: the Element that was added
# el = doc.add_element 'my-tag'
@@ -302,9 +302,9 @@ module REXML
end
# Deletes a child element.
- # element::
- # Must be an +Element+, +String+, or +Integer+. If Element,
- # the element is removed. If String, the element is found (via XPath)
+ # element::
+ # Must be an +Element+, +String+, or +Integer+. If Element,
+ # the element is removed. If String, the element is found (via XPath)
# and removed. <em>This means that any parent can remove any
# descendant.<em> If Integer, the Element indexed by that number will be
# removed.
@@ -327,14 +327,14 @@ module REXML
# Iterates through the child elements, yielding for each Element that
# has a particular attribute set.
- # key::
+ # key::
# the name of the attribute to search for
- # value::
+ # value::
# the value of the attribute
- # max::
- # (optional) causes this method to return after yielding
+ # max::
+ # (optional) causes this method to return after yielding
# for this number of matching children
- # name::
+ # name::
# (optional) if supplied, this is an XPath that filters
# the children to check.
#
@@ -348,7 +348,7 @@ module REXML
# # Yields d
# doc.root.each_element_with_attribute( 'id', '1', 0, 'd' ) {|e| p e}
def each_element_with_attribute( key, value=nil, max=0, name=nil, &block ) # :yields: Element
- each_with_something( proc {|child|
+ each_with_something( proc {|child|
if value.nil?
child.attributes[key] != nil
else
@@ -359,13 +359,13 @@ module REXML
# Iterates through the children, yielding for each Element that
# has a particular text set.
- # text::
+ # text::
# the text to search for. If nil, or not supplied, will iterate
# over all +Element+ children that contain at least one +Text+ node.
- # max::
+ # max::
# (optional) causes this method to return after yielding
# for this number of matching children
- # name::
+ # name::
# (optional) if supplied, this is an XPath that filters
# the children to check.
#
@@ -379,7 +379,7 @@ module REXML
# # Yields d
# doc.each_element_with_text(nil, 0, 'd'){|e|p e}
def each_element_with_text( text=nil, max=0, name=nil, &block ) # :yields: Element
- each_with_something( proc {|child|
+ each_with_something( proc {|child|
if text.nil?
child.has_text?
else
@@ -408,7 +408,7 @@ module REXML
# doc.root.elements['c'].next_element #-> nil
def next_element
element = next_sibling
- element = element.next_sibling until element.nil? or element.kind_of? Element
+ element = element.next_sibling until element.nil? or element.kind_of? Element
return element
end
@@ -477,7 +477,7 @@ module REXML
# this method with a nil argument. In this case, the next Text
# child becomes the first Text child. In no case is the order of
# any siblings disturbed.
- # text::
+ # text::
# If a String, a new Text child is created and added to
# this Element as the first Text child. If Text, the text is set
# as the first Child element. If nil, then any existing first Text
@@ -520,7 +520,7 @@ module REXML
# Note that at the end of this example, the branch has <b>3</b> nodes; the 'e'
# element and <b>2</b> Text node children.
def add_text( text )
- if text.kind_of? String
+ if text.kind_of? String
if @children[-1].kind_of? Text
@children[-1] << text
return
@@ -570,7 +570,7 @@ module REXML
# the attribute is added to the list of Element attributes. If String,
# the argument is used as the name of the new attribute, and the value
# parameter must be supplied.
- # value::
+ # value::
# Required if +key+ is a String, and ignored if the first argument is
# an Attribute. This is a String, and is used as the value
# of the new Attribute. This should be the unnormalized value of the
@@ -605,7 +605,7 @@ module REXML
# either an Attribute or a String. In either case, the
# attribute is found by matching the attribute name to the argument,
# and then removed. If no attribute is found, no action is taken.
- # Returns::
+ # Returns::
# the attribute removed, or nil if this Element did not contain
# a matching attribute
# e = Element.new('E')
@@ -622,7 +622,7 @@ module REXML
# Other Utilities #
#################################################
- # Get an array of all CData children.
+ # Get an array of all CData children.
# IMMUTABLE
def cdatas
find_all { |child| child.kind_of? CData }.freeze
@@ -665,7 +665,7 @@ module REXML
# Internet Explorer is the worst piece of crap to have ever been
# written, with the possible exception of Windows itself. Since IE is
# unable to parse proper XML, we have to provide a hack to generate XML
- # that IE's limited abilities can handle. This hack inserts a space
+ # that IE's limited abilities can handle. This hack inserts a space
# before the /> on empty tags. Defaults to false
#
# out = ''
@@ -690,8 +690,8 @@ module REXML
def __to_xpath_helper node
rv = node.expanded_name.clone
if node.parent
- results = node.parent.find_all {|n|
- n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
+ results = node.parent.find_all {|n|
+ n.kind_of?(REXML::Element) and n.expanded_name == node.expanded_name
}
if results.length > 1
idx = results.index( node )
@@ -718,7 +718,7 @@ module REXML
# A class which provides filtering of children for Elements, and
# XPath search support. You are expected to only encounter this class as
- # the <tt>element.elements</tt> object. Therefore, you are
+ # the <tt>element.elements</tt> object. Therefore, you are
# _not_ expected to instantiate this yourself.
class Elements
include Enumerable
@@ -730,7 +730,7 @@ module REXML
# Fetches a child element. Filters only Element children, regardless of
# the XPath match.
- # index::
+ # index::
# the search parameter. This is either an Integer, which
# will be used to find the index'th child Element, or an XPath,
# which will be used to search for the Element. <em>Because
@@ -740,7 +740,7 @@ module REXML
# child element is at index 1, not 0, and the +n+th element is at index
# +n+, not <tt>n-1</tt>. This is because XPath indexes element children
# starting from 1, not 0, and the indexes should be the same.
- # name::
+ # name::
# optional, and only used in the first argument is an
# Integer. In that case, the index'th child Element that has the
# supplied name will be returned. Note again that the indexes start at 1.
@@ -757,12 +757,12 @@ module REXML
child = nil
@element.find { |child|
child.kind_of? Element and
- (name.nil? ? true : child.has_name?( name )) and
+ (name.nil? ? true : child.has_name?( name )) and
(num += 1) == index
}
else
return XPath::first( @element, index )
- #{ |element|
+ #{ |element|
# return element if element.kind_of? Element
#}
#return nil
@@ -772,7 +772,7 @@ module REXML
# Sets an element, replacing any previous matching element. If no
# existing element is found ,the element is added.
# index:: Used to find a matching element to replace. See []().
- # element::
+ # element::
# The element to replace the existing element with
# the previous element
# Returns:: nil if no previous element was found.
@@ -797,12 +797,12 @@ module REXML
@element.find{ |child| child.kind_of? Element}.nil?
end
- # Returns the index of the supplied child (starting at 1), or -1 if
+ # Returns the index of the supplied child (starting at 1), or -1 if
# the element is not a child
# element:: an +Element+ child
def index element
rv = 0
- found = @element.find do |child|
+ found = @element.find do |child|
child.kind_of? Element and
(rv += 1) and
child == element
@@ -812,7 +812,7 @@ module REXML
end
# Deletes a child Element
- # element::
+ # element::
# Either an Element, which is removed directly; an
# xpath, where the first matching child is removed; or an Integer,
# where the n'th Element is removed.
@@ -839,7 +839,7 @@ module REXML
# deleted = doc.elements.delete_all 'a/c' #-> [<c/>, <c/>, <c/>, <c/>]
def delete_all( xpath )
rv = []
- XPath::each( @element, xpath) {|element|
+ XPath::each( @element, xpath) {|element|
rv << element if element.kind_of? Element
}
rv.each do |element|
@@ -850,7 +850,7 @@ module REXML
end
# Adds an element
- # element::
+ # element::
# if supplied, is either an Element, String, or
# Source (see Element.initialize). If not supplied or nil, a
# new, default Element will be constructed
@@ -875,8 +875,8 @@ module REXML
# Iterates through all of the child Elements, optionally filtering
# them by a given XPath
- # xpath::
- # optional. If supplied, this is a String XPath, and is used to
+ # xpath::
+ # optional. If supplied, this is a String XPath, and is used to
# filter the children, so that only matching children are yielded. Note
# that XPaths are automatically filtered for Elements, so that
# non-Element children will not be yielded
@@ -893,8 +893,8 @@ module REXML
def collect( xpath=nil, &block )
collection = []
- XPath::each( @element, xpath ) {|e|
- collection << yield(e) if e.kind_of?(Element)
+ XPath::each( @element, xpath ) {|e|
+ collection << yield(e) if e.kind_of?(Element)
}
collection
end
@@ -929,7 +929,7 @@ module REXML
# supplied XPath matches non-Element children.
# doc = Document.new '<a>sean<b/>elliott<c/></a>'
# doc.root.elements.to_a #-> [ <b/>, <c/> ]
- # doc.root.elements.to_a("child::node()") #-> [ <b/>, <c/> ]
+ # doc.root.elements.to_a("child::node()") #-> [ <b/>, <c/> ]
# XPath.match(doc.root, "child::node()") #-> [ sean, <b/>, elliott, <c/> ]
def to_a( xpath=nil )
rv = XPath.match( @element, xpath )
@@ -949,7 +949,7 @@ module REXML
# ATTRIBUTES #
########################################################################
- # A class that defines the set of Attributes of an Element and provides
+ # A class that defines the set of Attributes of an Element and provides
# operations for accessing elements in that set.
class Attributes < Hash
# Constructor
@@ -961,11 +961,11 @@ module REXML
# Fetches an attribute value. If you want to get the Attribute itself,
# use get_attribute()
# name:: an XPath attribute name. Namespaces are relevant here.
- # Returns::
+ # Returns::
# the String value of the matching attribute, or +nil+ if no
# matching attribute was found. This is the unnormalized value
# (with entities expanded).
- #
+ #
# doc = Document.new "<a foo:att='1' bar:att='2' att='&lt;'/>"
# doc.root.attributes['att'] #-> '<'
# doc.root.attributes['bar:att'] #-> '2'
@@ -991,7 +991,7 @@ module REXML
# Iterates over the attributes of an Element. Yields actual Attribute
# nodes, not String values.
- #
+ #
# doc = Document.new '<a x="1" y="2"/>'
# doc.root.attributes.each_attribute {|attr|
# p attr.expanded_name+" => "+attr.value
@@ -1018,7 +1018,7 @@ module REXML
end
# Fetches an attribute
- # name::
+ # name::
# the name by which to search for the attribute. Can be a
# <tt>prefix:name</tt> namespace name.
# Returns:: The first matching attribute, or nil if there was none. This
@@ -1062,10 +1062,10 @@ module REXML
# Sets an attribute, overwriting any existing attribute value by the
# same name. Namespace is significant.
# name:: the name of the attribute
- # value::
+ # value::
# (optional) If supplied, the value of the attribute. If
# nil, any existing matching attribute is deleted.
- # Returns::
+ # Returns::
# Owning element
# doc = Document.new "<a x:foo='1' foo='3'/>"
# doc.root.attributes['y:foo'] = '2'
@@ -1094,13 +1094,13 @@ module REXML
old_attr[value.prefix] = value
elsif old_attr.prefix != value.prefix
# Check for conflicting namespaces
- raise ParseException.new(
+ raise ParseException.new(
"Namespace conflict in adding attribute \"#{value.name}\": "+
"Prefix \"#{old_attr.prefix}\" = "+
"\"#{@element.namespace(old_attr.prefix)}\" and prefix "+
- "\"#{value.prefix}\" = \"#{@element.namespace(value.prefix)}\"") if
+ "\"#{value.prefix}\" = \"#{@element.namespace(value.prefix)}\"") if
value.prefix != "xmlns" and old_attr.prefix != "xmlns" and
- @element.namespace( old_attr.prefix ) ==
+ @element.namespace( old_attr.prefix ) ==
@element.namespace( value.prefix )
store value.name, { old_attr.prefix => old_attr,
value.prefix => value }
@@ -1110,7 +1110,7 @@ module REXML
return @element
end
- # Returns an array of Strings containing all of the prefixes declared
+ # Returns an array of Strings containing all of the prefixes declared
# by this set of # attributes. The array does not include the default
# namespace declaration, if one exists.
# doc = Document.new("<a xmlns='foo' xmlns:x='bar' xmlns:y='twee' "+
@@ -1149,7 +1149,7 @@ module REXML
end
# Removes an attribute
- # attribute::
+ # attribute::
# either a String, which is the name of the attribute to remove --
# namespaces are significant here -- or the attribute to remove.
# Returns:: the owning element
@@ -1197,12 +1197,12 @@ module REXML
alias :<< :add
# Deletes all attributes matching a name. Namespaces are significant.
- # name::
+ # name::
# A String; all attributes that match this path will be removed
# Returns:: an Array of the Attributes that were removed
def delete_all( name )
rv = []
- each_attribute { |attribute|
+ each_attribute { |attribute|
rv << attribute if attribute.expanded_name == name
}
rv.each{ |attr| attr.remove }
@@ -1212,7 +1212,7 @@ module REXML
# The +get_attribute_ns+ method retrieves a method by its namespace
# and name. Thus it is possible to reliably identify an attribute
# even if an XML processor has changed the prefix.
- #
+ #
# Method contributed by Henrik Martensson
def get_attribute_ns(namespace, name)
each_attribute() { |attribute|
diff --git a/lib/rexml/encoding.rb b/lib/rexml/encoding.rb
index a01763be99..d6a2755373 100644
--- a/lib/rexml/encoding.rb
+++ b/lib/rexml/encoding.rb
@@ -29,7 +29,7 @@ module REXML
if enc and enc != UTF_8
@encoding = enc
raise ArgumentError, "Bad encoding name #@encoding" unless @encoding =~ /^[\w-]+$/
- @encoding.untaint
+ @encoding.untaint
begin
require 'rexml/encodings/ICONV.rb'
Encoding.apply(self, "ICONV")
diff --git a/lib/rexml/encodings/CP-1252.rb b/lib/rexml/encodings/CP-1252.rb
index 8675f9ff98..8a321f19f1 100644
--- a/lib/rexml/encodings/CP-1252.rb
+++ b/lib/rexml/encodings/CP-1252.rb
@@ -58,7 +58,7 @@ module REXML
end
array_enc.pack('C*')
end
-
+
# Convert to UTF-8
def decode_cp1252(str)
array_latin9 = str.unpack('C*')
diff --git a/lib/rexml/encodings/ISO-8859-15.rb b/lib/rexml/encodings/ISO-8859-15.rb
index 8dea0d38a4..71e23b781a 100644
--- a/lib/rexml/encodings/ISO-8859-15.rb
+++ b/lib/rexml/encodings/ISO-8859-15.rb
@@ -46,7 +46,7 @@ module REXML
end
array_enc.pack('C*')
end
-
+
# Convert to UTF-8
def from_iso_8859_15(str)
array_latin9 = str.unpack('C*')
diff --git a/lib/rexml/encodings/UNILE.rb b/lib/rexml/encodings/UNILE.rb
index d054140c40..1a18f0c932 100644
--- a/lib/rexml/encodings/UNILE.rb
+++ b/lib/rexml/encodings/UNILE.rb
@@ -18,7 +18,7 @@ module REXML
def decode_unile(str)
array_enc=str.unpack('C*')
array_utf8 = []
- 0.step(array_enc.size-1, 2){|i|
+ 0.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i) + array_enc.at(i+1)*0x100)
}
array_utf8.pack('U*')
diff --git a/lib/rexml/encodings/UTF-16.rb b/lib/rexml/encodings/UTF-16.rb
index 007c493d9c..2ec058eed5 100644
--- a/lib/rexml/encodings/UTF-16.rb
+++ b/lib/rexml/encodings/UTF-16.rb
@@ -19,7 +19,7 @@ module REXML
str = str[2..-1] if /^\376\377/n =~ str
array_enc=str.unpack('C*')
array_utf8 = []
- 0.step(array_enc.size-1, 2){|i|
+ 0.step(array_enc.size-1, 2){|i|
array_utf8 << (array_enc.at(i+1) + array_enc.at(i)*0x100)
}
array_utf8.pack('U*')
diff --git a/lib/rexml/entity.rb b/lib/rexml/entity.rb
index 919df02b10..0e5d03b014 100644
--- a/lib/rexml/entity.rb
+++ b/lib/rexml/entity.rb
@@ -30,7 +30,7 @@ module REXML
# is read from a stream. If you start poking around with the accessors,
# you can easily create a non-conformant Entity. The best thing to do is
# dump the stupid DTDs and use XMLSchema instead.
- #
+ #
# e = Entity.new( 'amp', '&' )
def initialize stream, value=nil, parent=nil, reference=false
super(parent)
@@ -38,7 +38,7 @@ module REXML
if stream.kind_of? Array
@name = stream[1]
if stream[-1] == '%'
- @reference = true
+ @reference = true
stream.pop
else
@reference = false
diff --git a/lib/rexml/formatters/default.rb b/lib/rexml/formatters/default.rb
index 77381bdf84..e34e45d0a7 100644
--- a/lib/rexml/formatters/default.rb
+++ b/lib/rexml/formatters/default.rb
@@ -21,7 +21,7 @@ module REXML
def write( node, output )
case node
- when Document
+ when Document
if node.xml_decl.encoding != "UTF-8" && !output.kind_of?(Output)
output = Output.new( output, node.xml_decl.encoding )
end
@@ -70,7 +70,7 @@ module REXML
if node.children.empty?
output << " " if @ie_hack
- output << "/"
+ output << "/"
else
output << ">"
node.children.each { |child|
diff --git a/lib/rexml/formatters/pretty.rb b/lib/rexml/formatters/pretty.rb
index dd03626a21..7c0e42d86f 100644
--- a/lib/rexml/formatters/pretty.rb
+++ b/lib/rexml/formatters/pretty.rb
@@ -47,7 +47,7 @@ module REXML
if @ie_hack
output << " "
end
- output << "/"
+ output << "/"
else
output << ">"
# If compact and all children are text, and if the formatted output
diff --git a/lib/rexml/formatters/transitive.rb b/lib/rexml/formatters/transitive.rb
index 1d80f21fbb..1e68a7699a 100644
--- a/lib/rexml/formatters/transitive.rb
+++ b/lib/rexml/formatters/transitive.rb
@@ -29,7 +29,7 @@ module REXML
output << "\n"
output << ' '*@level
if node.children.empty?
- output << "/"
+ output << "/"
else
output << ">"
# If compact and all children are text, and if the formatted output
diff --git a/lib/rexml/functions.rb b/lib/rexml/functions.rb
index fefc9ef940..78e07b8668 100644
--- a/lib/rexml/functions.rb
+++ b/lib/rexml/functions.rb
@@ -48,7 +48,7 @@ module REXML
# UNTESTED
def Functions::local_name( node_set=nil )
get_namespace( node_set ) do |node|
- return node.local_name
+ return node.local_name
end
end
@@ -57,7 +57,7 @@ module REXML
end
def Functions::name( node_set=nil )
- get_namespace( node_set ) do |node|
+ get_namespace( node_set ) do |node|
node.expanded_name
end
end
@@ -66,7 +66,7 @@ module REXML
def Functions::get_namespace( node_set = nil )
if node_set == nil
yield @@context[:node] if defined? @@context[:node].namespace
- else
+ else
if node_set.respond_to? :each
node_set.each { |node| yield node if defined? node.namespace }
elsif node_set.respond_to? :namespace
@@ -81,15 +81,15 @@ module REXML
#
# A number is converted to a string as follows
#
- # NaN is converted to the string NaN
+ # NaN is converted to the string NaN
#
- # positive zero is converted to the string 0
+ # positive zero is converted to the string 0
#
- # negative zero is converted to the string 0
+ # negative zero is converted to the string 0
#
- # positive infinity is converted to the string Infinity
+ # positive infinity is converted to the string Infinity
#
- # negative infinity is converted to the string -Infinity
+ # negative infinity is converted to the string -Infinity
#
# if the number is an integer, the number is represented in decimal form
# as a Number with no decimal point and no leading zeros, preceded by a
@@ -156,7 +156,7 @@ module REXML
string(string).include?(string(test))
end
- # Kouhei fixed this
+ # Kouhei fixed this
def Functions::substring_before( string, test )
ruby_string = string(string)
ruby_index = ruby_string.index(string(test))
@@ -166,7 +166,7 @@ module REXML
ruby_string[ 0...ruby_index ]
end
end
-
+
# Kouhei fixed this too
def Functions::substring_after( string, test )
ruby_string = string(string)
@@ -175,11 +175,11 @@ module REXML
""
end
- # Take equal portions of Mike Stok and Sean Russell; mix
+ # Take equal portions of Mike Stok and Sean Russell; mix
# vigorously, and pour into a tall, chilled glass. Serves 10,000.
def Functions::substring( string, start, length=nil )
ruby_string = string(string)
- ruby_length = if length.nil?
+ ruby_length = if length.nil?
ruby_string.length.to_f
else
number(length)
@@ -188,15 +188,15 @@ module REXML
# Handle the special cases
return '' if (
- ruby_length.nan? or
+ ruby_length.nan? or
ruby_start.nan? or
ruby_start.infinite?
)
infinite_length = ruby_length.infinite? == 1
ruby_length = ruby_string.length if infinite_length
-
- # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds
+
+ # Now, get the bounds. The XPath bounds are 1..length; the ruby bounds
# are 0..length. Therefore, we have to offset the bounds by one.
ruby_start = ruby_start.round - 1
ruby_length = ruby_length.round
@@ -247,7 +247,7 @@ module REXML
0.upto(from.length - 1) { |pos|
from_char = from[pos]
unless map.has_key? from_char
- map[from_char] =
+ map[from_char] =
if pos < to.length
to[pos]
else
@@ -353,7 +353,7 @@ module REXML
nodes = [nodes] unless nodes.kind_of? Array
nodes.inject(0) { |r,n| r += number(string(n)) }
end
-
+
def Functions::floor( number )
number(number).floor
end
diff --git a/lib/rexml/instruction.rb b/lib/rexml/instruction.rb
index c16b894b4a..e5a497e2b3 100644
--- a/lib/rexml/instruction.rb
+++ b/lib/rexml/instruction.rb
@@ -13,7 +13,7 @@ module REXML
attr_accessor :target, :content
# Constructs a new Instruction
- # @param target can be one of a number of things. If String, then
+ # @param target can be one of a number of things. If String, then
# the target of this instruction is set to this. If an Instruction,
# then the Instruction is shallowly cloned (target and content are
# copied). If a Source, then the source is scanned and parsed for
@@ -37,7 +37,7 @@ module REXML
def clone
Instruction.new self
end
-
+
# == DEPRECATED
# See the rexml/formatters package
#
diff --git a/lib/rexml/namespace.rb b/lib/rexml/namespace.rb
index 3e8790580b..5e5f277795 100644
--- a/lib/rexml/namespace.rb
+++ b/lib/rexml/namespace.rb
@@ -40,7 +40,7 @@ module REXML
# source file.
def fully_expanded_name
ns = prefix
- return "#{ns}:#@name" if ns.size > 0
+ return "#{ns}:#@name" if ns.size > 0
return @name
end
end
diff --git a/lib/rexml/node.rb b/lib/rexml/node.rb
index d5e8456e53..7f846903ca 100644
--- a/lib/rexml/node.rb
+++ b/lib/rexml/node.rb
@@ -57,7 +57,7 @@ module REXML
}
end
- # Find (and return) first subnode (recursively) for which the block
+ # Find (and return) first subnode (recursively) for which the block
# evaluates to true. Returns +nil+ if none was found.
def find_first_recursive(&block) # :yields: node
each_recursive {|node|
diff --git a/lib/rexml/output.rb b/lib/rexml/output.rb
index be4d23d42d..31fca83ef3 100644
--- a/lib/rexml/output.rb
+++ b/lib/rexml/output.rb
@@ -3,7 +3,7 @@ require 'rexml/encoding'
module REXML
class Output
include Encoding
-
+
attr_reader :encoding
def initialize real_IO, encd="iso-8859-1"
diff --git a/lib/rexml/parent.rb b/lib/rexml/parent.rb
index a20aaaef6b..7ed1761654 100644
--- a/lib/rexml/parent.rb
+++ b/lib/rexml/parent.rb
@@ -6,14 +6,14 @@ module REXML
# object.
class Parent < Child
include Enumerable
-
+
# Constructor
# @param parent if supplied, will be set as the parent of this object
def initialize parent=nil
super(parent)
@children = []
end
-
+
def add( object )
#puts "PARENT GOTS #{size} CHILDREN"
object.parent = self
@@ -21,47 +21,47 @@ module REXML
#puts "PARENT NOW GOTS #{size} CHILDREN"
object
end
-
+
alias :push :add
alias :<< :push
-
+
def unshift( object )
object.parent = self
@children.unshift object
end
-
+
def delete( object )
found = false
@children.delete_if {|c| c.equal?(object) and found = true }
object.parent = nil if found
end
-
+
def each(&block)
@children.each(&block)
end
-
+
def delete_if( &block )
@children.delete_if(&block)
end
-
+
def delete_at( index )
@children.delete_at index
end
-
+
def each_index( &block )
@children.each_index(&block)
end
-
+
# Fetches a child at a given index
# @param index the Integer index of the child to fetch
def []( index )
@children[index]
end
-
+
alias :each_child :each
-
-
-
+
+
+
# Set an index entry. See Array.[]=
# @param index the index of the element to set
# @param opt either the object to set, or an Integer length
@@ -71,7 +71,7 @@ module REXML
args[-1].parent = self
@children[*args[0..-2]] = args[-1]
end
-
+
# Inserts an child before another child
# @param child1 this is either an xpath or an Element. If an Element,
# child2 will be inserted before child1 in the child list of the parent.
@@ -91,7 +91,7 @@ module REXML
end
self
end
-
+
# Inserts an child after another child
# @param child1 this is either an xpath or an Element. If an Element,
# child2 will be inserted after child1 in the child list of the parent.
@@ -111,11 +111,11 @@ module REXML
end
self
end
-
+
def to_a
@children.dup
end
-
+
# Fetches the index of a given child
# @param child the child to get the index of
# @return the index of the child, or nil if the object is not a child
@@ -125,24 +125,24 @@ module REXML
@children.find { |i| count += 1 ; i.hash == child.hash }
count
end
-
+
# @return the number of children of this parent
def size
@children.size
end
-
+
alias :length :size
-
+
# Replaces one child with another, making sure the nodelist is correct
# @param to_replace the child to replace (must be a Child)
- # @param replacement the child to insert into the nodelist (must be a
+ # @param replacement the child to insert into the nodelist (must be a
# Child)
def replace_child( to_replace, replacement )
@children.map! {|c| c.equal?( to_replace ) ? replacement : c }
to_replace.parent = nil
replacement.parent = self
end
-
+
# Deeply clones this object. This creates a complete duplicate of this
# Parent, including all descendants.
def deep_clone
@@ -156,9 +156,9 @@ module REXML
end
cl
end
-
+
alias :children :to_a
-
+
def parent?
true
end
diff --git a/lib/rexml/parseexception.rb b/lib/rexml/parseexception.rb
index feb7a7e638..0481f72818 100644
--- a/lib/rexml/parseexception.rb
+++ b/lib/rexml/parseexception.rb
@@ -30,7 +30,7 @@ module REXML
err << "Last 80 unconsumed characters:\n"
err << @source.buffer[0..80].gsub(/\n/, ' ')
end
-
+
err
end
@@ -40,12 +40,12 @@ module REXML
end
def line
- @source.current_line[2] if @source and defined? @source.current_line and
+ @source.current_line[2] if @source and defined? @source.current_line and
@source.current_line
end
def context
@source.current_line
end
- end
+ end
end
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
index c791b476f9..a4f7b9edb1 100644
--- a/lib/rexml/parsers/baseparser.rb
+++ b/lib/rexml/parsers/baseparser.rb
@@ -92,11 +92,11 @@ module REXML
EREFERENCE = /&(?!#{NAME};)/
- DEFAULT_ENTITIES = {
- 'gt' => [/&gt;/, '&gt;', '>', />/],
- 'lt' => [/&lt;/, '&lt;', '<', /</],
- 'quot' => [/&quot;/, '&quot;', '"', /"/],
- "apos" => [/&apos;/, "&apos;", "'", /'/]
+ DEFAULT_ENTITIES = {
+ 'gt' => [/&gt;/, '&gt;', '>', />/],
+ 'lt' => [/&lt;/, '&lt;', '<', /</],
+ 'quot' => [/&quot;/, '&quot;', '"', /"/],
+ "apos" => [/&apos;/, "&apos;", "'", /'/]
}
@@ -167,9 +167,9 @@ module REXML
# Peek at the +depth+ event in the stack. The first element on the stack
# is at depth 0. If +depth+ is -1, will parse to the end of the input
# stream and return the last event, which is always :end_document.
- # Be aware that this causes the stream to be parsed up to the +depth+
- # event, so you can effectively pre-parse the entire document (pull the
- # entire thing into memory) using this method.
+ # Be aware that this causes the stream to be parsed up to the +depth+
+ # event, so you can effectively pre-parse the entire document (pull the
+ # entire thing into memory) using this method.
def peek depth=0
raise %Q[Illegal argument "#{depth}"] if depth < -1
temp = []
@@ -247,7 +247,7 @@ module REXML
if @document_status == :in_doctype
md = @source.match(/\s*(.*?>)/um)
case md[1]
- when SYSTEMENTITY
+ when SYSTEMENTITY
match = @source.match( SYSTEMENTITY, true )[1]
return [ :externalentity, match ]
@@ -326,7 +326,7 @@ module REXML
#md = @source.match_to_consume( '>', CLOSE_MATCH)
md = @source.match( CLOSE_MATCH, true )
raise REXML::ParseException.new( "Missing end tag for "+
- "'#{last_tag}' (got \"#{md[1]}\")",
+ "'#{last_tag}' (got \"#{md[1]}\")",
@source) unless last_tag == md[1]
return [ :end_element, last_tag ]
elsif @source.buffer[1] == ?!
@@ -353,7 +353,7 @@ module REXML
unless md
# Check for missing attribute quotes
raise REXML::ParseException.new("missing attribute quote", @source) if @source.match(MISSING_ATTRIBUTE_QUOTES )
- raise REXML::ParseException.new("malformed XML: missing tag start", @source)
+ raise REXML::ParseException.new("malformed XML: missing tag start", @source)
end
attributes = {}
prefixes = Set.new
@@ -362,7 +362,7 @@ module REXML
if md[4].size > 0
attrs = md[4].scan( ATTRIBUTE_PATTERN )
raise REXML::ParseException.new( "error parsing attributes: [#{attrs.join ', '}], excess = \"#$'\"", @source) if $' and $'.strip.size > 0
- attrs.each { |a,b,c,d,e|
+ attrs.each { |a,b,c,d,e|
if b == "xmlns"
if c == "xml"
if d != "http://www.w3.org/XML/1998/namespace"
@@ -379,10 +379,10 @@ module REXML
elsif b
prefixes << b unless b == "xml"
end
- attributes[a] = e
+ attributes[a] = e
}
end
-
+
# Verify that all of the prefixes have been defined
for prefix in prefixes
unless @nsstack.find{|k| k.member?(prefix)}
@@ -436,7 +436,7 @@ module REXML
# Doing it like this rather than in a loop improves the speed
copy.gsub!( EREFERENCE, '&amp;' )
entities.each do |key, value|
- copy.gsub!( value, "&#{key};" ) unless entity_filter and
+ copy.gsub!( value, "&#{key};" ) unless entity_filter and
entity_filter.include?(entity)
end if entities
copy.gsub!( EREFERENCE, '&amp;' )
diff --git a/lib/rexml/parsers/pullparser.rb b/lib/rexml/parsers/pullparser.rb
index 36dc7160c3..68a4ff7eae 100644
--- a/lib/rexml/parsers/pullparser.rb
+++ b/lib/rexml/parsers/pullparser.rb
@@ -68,7 +68,7 @@ module REXML
event = @parser.pull
case event[0]
when :entitydecl
- @entities[ event[1] ] =
+ @entities[ event[1] ] =
event[2] unless event[2] =~ /PUBLIC|SYSTEM/
when :text
unnormalized = @parser.unnormalize( event[1], @entities )
diff --git a/lib/rexml/parsers/sax2parser.rb b/lib/rexml/parsers/sax2parser.rb
index e402eb7747..02d5c0360d 100644
--- a/lib/rexml/parsers/sax2parser.rb
+++ b/lib/rexml/parsers/sax2parser.rb
@@ -20,7 +20,7 @@ module REXML
def source
@parser.source
end
-
+
def add_listener( listener )
@parser.add_listener( listener )
end
@@ -44,7 +44,7 @@ module REXML
# :entitydecl, :notationdecl, :cdata, :xmldecl, :comment
#
# There is an additional symbol that can be listened for: :progress.
- # This will be called for every event generated, passing in the current
+ # This will be called for every event generated, passing in the current
# stream position.
#
# Array contains regular expressions or strings which will be matched
@@ -72,7 +72,7 @@ module REXML
add([nil, nil, args[0]])
end
end
-
+
def deafen( listener=nil, &blok )
if listener
@listeners.delete_if {|item| item[-1] == listener }
@@ -81,10 +81,10 @@ module REXML
@procs.delete_if {|item| item[-1] == blok }
end
end
-
+
def parse
@procs.each { |sym,match,block| block.call if sym == :start_document }
- @listeners.each { |sym,match,block|
+ @listeners.each { |sym,match,block|
block.start_document if sym == :start_document or sym.nil?
}
root = context = []
@@ -126,8 +126,8 @@ module REXML
listeners = get_listeners( :start_element, event[1] )
# notify observers
procs.each { |ob| ob.call( uri, local, event[1], event[2] ) } if procs
- listeners.each { |ob|
- ob.start_element( uri, local, event[1], event[2] )
+ listeners.each { |ob|
+ ob.start_element( uri, local, event[1], event[2] )
} if listeners
when :end_element
@tag_stack.pop
@@ -140,8 +140,8 @@ module REXML
listeners = get_listeners( :end_element, event[1] )
# notify observers
procs.each { |ob| ob.call( uri, local, event[1] ) } if procs
- listeners.each { |ob|
- ob.end_element( uri, local, event[1] )
+ listeners.each { |ob|
+ ob.end_element( uri, local, event[1] )
} if listeners
namespace_mapping = @namespace_stack.pop
@@ -169,7 +169,7 @@ module REXML
when :entitydecl
@entities[ event[1] ] = event[2] if event.size == 3
handle( *event )
- when :processing_instruction, :comment, :attlistdecl,
+ when :processing_instruction, :comment, :attlistdecl,
:elementdecl, :cdata, :notationdecl, :xmldecl
handle( *event )
end
@@ -184,8 +184,8 @@ module REXML
listeners = get_listeners( symbol, tag )
# notify observers
procs.each { |ob| ob.call( *arguments ) } if procs
- listeners.each { |l|
- l.send( symbol.to_s, *arguments )
+ listeners.each { |l|
+ l.send( symbol.to_s, *arguments )
} if listeners
end
@@ -196,7 +196,7 @@ module REXML
@procs.find_all do |sym, match, block|
#puts sym.inspect+"=="+symbol.inspect+ "\t"+match.inspect+"=="+name.inspect+ "\t"+( (sym.nil? or symbol == sym) and ((name.nil? and match.nil?) or match.nil? or ( (name == match) or (match.kind_of? Regexp and name =~ match)))).to_s
(
- (sym.nil? or symbol == sym) and
+ (sym.nil? or symbol == sym) and
((name.nil? and match.nil?) or match.nil? or (
(name == match) or
(match.kind_of? Regexp and name =~ match)
@@ -209,7 +209,7 @@ module REXML
return nil if @listeners.size == 0
@listeners.find_all do |sym, match, block|
(
- (sym.nil? or symbol == sym) and
+ (sym.nil? or symbol == sym) and
((name.nil? and match.nil?) or match.nil? or (
(name == match) or
(match.kind_of? Regexp and name =~ match)
@@ -228,7 +228,7 @@ module REXML
end
end
- def get_namespace( prefix )
+ def get_namespace( prefix )
uris = (@namespace_stack.find_all { |ns| not ns[prefix].nil? }) ||
(@namespace_stack.find { |ns| not ns[nil].nil? })
uris[-1][prefix] unless uris.nil? or 0 == uris.size
diff --git a/lib/rexml/parsers/streamparser.rb b/lib/rexml/parsers/streamparser.rb
index 256d0f611c..073fcc2c21 100644
--- a/lib/rexml/parsers/streamparser.rb
+++ b/lib/rexml/parsers/streamparser.rb
@@ -5,11 +5,11 @@ module REXML
@listener = listener
@parser = BaseParser.new( source )
end
-
+
def add_listener( listener )
@parser.add_listener( listener )
end
-
+
def parse
# entity string
while true
diff --git a/lib/rexml/parsers/treeparser.rb b/lib/rexml/parsers/treeparser.rb
index 5c3e142ea7..591af26914 100644
--- a/lib/rexml/parsers/treeparser.rb
+++ b/lib/rexml/parsers/treeparser.rb
@@ -39,8 +39,8 @@ module REXML
if @build_context[-1].instance_of? Text
@build_context[-1] << event[1]
else
- @build_context.add(
- Text.new(event[1], @build_context.whitespace, nil, true)
+ @build_context.add(
+ Text.new(event[1], @build_context.whitespace, nil, true)
) unless (
@build_context.ignore_whitespace_nodes and
event[1].strip.size==0
diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb
index de2530e347..a36a4286ac 100644
--- a/lib/rexml/parsers/xpathparser.rb
+++ b/lib/rexml/parsers/xpathparser.rb
@@ -53,8 +53,8 @@ module REXML
string << "*"
when :text
string << "text()"
- when :following, :following_sibling,
- :ancestor, :ancestor_or_self, :descendant,
+ when :following, :following_sibling,
+ :ancestor, :ancestor_or_self, :descendant,
:namespace, :preceding, :preceding_sibling
string << "/" unless string.size == 0
string << op.to_s.tr("_", "-")
@@ -97,7 +97,7 @@ module REXML
case op
when :node
string << "node()"
- when :attribute, :child, :following, :following_sibling,
+ when :attribute, :child, :following, :following_sibling,
:ancestor, :ancestor_or_self, :descendant, :descendant_or_self,
:namespace, :preceding, :preceding_sibling, :self, :parent
string << "/" unless string.size == 0
@@ -249,7 +249,7 @@ module REXML
parsed.concat(n)
end
-
+
if path.size > 0
if path[0] == ?/
if path[1] == ?/
@@ -332,12 +332,12 @@ module REXML
predicates << expr[1..-2] if expr
end
#puts "PREDICATES = #{predicates.inspect}"
- predicates.each{ |expr|
+ predicates.each{ |expr|
#puts "ORING #{expr}"
preds = []
parsed << :predicate
parsed << preds
- OrExpr(expr, preds)
+ OrExpr(expr, preds)
}
#puts "PREDICATES = #{predicates.inspect}"
path
@@ -600,13 +600,13 @@ module REXML
#puts "LITERAL or NUMBER: #$1"
varname = $1.nil? ? $2 : $1
path = $'
- parsed << :literal
+ parsed << :literal
parsed << (varname.include?('.') ? varname.to_f : varname.to_i)
when LITERAL
#puts "LITERAL or NUMBER: #$1"
varname = $1.nil? ? $2 : $1
path = $'
- parsed << :literal
+ parsed << :literal
parsed << varname
when /^\(/ #/
path, contents = get_group(path)
@@ -649,7 +649,7 @@ module REXML
return nil unless depth==0
[string[ind..-1], string[0..ind-1]]
end
-
+
def parse_args( string )
arguments = []
ind = 0
@@ -683,7 +683,7 @@ module REXML
s = string[0,ind].strip
arguments << s unless s == ""
string = string[ind+1..-1]
- ind = -1
+ ind = -1
end
end
end
diff --git a/lib/rexml/quickpath.rb b/lib/rexml/quickpath.rb
index c099db8579..50bf483677 100644
--- a/lib/rexml/quickpath.rb
+++ b/lib/rexml/quickpath.rb
@@ -68,7 +68,7 @@ module REXML
ns = $1
rest = $'
elements.delete_if do |element|
- !(element.kind_of? Element and
+ !(element.kind_of? Element and
(element.expanded_name == name or
(element.name == name and
element.namespace == Functions.namespace_context[ns])))
@@ -135,16 +135,16 @@ module REXML
matches = filter(elements.collect{|element| element.next_sibling}.uniq,
rest)
when "previous-sibling"
- matches = filter(elements.collect{|element|
+ matches = filter(elements.collect{|element|
element.previous_sibling}.uniq, rest )
end
return matches.uniq
end
# A predicate filters a node-set with respect to an axis to produce a
- # new node-set. For each node in the node-set to be filtered, the
- # PredicateExpr is evaluated with that node as the context node, with
- # the number of nodes in the node-set as the context size, and with the
+ # new node-set. For each node in the node-set to be filtered, the
+ # PredicateExpr is evaluated with that node as the context node, with
+ # the number of nodes in the node-set as the context size, and with the
# proximity position of the node in the node-set with respect to the
# axis as the context position; if PredicateExpr evaluates to true for
# that node, the node is included in the new node-set; otherwise, it is
@@ -157,7 +157,7 @@ module REXML
# number, then the result will be converted as if by a call to the
# boolean function. Thus a location path para[3] is equivalent to
# para[position()=3].
- def QuickPath::predicate( elements, path )
+ def QuickPath::predicate( elements, path )
ind = 1
bcount = 1
while bcount > 0
@@ -170,21 +170,21 @@ module REXML
rest = path[ind+1..-1]
# have to change 'a [=<>] b [=<>] c' into 'a [=<>] b and b [=<>] c'
- predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u ) {
+ predicate.gsub!( /([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)\s*([<>=])\s*([^\s(and)(or)<>=]+)/u ) {
"#$1 #$2 #$3 and #$3 #$4 #$5"
}
# Let's do some Ruby trickery to avoid some work:
predicate.gsub!( /&/u, "&&" )
predicate.gsub!( /=/u, "==" )
predicate.gsub!( /@(\w[-\w.]*)/u ) {
- "attribute(\"#$1\")"
+ "attribute(\"#$1\")"
}
predicate.gsub!( /\bmod\b/u, "%" )
predicate.gsub!( /\b(\w[-\w.]*\()/u ) {
fname = $1
fname.gsub( /-/u, "_" )
}
-
+
Functions.pair = [ 0, elements.size ]
results = []
elements.each do |element|
diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb
index d41718f9e7..98476ee6b4 100644
--- a/lib/rexml/rexml.rb
+++ b/lib/rexml/rexml.rb
@@ -5,8 +5,8 @@
# non-validating[http://www.w3.org/TR/2004/REC-xml-20040204/#sec-conformance]
# toolkit with an intuitive API. REXML passes 100% of the non-validating Oasis
# tests[http://www.oasis-open.org/committees/xml-conformance/xml-test-suite.shtml],
-# and provides tree, stream, SAX2, pull, and lightweight APIs. REXML also
-# includes a full XPath[http://www.w3c.org/tr/xpath] 1.0 implementation. Since
+# and provides tree, stream, SAX2, pull, and lightweight APIs. REXML also
+# includes a full XPath[http://www.w3c.org/tr/xpath] 1.0 implementation. Since
# Ruby 1.8, REXML is included in the standard Ruby distribution.
#
# Main page:: http://www.germane-software.com/software/rexml
@@ -14,12 +14,12 @@
# Version:: 3.1.7.2
# Date:: 2007/275
# Revision:: $Revision$
-#
+#
# This API documentation can be downloaded from the REXML home page, or can
# be accessed online[http://www.germane-software.com/software/rexml_doc]
#
# A tutorial is available in the REXML distribution in docs/tutorial.html,
-# or can be accessed
+# or can be accessed
# online[http://www.germane-software.com/software/rexml/docs/tutorial.html]
module REXML
COPYRIGHT = "Copyright \xC2\xA9 2001-2006 Sean Russell <[email protected]>"
diff --git a/lib/rexml/sax2listener.rb b/lib/rexml/sax2listener.rb
index 8db1389d06..f73acd6882 100644
--- a/lib/rexml/sax2listener.rb
+++ b/lib/rexml/sax2listener.rb
@@ -1,11 +1,11 @@
module REXML
# A template for stream parser listeners.
# Note that the declarations (attlistdecl, elementdecl, etc) are trivially
- # processed; REXML doesn't yet handle doctype entity declarations, so you
+ # processed; REXML doesn't yet handle doctype entity declarations, so you
# have to parse them out yourself.
# === Missing methods from SAX2
# ignorable_whitespace
- # === Methods extending SAX2
+ # === Methods extending SAX2
# +WARNING+
# These methods are certainly going to change, until DTDs are fully
# supported. Be aware of this.
@@ -58,7 +58,7 @@ module REXML
# The argument passed to this method is an array of the entity
# declaration. It can be in a number of formats, but in general it
# returns (example, result):
- # <!ENTITY % YN '"Yes"'>
+ # <!ENTITY % YN '"Yes"'>
# ["%", "YN", "'\"Yes\"'", "\""]
# <!ENTITY % YN 'Yes'>
# ["%", "YN", "'Yes'", "s"]
@@ -93,5 +93,5 @@ module REXML
end
def progress position
end
- end
+ end
end
diff --git a/lib/rexml/source.rb b/lib/rexml/source.rb
index ce7a2c98b0..2b7cbd05b4 100644
--- a/lib/rexml/source.rb
+++ b/lib/rexml/source.rb
@@ -65,9 +65,9 @@ module REXML
# usual scan() method. For one thing, the pattern argument has some
# requirements; for another, the source can be consumed. You can easily
# confuse this method. Originally, the patterns were easier
- # to construct and this method more robust, because this method
- # generated search regexes on the fly; however, this was
- # computationally expensive and slowed down the entire REXML package
+ # to construct and this method more robust, because this method
+ # generated search regexes on the fly; however, this was
+ # computationally expensive and slowed down the entire REXML package
# considerably, since this is by far the most commonly called method.
# @param pattern must be a Regexp, and must be in the form of
# /^\s*(#{your pattern, with no groups})(.*)/. The first group
@@ -190,7 +190,7 @@ module REXML
def read
begin
str = @source.readline(@line_break)
- str = decode(str) if @to_utf and str
+ str = decode(str) if @to_utf and str
@buffer << str
rescue Exception, NameError
@source = nil
@@ -218,7 +218,7 @@ module REXML
rv.taint
rv
end
-
+
def empty?
super and ( @source.nil? || @source.eof? )
end
diff --git a/lib/rexml/streamlistener.rb b/lib/rexml/streamlistener.rb
index 6f401125b5..9defb5500e 100644
--- a/lib/rexml/streamlistener.rb
+++ b/lib/rexml/streamlistener.rb
@@ -1,14 +1,14 @@
module REXML
# A template for stream parser listeners.
# Note that the declarations (attlistdecl, elementdecl, etc) are trivially
- # processed; REXML doesn't yet handle doctype entity declarations, so you
+ # processed; REXML doesn't yet handle doctype entity declarations, so you
# have to parse them out yourself.
module StreamListener
# Called when a tag is encountered.
# @p name the tag name
# @p attrs an array of arrays of attribute/value pairs, suitable for
# use with assoc or rassoc. IE, <tag attr1="value1" attr2="value2">
- # will result in
+ # will result in
# tag_start( "tag", # [["attr1","value1"],["attr2","value2"]])
def tag_start name, attrs
end
@@ -56,7 +56,7 @@ module REXML
# The argument passed to this method is an array of the entity
# declaration. It can be in a number of formats, but in general it
# returns (example, result):
- # <!ENTITY % YN '"Yes"'>
+ # <!ENTITY % YN '"Yes"'>
# ["%", "YN", "'\"Yes\"'", "\""]
# <!ENTITY % YN 'Yes'>
# ["%", "YN", "'Yes'", "s"]
diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb
index a4a30b6d54..d9e53eb465 100644
--- a/lib/rexml/text.rb
+++ b/lib/rexml/text.rb
@@ -19,24 +19,24 @@ module REXML
attr_accessor :raw
ILLEGAL = /(<|&(?!(#{Entity::NAME})|(#0*((?:\d+)|(?:x[a-fA-F0-9]+)));))/um
- NUMERICENTITY = /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/
+ NUMERICENTITY = /&#0*((?:\d+)|(?:x[a-fA-F0-9]+));/
# Constructor
# +arg+ if a String, the content is set to the String. If a Text,
- # the object is shallowly cloned.
+ # the object is shallowly cloned.
#
# +respect_whitespace+ (boolean, false) if true, whitespace is
# respected
#
# +parent+ (nil) if this is a Parent object, the parent
- # will be set to this.
+ # will be set to this.
#
# +raw+ (nil) This argument can be given three values.
- # If true, then the value of used to construct this object is expected to
- # contain no unescaped XML markup, and REXML will not change the text. If
+ # If true, then the value of used to construct this object is expected to
+ # contain no unescaped XML markup, and REXML will not change the text. If
# this value is false, the string may contain any characters, and REXML will
# escape any and all defined entities whose values are contained in the
- # text. If this value is nil (the default), then the raw value of the
+ # text. If this value is nil (the default), then the raw value of the
# parent will be used as the raw value for this node. If there is no raw
# value for the parent, and no value is supplied, the default is false.
# Use this field if you have entities defined for some text, and you don't
@@ -57,14 +57,14 @@ module REXML
# In the last example, the +entity_filter+ argument is ignored.
#
# +pattern+ INTERNAL USE ONLY
- def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
+ def initialize(arg, respect_whitespace=false, parent=nil, raw=nil,
entity_filter=nil, illegal=ILLEGAL )
@raw = false
if parent
super( parent )
- @raw = parent.raw
+ @raw = parent.raw
else
@parent = nil
end
@@ -125,12 +125,12 @@ module REXML
# escaped, meaning that it is a valid XML text node string, and all
# entities that can be escaped, have been inserted. This method respects
# the entity filter set in the constructor.
- #
- # # Assume that the entity "s" is defined to be "sean", and that the
+ #
+ # # Assume that the entity "s" is defined to be "sean", and that the
# # entity "r" is defined to be "russell"
- # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
+ # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
# t.to_s #-> "&lt; &amp; &s; russell"
- # t = Text.new( "< & &s; russell", false, nil, false )
+ # t = Text.new( "< & &s; russell", false, nil, false )
# t.to_s #-> "&lt; &amp; &s; russell"
# u = Text.new( "sean russell", false, nil, true )
# u.to_s #-> "sean russell"
@@ -156,9 +156,9 @@ module REXML
# console. This ignores the 'raw' attribute setting, and any
# entity_filter.
#
- # # Assume that the entity "s" is defined to be "sean", and that the
+ # # Assume that the entity "s" is defined to be "sean", and that the
# # entity "r" is defined to be "russell"
- # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
+ # t = Text.new( "< & sean russell", false, nil, false, ['s'] )
# t.value #-> "< & sean russell"
# t = Text.new( "< & &s; russell", false, nil, false )
# t.value #-> "< & sean russell"
@@ -174,7 +174,7 @@ module REXML
@unnormalized = Text::unnormalize( @string, doctype )
end
- # Sets the contents of this text node. This expects the text to be
+ # Sets the contents of this text node. This expects the text to be
# unnormalized. It returns self.
#
# e = Element.new( "a" )
@@ -187,7 +187,7 @@ module REXML
@normalized = nil
@raw = false
end
-
+
def wrap(string, width, addnewline=false)
# Recursively wrap string at width.
return string if string.length <= width
@@ -210,11 +210,11 @@ module REXML
new_string.strip! unless indentfirstline
return new_string
end
-
+
# == DEPRECATED
# See REXML::Formatters
#
- def write( writer, indent=-1, transitive=false, ie_hack=false )
+ def write( writer, indent=-1, transitive=false, ie_hack=false )
Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters")
formatter = if indent > -1
REXML::Formatters::Pretty.new( indent )
@@ -265,7 +265,7 @@ module REXML
if copy =~ illegal
raise ParseException.new( "malformed text: Illegal character #$& in \"#{copy}\"" )
end if illegal
-
+
copy.gsub!( /\r\n?/, "\n" )
if copy.include? ?&
copy.gsub!( SETUTITSBUS[0], SLAICEPS[0] )
@@ -293,8 +293,8 @@ module REXML
if doctype
# Replace all ampersands that aren't part of an entity
doctype.entities.each_value do |entity|
- copy = copy.gsub( entity.value,
- "&#{entity.name};" ) if entity.value and
+ copy = copy.gsub( entity.value,
+ "&#{entity.name};" ) if entity.value and
not( entity_filter and entity_filter.include?(entity) )
end
else
diff --git a/lib/rexml/validation/relaxng.rb b/lib/rexml/validation/relaxng.rb
index 969f51bc95..30365f1909 100644
--- a/lib/rexml/validation/relaxng.rb
+++ b/lib/rexml/validation/relaxng.rb
@@ -79,7 +79,7 @@ module REXML
when "mixed"
states << Interleave.new( self )
states[-2] << states[-1]
- states[-1] << TEXT
+ states[-1] << TEXT
when "define"
states << [ event[2]["name"] ]
when "ref"
@@ -102,7 +102,7 @@ module REXML
case event[1]
when "element", "attribute"
states[-1] << event
- when "zeroOrMore", "oneOrMore", "choice", "optional",
+ when "zeroOrMore", "oneOrMore", "choice", "optional",
"interleave", "group", "mixed"
states.pop
when "define"
@@ -139,7 +139,7 @@ module REXML
@events.each {|s| s.reset if s.kind_of? State }
end
- def previous=( previous )
+ def previous=( previous )
@previous << previous
end
@@ -183,7 +183,7 @@ module REXML
end
def inspect
- "< #{to_s} #{@events.collect{|e|
+ "< #{to_s} #{@events.collect{|e|
pre = e == @events[@current] ? '#' : ''
pre + e.inspect unless self == e
}.join(', ')} >"
@@ -201,15 +201,15 @@ module REXML
protected
def expand_ref_in( arry, ind )
new_events = []
- @references[ arry[ind].to_s ].each{ |evt|
+ @references[ arry[ind].to_s ].each{ |evt|
add_event_to_arry(new_events,evt)
}
arry[ind,1] = new_events
end
- def add_event_to_arry( arry, evt )
+ def add_event_to_arry( arry, evt )
evt = generate_event( evt )
- if evt.kind_of? String
+ if evt.kind_of? String
arry[-1].event_arg = evt if arry[-1].kind_of? Event and @value
@value = false
else
@@ -272,7 +272,7 @@ module REXML
end
def matches?(event)
- @events[@current].matches?(event) ||
+ @events[@current].matches?(event) ||
(@current == 0 and @previous[-1].matches?(event))
end
@@ -319,7 +319,7 @@ module REXML
end
def reset
- super
+ super
@ord = 0
end
@@ -345,7 +345,7 @@ module REXML
end
def matches?( event )
- @events[@current].matches?(event) ||
+ @events[@current].matches?(event) ||
(@current == 0 and @ord > 0 and @previous[-1].matches?(event))
end
@@ -412,7 +412,7 @@ module REXML
#puts "IN CHOICE EXPECTED"
#puts "EVENTS = #{@events.inspect}"
return [@events[@current]] if @events.size > 0
- return @choices.collect do |x|
+ return @choices.collect do |x|
if x[0].kind_of? State
x[0].expected
else
@@ -426,12 +426,12 @@ module REXML
end
protected
- def add_event_to_arry( arry, evt )
+ def add_event_to_arry( arry, evt )
if evt.kind_of? State or evt.class == Ref
arry << [evt]
- elsif evt[0] == :text
+ elsif evt[0] == :text
if arry[-1] and
- arry[-1][-1].kind_of?( Event ) and
+ arry[-1][-1].kind_of?( Event ) and
arry[-1][-1].event_type == :text and @value
arry[-1][-1].event_arg = evt[1]
@@ -478,7 +478,7 @@ module REXML
@choices[idx] = old
@choice += 1
end
-
+
#puts "In next with #{event.inspect}."
#puts "events is #{@events.inspect}"
@events = [] unless @events
@@ -490,7 +490,7 @@ module REXML
next_current(event) unless @events[@current]
return nil unless @events[@current]
- expand_ref_in( @events, @current ) if @events[@current].class == Ref
+ expand_ref_in( @events, @current ) if @events[@current].class == Ref
#puts "In next with #{event.inspect}."
#puts "Next (#@current) is #{@events[@current]}"
if ( @events[@current].kind_of? State )
@@ -530,7 +530,7 @@ module REXML
#puts "IN CHOICE EXPECTED"
#puts "EVENTS = #{@events.inspect}"
return [@events[@current]] if @events[@current]
- return @choices[@choice..-1].collect do |x|
+ return @choices[@choice..-1].collect do |x|
if x[0].kind_of? State
x[0].expected
else
diff --git a/lib/rexml/validation/validation.rb b/lib/rexml/validation/validation.rb
index 160ea96b31..2dc177d42e 100644
--- a/lib/rexml/validation/validation.rb
+++ b/lib/rexml/validation/validation.rb
@@ -14,7 +14,7 @@ module REXML
def dump
puts @root.inspect
end
- def validate( event )
+ def validate( event )
#puts "Current: #@current"
#puts "Event: #{event.inspect}"
@attr_stack = [] unless defined? @attr_stack
@@ -33,12 +33,12 @@ module REXML
sattr = [:start_attribute, nil]
eattr = [:end_attribute]
text = [:text, nil]
- k,v = event[2].find { |k,v|
+ k,v = event[2].find { |k,v|
sattr[1] = k
#puts "Looking for #{sattr.inspect}"
m = @current.next( sattr )
#puts "Got #{m.inspect}"
- if m
+ if m
# If the state has text children...
#puts "Looking for #{eattr.inspect}"
#puts "Expect #{m.expected}"
diff --git a/lib/rexml/xpath.rb b/lib/rexml/xpath.rb
index b8d65c478d..474689176f 100644
--- a/lib/rexml/xpath.rb
+++ b/lib/rexml/xpath.rb
@@ -64,7 +64,7 @@ module REXML
parser.parse(path, element).each( &block )
end
- # Returns an array of nodes matching a given XPath.
+ # Returns an array of nodes matching a given XPath.
def XPath::match element, path=nil, namespaces=nil, variables={}
parser = XPathParser.new
parser.namespaces = namespaces
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index eb608fdb34..ac4531919e 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -88,7 +88,7 @@ module REXML
case path[0]
when :document
- # do nothing
+ # do nothing
return first( path[1..-1], node )
when :child
for c in node.children
@@ -123,7 +123,7 @@ module REXML
end
- def match( path_stack, nodeset )
+ def match( path_stack, nodeset )
#puts "MATCH: path_stack = #{path_stack.inspect}"
#puts "MATCH: nodeset = #{nodeset.inspect}"
r = expr( path_stack, nodeset )
@@ -136,7 +136,7 @@ module REXML
# Returns a String namespace for a node, given a prefix
# The rules are:
- #
+ #
# 1. Use the supplied namespace mapping first.
# 2. If no mapping was supplied, use the context node to look up the namespace
def get_namespace( node, prefix )
@@ -187,8 +187,8 @@ module REXML
#puts "node.namespace == #{ns.inspect} => #{node.namespace == ns}"
end
end
- !(node.node_type == :element and
- node.name == name and
+ !(node.node_type == :element and
+ node.name == name and
node.namespace == ns )
end
node_types = ELEMENTS
@@ -205,7 +205,7 @@ module REXML
when :processing_instruction
target = path_stack.shift
nodeset.delete_if do |node|
- (node.node_type != :processing_instruction) or
+ (node.node_type != :processing_instruction) or
( target!='' and ( node.target != target ) )
end
@@ -231,7 +231,7 @@ module REXML
when :literal
return path_stack.shift
-
+
when :attribute
new_nodeset = []
case path_stack.shift
@@ -481,23 +481,23 @@ module REXML
when :function
func_name = path_stack.shift.tr('-','_')
arguments = path_stack.shift
- #puts "FUNCTION 0: #{func_name}(#{arguments.collect{|a|a.inspect}.join(', ')})"
+ #puts "FUNCTION 0: #{func_name}(#{arguments.collect{|a|a.inspect}.join(', ')})"
subcontext = context ? nil : { :size => nodeset.size }
res = []
cont = context
- nodeset.each_with_index { |n, i|
+ nodeset.each_with_index { |n, i|
if subcontext
subcontext[:node] = n
subcontext[:index] = i
cont = subcontext
end
arg_clone = arguments.dclone
- args = arg_clone.collect { |arg|
+ args = arg_clone.collect { |arg|
#puts "FUNCTION 1: Calling expr( #{arg.inspect}, [#{n.inspect}] )"
- expr( arg, [n], cont )
+ expr( arg, [n], cont )
}
- #puts "FUNCTION 2: #{func_name}(#{args.collect{|a|a.inspect}.join(', ')})"
+ #puts "FUNCTION 2: #{func_name}(#{args.collect{|a|a.inspect}.join(', ')})"
Functions.context = cont
res << Functions.send( func_name, *args )
#puts "FUNCTION 3: #{res[-1].inspect}"
@@ -515,10 +515,10 @@ module REXML
# FIXME
# The next two methods are BAD MOJO!
# This is my achilles heel. If anybody thinks of a better
- # way of doing this, be my guest. This really sucks, but
+ # way of doing this, be my guest. This really sucks, but
# it is a wonder it works at all.
# ########################################################
-
+
def descendant_or_self( path_stack, nodeset )
rs = []
#puts "#"*80
@@ -547,7 +547,7 @@ module REXML
# Reorders an array of nodes so that they are in document order
# It tries to do this efficiently.
#
- # FIXME: I need to get rid of this, but the issue is that most of the XPath
+ # FIXME: I need to get rid of this, but the issue is that most of the XPath
# interpreter functions as a filter, which means that we lose context going
# in and out of function calls. If I knew what the index of the nodes was,
# I wouldn't have to do this. Maybe add a document IDX for each node?
@@ -555,7 +555,7 @@ module REXML
def document_order( array_of_nodes )
new_arry = []
array_of_nodes.each { |node|
- node_idx = []
+ node_idx = []
np = node.node_type == :attribute ? node.element : node
while np.parent and np.parent.node_type == :element
node_idx << np.parent.index( np )
@@ -579,7 +579,7 @@ module REXML
# Builds a nodeset of all of the preceding nodes of the supplied node,
# in reverse document order
- # preceding:: includes every element in the document that precedes this node,
+ # preceding:: includes every element in the document that precedes this node,
# except for ancestors
def preceding( node )
#puts "IN PRECEDING"
@@ -609,9 +609,9 @@ module REXML
#puts "NODE: #{node.inspect}"
#puts "PREVIOUS NODE: #{node.previous_sibling_node.inspect}"
#puts "PARENT NODE: #{node.parent}"
- psn = node.previous_sibling_node
+ psn = node.previous_sibling_node
if psn.nil?
- if node.parent.nil? or node.parent.class == Document
+ if node.parent.nil? or node.parent.class == Document
return nil
end
return node.parent
@@ -647,9 +647,9 @@ module REXML
end
def next_sibling_node(node)
- psn = node.next_sibling_node
+ psn = node.next_sibling_node
while psn.nil?
- if node.parent.nil? or node.parent.class == Document
+ if node.parent.nil? or node.parent.class == Document
return nil
end
node = node.parent
diff --git a/lib/rinda/rinda.rb b/lib/rinda/rinda.rb
index 6c59e68654..18e284a544 100644
--- a/lib/rinda/rinda.rb
+++ b/lib/rinda/rinda.rb
@@ -58,7 +58,7 @@ module Rinda
##
# The number of elements in the tuple.
-
+
def size
@tuple.size
end
@@ -162,7 +162,7 @@ module Rinda
end
return true
end
-
+
##
# Alias for #match.
@@ -171,7 +171,7 @@ module Rinda
end
end
-
+
##
# <i>Documentation?</i>
@@ -184,7 +184,7 @@ module Rinda
@drb_uri = uri
@drb_ref = ref
end
-
+
##
# This DRbObjectTemplate matches +ro+ if the remote object's drburi and
# drbref are the same. +nil+ is used as a wildcard.
@@ -213,14 +213,14 @@ module Rinda
def initialize(ts)
@ts = ts
end
-
+
##
# Adds +tuple+ to the proxied TupleSpace. See TupleSpace#write.
def write(tuple, sec=nil)
@ts.write(tuple, sec)
end
-
+
##
# Takes +tuple+ from the proxied TupleSpace. See TupleSpace#take.
@@ -229,14 +229,14 @@ module Rinda
@ts.move(DRbObject.new(port), tuple, sec, &block)
port[0]
end
-
+
##
# Reads +tuple+ from the proxied TupleSpace. See TupleSpace#read.
def read(tuple, sec=nil, &block)
@ts.read(tuple, sec, &block)
end
-
+
##
# Reads all tuples matching +tuple+ from the proxied TupleSpace. See
# TupleSpace#read_all.
@@ -244,7 +244,7 @@ module Rinda
def read_all(tuple)
@ts.read_all(tuple)
end
-
+
##
# Registers for notifications of event +ev+ on the proxied TupleSpace.
# See TupleSpace#notify
diff --git a/lib/rinda/ring.rb b/lib/rinda/ring.rb
index 1fad92dbc7..e7d9456763 100644
--- a/lib/rinda/ring.rb
+++ b/lib/rinda/ring.rb
@@ -49,7 +49,7 @@ module Rinda
end
end
end
-
+
##
# Extracts the response URI from +msg+ and adds it to TupleSpace where it
# will be picked up by +reply_service+ for notification.
@@ -74,7 +74,7 @@ module Rinda
end
end
end
-
+
##
# Pulls lookup tuples out of the TupleSpace and sends their DRb object the
# address of the local TupleSpace.
@@ -104,7 +104,7 @@ module Rinda
# created RingFinger.
def self.finger
- unless @@finger
+ unless @@finger
@@finger = self.new
@@finger.lookup_ring_any
end
@@ -207,7 +207,7 @@ module Rinda
@rings.push(it)
end
end
-
+
@primary = queue.pop
raise('RingNotFound') if @primary.nil?
@primary
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb
index 6ca30a7b4b..113aa0de15 100644
--- a/lib/rinda/tuplespace.rb
+++ b/lib/rinda/tuplespace.rb
@@ -73,14 +73,14 @@ module Rinda
end
##
- # Reset the expiry time according to +sec_or_renewer+.
+ # Reset the expiry time according to +sec_or_renewer+.
#
# +nil+:: it is set to expire in the far future.
# +false+:: it has expired.
# Numeric:: it will expire in that many seconds.
#
# Otherwise the argument refers to some kind of renewer object
- # which will reset its expiry time.
+ # which will reset its expiry time.
def renew(sec_or_renewer)
sec, @renewer = get_renewer(sec_or_renewer)
@@ -168,7 +168,7 @@ module Rinda
def match(tuple)
@tuple.match(tuple)
end
-
+
alias === match
def make_tuple(ary) # :nodoc:
@@ -224,11 +224,11 @@ module Rinda
#
# ts = Rinda::TupleSpace.new
# observer = ts.notify 'write', [nil]
- #
+ #
# Thread.start do
# observer.each { |t| p t }
# end
- #
+ #
# 3.times { |i| ts.write [i] }
#
# Outputs:
@@ -276,7 +276,7 @@ module Rinda
it = pop
yield(it)
end
- rescue
+ rescue
ensure
cancel
end
@@ -295,16 +295,16 @@ module Rinda
def initialize
@bin = []
end
-
+
def add(tuple)
@bin.push(tuple)
end
-
+
def delete(tuple)
idx = @bin.rindex(tuple)
@bin.delete_at(idx) if idx
end
-
+
def find(&blk)
@bin.reverse_each do |x|
return x if yield(x)
diff --git a/lib/rss/0.9.rb b/lib/rss/0.9.rb
index c02b357911..28ef768274 100644
--- a/lib/rss/0.9.rb
+++ b/lib/rss/0.9.rb
@@ -8,7 +8,7 @@ module RSS
def self.append_features(klass)
super
-
+
klass.install_must_call_validator('', "")
end
end
@@ -123,7 +123,7 @@ module RSS
def not_need_to_call_setup_maker_variables
%w(image textInput)
end
-
+
class SkipDays < Element
include RSS09
@@ -146,11 +146,11 @@ module RSS
self.content = args[0]
end
end
-
+
end
-
+
end
-
+
class SkipHours < Element
include RSS09
@@ -174,13 +174,13 @@ module RSS
end
end
end
-
+
end
-
+
class Image < Element
include RSS09
-
+
%w(url title link).each do |name|
install_text_element(name, "", nil)
end
@@ -239,9 +239,9 @@ module RSS
end
end
end
-
+
class Item < Element
-
+
include RSS09
[
@@ -269,7 +269,7 @@ module RSS
@enclosure.setup_maker(item) if @enclosure
@source.setup_maker(item) if @source
end
-
+
class Source < Element
include RSS09
@@ -279,7 +279,7 @@ module RSS
].each do |name, uri, required|
install_get_attribute(name, uri, required)
end
-
+
content_setup
def initialize(*args)
@@ -341,7 +341,7 @@ module RSS
class Category < Element
include RSS09
-
+
[
["domain", "", false]
].each do |name, uri, required|
@@ -369,11 +369,11 @@ module RSS
category.domain = domain
category.content = content
end
-
+
end
end
-
+
class TextInput < Element
include RSS09
@@ -399,9 +399,9 @@ module RSS
maker.textinput
end
end
-
+
end
-
+
end
RSS09::ELEMENTS.each do |name|
@@ -412,7 +412,7 @@ module RSS
private
def initial_start_rss(tag_name, prefix, attrs, ns)
check_ns(tag_name, prefix, ns, "", false)
-
+
@rss = Rss.new(attrs['version'], @version, @encoding, @standalone)
@rss.do_validate = @do_validate
@rss.xml_stylesheets = @xml_stylesheets
@@ -422,7 +422,7 @@ module RSS
end
@proc_stack.push(pr)
end
-
+
end
end
diff --git a/lib/rss/1.0.rb b/lib/rss/1.0.rb
index 0d1e9fe685..2ff53b4723 100644
--- a/lib/rss/1.0.rb
+++ b/lib/rss/1.0.rb
@@ -8,7 +8,7 @@ module RSS
def self.append_features(klass)
super
-
+
klass.install_must_call_validator('', ::RSS::URI)
end
@@ -64,13 +64,13 @@ module RSS
URI
end
end
-
+
[
["resource", [URI, ""], true]
].each do |name, uri, required|
install_get_attribute(name, uri, required)
end
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -98,10 +98,10 @@ module RSS
end
@tag_name = 'Seq'
-
+
install_have_children_element("li", URI, "*")
install_must_call_validator('rdf', ::RSS::RDF::URI)
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -114,7 +114,7 @@ module RSS
def full_name
tag_name_with_prefix(PREFIX)
end
-
+
def setup_maker(target)
lis.each do |li|
target << li.resource
@@ -135,10 +135,10 @@ module RSS
end
@tag_name = 'Bag'
-
+
install_have_children_element("li", URI, "*")
install_must_call_validator('rdf', URI)
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -151,7 +151,7 @@ module RSS
def full_name
tag_name_with_prefix(PREFIX)
end
-
+
def setup_maker(target)
lis.each do |li|
target << li.resource
@@ -162,7 +162,7 @@ module RSS
class Channel < Element
include RSS10
-
+
class << self
def required_uri
@@ -202,17 +202,17 @@ module RSS
def maker_target(maker)
maker.channel
end
-
+
def setup_maker_attributes(channel)
channel.about = about
end
class Image < Element
-
+
include RSS10
class << self
-
+
def required_uri
::RSS::URI
end
@@ -225,7 +225,7 @@ module RSS
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -237,11 +237,11 @@ module RSS
end
class Textinput < Element
-
+
include RSS10
class << self
-
+
def required_uri
::RSS::URI
end
@@ -254,7 +254,7 @@ module RSS
install_get_attribute(name, uri, required, nil, nil,
"#{PREFIX}:#{name}")
end
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -264,7 +264,7 @@ module RSS
end
end
end
-
+
class Items < Element
include RSS10
@@ -272,16 +272,16 @@ module RSS
Seq = ::RSS::RDF::Seq
class << self
-
+
def required_uri
::RSS::URI
end
-
+
end
install_have_child_element("Seq", URI, nil)
install_must_call_validator('rdf', URI)
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -309,7 +309,7 @@ module RSS
include RSS10
class << self
-
+
def required_uri
::RSS::URI
end
@@ -351,7 +351,7 @@ module RSS
def required_uri
::RSS::URI
end
-
+
end
diff --git a/lib/rss/2.0.rb b/lib/rss/2.0.rb
index 3798da4eb7..9622c598d9 100644
--- a/lib/rss/2.0.rb
+++ b/lib/rss/2.0.rb
@@ -29,7 +29,7 @@ module RSS
Category = Item::Category
class Item
-
+
[
["comments", "?"],
["author", "?"],
@@ -57,9 +57,9 @@ module RSS
_setup_maker_element(item)
@guid.setup_maker(item) if @guid
end
-
+
class Guid < Element
-
+
include RSS09
[
diff --git a/lib/rss/converter.rb b/lib/rss/converter.rb
index 415a319188..b5a1f88c34 100644
--- a/lib/rss/converter.rb
+++ b/lib/rss/converter.rb
@@ -3,7 +3,7 @@ require "rss/utils"
module RSS
class Converter
-
+
include Utils
def initialize(to_enc, from_enc=nil)
@@ -55,11 +55,11 @@ module RSS
raise UnknownConversionMethodError.new(to_enc, from_enc)
end
end
-
+
def def_else_enc(to_enc, from_enc)
def_iconv_convert(to_enc, from_enc, 0)
end
-
+
def def_same_enc()
def_convert do |value|
value
@@ -93,40 +93,40 @@ module RSS
def def_to_euc_jp_from_utf_8
def_uconv_convert_if_can('u8toeuc', 'EUC-JP', 'UTF-8', '-We')
end
-
+
def def_to_utf_8_from_euc_jp
def_uconv_convert_if_can('euctou8', 'UTF-8', 'EUC-JP', '-Ew')
end
-
+
def def_to_shift_jis_from_utf_8
def_uconv_convert_if_can('u8tosjis', 'Shift_JIS', 'UTF-8', '-Ws')
end
-
+
def def_to_utf_8_from_shift_jis
def_uconv_convert_if_can('sjistou8', 'UTF-8', 'Shift_JIS', '-Sw')
end
-
+
def def_to_euc_jp_from_shift_jis
require "nkf"
def_convert do |value|
"NKF.nkf('-Se', #{value})"
end
end
-
+
def def_to_shift_jis_from_euc_jp
require "nkf"
def_convert do |value|
"NKF.nkf('-Es', #{value})"
end
end
-
+
def def_to_euc_jp_from_iso_2022_jp
require "nkf"
def_convert do |value|
"NKF.nkf('-Je', #{value})"
end
end
-
+
def def_to_iso_2022_jp_from_euc_jp
require "nkf"
def_convert do |value|
@@ -139,7 +139,7 @@ module RSS
"#{value}.unpack('C*').pack('U*')"
end
end
-
+
def def_to_iso_8859_1_from_utf_8
def_convert do |value|
<<-EOC
@@ -156,7 +156,7 @@ module RSS
EOC
end
end
-
+
end
-
+
end
diff --git a/lib/rss/dublincore.rb b/lib/rss/dublincore.rb
index 7ba239f8f1..53a4ca70d6 100644
--- a/lib/rss/dublincore.rb
+++ b/lib/rss/dublincore.rb
@@ -25,7 +25,7 @@ module RSS
def #{full_name}
@#{full_name}.first and @#{full_name}.first.value
end
-
+
def #{full_name}=(new_value)
@#{full_name}[0] = Utils.new_with_value_if_need(#{klass_name}, new_value)
end
@@ -50,7 +50,7 @@ module RSS
EOC
end
end
-
+
module DublinCoreModel
extend BaseModel
@@ -76,26 +76,26 @@ module RSS
DATE_ELEMENTS = {
"date" => "w3cdtf",
}
-
+
ELEMENT_NAME_INFOS = DublinCoreModel::TEXT_ELEMENTS.to_a
DublinCoreModel::DATE_ELEMENTS.each do |name, |
ELEMENT_NAME_INFOS << [name, nil]
end
-
+
ELEMENTS = TEXT_ELEMENTS.keys + DATE_ELEMENTS.keys
ELEMENTS.each do |name, plural_name|
module_eval(<<-EOC, *get_file_and_line_from_caller(0))
class DublinCore#{Utils.to_class_name(name)} < Element
include RSS10
-
+
content_setup
class << self
def required_prefix
DC_PREFIX
end
-
+
def required_uri
DC_URI
end
@@ -105,7 +105,7 @@ module RSS
alias_method(:value, :content)
alias_method(:value=, :content=)
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -114,7 +114,7 @@ module RSS
self.content = args[0]
end
end
-
+
def full_name
tag_name_with_prefix(DC_PREFIX)
end
diff --git a/lib/rss/image.rb b/lib/rss/image.rb
index c4714aea12..e79e9f5e65 100644
--- a/lib/rss/image.rb
+++ b/lib/rss/image.rb
@@ -15,7 +15,7 @@ module RSS
BaseListener.install_class_name(IMAGE_URI, name, "Image#{class_name}")
IMAGE_ELEMENTS << "#{IMAGE_PREFIX}_#{name}"
end
-
+
module ImageModelUtils
def validate_one_tag_name(ignore_unknown_element, name, tags)
if !ignore_unknown_element
@@ -25,7 +25,7 @@ module RSS
raise TooMuchTagError.new(name, tag_name) if tags.size > 1
end
end
-
+
module ImageItemModel
include ImageModelUtils
extend BaseModel
@@ -43,12 +43,12 @@ module RSS
include DublinCoreModel
@tag_name = "item"
-
+
class << self
def required_prefix
IMAGE_PREFIX
end
-
+
def required_uri
IMAGE_URI
end
@@ -102,11 +102,11 @@ module RSS
end
end
end
-
+
module ImageFaviconModel
include ImageModelUtils
extend BaseModel
-
+
def self.append_features(klass)
super
@@ -122,12 +122,12 @@ module RSS
include DublinCoreModel
@tag_name = "favicon"
-
+
class << self
def required_prefix
IMAGE_PREFIX
end
-
+
def required_uri
IMAGE_URI
end
@@ -154,7 +154,7 @@ module RSS
end
set_size(new_value)
end
-
+
alias image_size= size=
alias image_size size
diff --git a/lib/rss/maker/0.9.rb b/lib/rss/maker/0.9.rb
index dc7dd2812b..aede4d7c20 100644
--- a/lib/rss/maker/0.9.rb
+++ b/lib/rss/maker/0.9.rb
@@ -4,14 +4,14 @@ require "rss/maker/base"
module RSS
module Maker
-
+
class RSS09 < RSSBase
-
+
def initialize(feed_version)
super
@feed_type = "rss"
end
-
+
private
def make_feed
Rss.new(@feed_version, @version, @encoding, @standalone)
@@ -38,20 +38,20 @@ module RSS
raise NotSetError.new("maker.channel", _not_set_required_variables)
end
end
-
+
private
def setup_items(rss)
@maker.items.to_feed(rss)
end
-
+
def setup_image(rss)
@maker.image.to_feed(rss)
end
-
+
def setup_textinput(rss)
@maker.textinput.to_feed(rss)
end
-
+
def variables
super + ["pubDate"]
end
@@ -78,7 +78,7 @@ module RSS
end
end
end
-
+
class Day < DayBase
def to_feed(rss, days)
day = Rss::Channel::SkipDays::Day.new
@@ -96,7 +96,7 @@ module RSS
end
end
end
-
+
class SkipHours < SkipHoursBase
def to_feed(rss, channel)
unless @hours.empty?
@@ -108,7 +108,7 @@ module RSS
end
end
end
-
+
class Hour < HourBase
def to_feed(rss, hours)
hour = Rss::Channel::SkipHours::Hour.new
@@ -126,7 +126,7 @@ module RSS
end
end
end
-
+
class Cloud < CloudBase
def to_feed(*args)
end
@@ -243,7 +243,7 @@ module RSS
true
end
end
-
+
class Items < ItemsBase
def to_feed(rss)
if rss.channel
@@ -253,7 +253,7 @@ module RSS
setup_other_elements(rss, rss.items)
end
end
-
+
class Item < ItemBase
def to_feed(rss)
item = Rss::Channel::Item.new
@@ -439,7 +439,7 @@ module RSS
end
end
end
-
+
class Textinput < TextinputBase
def to_feed(rss)
textInput = Rss::Channel::TextInput.new
diff --git a/lib/rss/maker/1.0.rb b/lib/rss/maker/1.0.rb
index d77dd58d02..0d8075f836 100644
--- a/lib/rss/maker/1.0.rb
+++ b/lib/rss/maker/1.0.rb
@@ -61,7 +61,7 @@ module RSS
rss.channel.items = items
set_parent(rss.channel, items)
end
-
+
def setup_image(rss)
if @maker.image.have_required_values?
image = RDF::Channel::Image.new(@maker.image.url)
@@ -92,11 +92,11 @@ module RSS
class SkipDays < SkipDaysBase
def to_feed(*args)
end
-
+
class Day < DayBase
end
end
-
+
class SkipHours < SkipHoursBase
def to_feed(*args)
end
@@ -104,7 +104,7 @@ module RSS
class Hour < HourBase
end
end
-
+
class Cloud < CloudBase
def to_feed(*args)
end
@@ -404,7 +404,7 @@ module RSS
end
end
end
-
+
class Textinput < TextinputBase
def to_feed(rss)
if @link
diff --git a/lib/rss/maker/2.0.rb b/lib/rss/maker/2.0.rb
index 67d68126ac..15b1349c2a 100644
--- a/lib/rss/maker/2.0.rb
+++ b/lib/rss/maker/2.0.rb
@@ -4,9 +4,9 @@ require "rss/maker/0.9"
module RSS
module Maker
-
+
class RSS20 < RSS09
-
+
def initialize(feed_version="2.0")
super
end
@@ -17,17 +17,17 @@ module RSS
def required_variable_names
%w(link)
end
-
+
class SkipDays < RSS09::Channel::SkipDays
class Day < RSS09::Channel::SkipDays::Day
end
end
-
+
class SkipHours < RSS09::Channel::SkipHours
class Hour < RSS09::Channel::SkipHours::Hour
end
end
-
+
class Cloud < RSS09::Channel::Cloud
def to_feed(rss, channel)
cloud = Rss::Channel::Cloud.new
@@ -51,7 +51,7 @@ module RSS
category.to_feed(rss, channel)
end
end
-
+
class Category < RSS09::Channel::Categories::Category
def to_feed(rss, channel)
category = Rss::Channel::Category.new
@@ -81,14 +81,14 @@ module RSS
end
end
end
-
+
class Image < RSS09::Image
private
def required_element?
false
end
end
-
+
class Items < RSS09::Items
class Item < RSS09::Items::Item
private
@@ -179,7 +179,7 @@ module RSS
category.to_feed(rss, item)
end
end
-
+
class Category < RSS09::Items::Item::Categories::Category
def to_feed(rss, item)
category = Rss::Channel::Item::Category.new
@@ -212,11 +212,11 @@ module RSS
end
end
end
-
+
class Textinput < RSS09::Textinput
end
end
-
+
add_maker("2.0", "2.0", RSS20)
add_maker("rss2.0", "2.0", RSS20)
end
diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb
index 4611e45292..88ea831164 100644
--- a/lib/rss/maker/base.rb
+++ b/lib/rss/maker/base.rb
@@ -419,7 +419,7 @@ module RSS
end
EOC
end
-
+
attr_reader :feed_version
alias_method(:rss_version, :feed_version)
attr_accessor :version, :encoding, :standalone
@@ -433,7 +433,7 @@ module RSS
@encoding = "UTF-8"
@standalone = nil
end
-
+
def make
yield(self)
to_feed
@@ -447,7 +447,7 @@ module RSS
feed.validate
feed
end
-
+
private
remove_method :make_xml_stylesheets
def make_xml_stylesheets
@@ -464,7 +464,7 @@ module RSS
attr_accessor attribute
add_need_initialize_variable(attribute)
end
-
+
def to_feed(feed)
xss = ::RSS::XMLStyleSheet.new
guess_type_if_need(xss)
@@ -487,7 +487,7 @@ module RSS
end
end
end
-
+
class ChannelBase < Base
include SetupDefaultDate
@@ -574,7 +574,7 @@ module RSS
end
end
end
-
+
class SkipHoursBase < Base
def_array_element("hour")
@@ -585,7 +585,7 @@ module RSS
end
end
end
-
+
class CloudBase < Base
%w(domain port path registerProcedure protocol).each do |element|
attr_accessor element
@@ -655,7 +655,7 @@ module RSS
include AtomTextConstructBase
end
end
-
+
class ImageBase < Base
%w(title url width height description).each do |element|
attr_accessor element
@@ -666,18 +666,18 @@ module RSS
@maker.channel.link
end
end
-
+
class ItemsBase < Base
def_array_element("item")
attr_accessor :do_sort, :max_size
-
+
def initialize(maker)
super
@do_sort = false
@max_size = -1
end
-
+
def normalize
if @max_size >= 0
sort_if_need[0...@max_size]
diff --git a/lib/rss/maker/dublincore.rb b/lib/rss/maker/dublincore.rb
index ff4813fe19..9069c27d06 100644
--- a/lib/rss/maker/dublincore.rb
+++ b/lib/rss/maker/dublincore.rb
@@ -90,7 +90,7 @@ EOC
class ChannelBase
include DublinCoreModel
end
-
+
class ImageBase; include DublinCoreModel; end
class ItemsBase
class ItemBase
diff --git a/lib/rss/maker/image.rb b/lib/rss/maker/image.rb
index b95cf4c714..e2b36e0a08 100644
--- a/lib/rss/maker/image.rb
+++ b/lib/rss/maker/image.rb
@@ -89,7 +89,7 @@ EOC
end
class ChannelBase; include Maker::ImageFaviconModel; end
-
+
class ItemsBase
class ItemBase; include Maker::ImageItemModel; end
end
diff --git a/lib/rss/maker/taxonomy.rb b/lib/rss/maker/taxonomy.rb
index 211603840f..13ae9aa805 100644
--- a/lib/rss/maker/taxonomy.rb
+++ b/lib/rss/maker/taxonomy.rb
@@ -72,12 +72,12 @@ EOC
class TaxonomyTopicBase < Base
include DublinCoreModel
include TaxonomyTopicsModel
-
+
attr_accessor :value
add_need_initialize_variable("value")
alias_method(:taxo_link, :value)
alias_method(:taxo_link=, :value=)
-
+
def have_required_values?
@value
end
@@ -88,11 +88,11 @@ EOC
class RSSBase
include TaxonomyTopicModel
end
-
+
class ChannelBase
include TaxonomyTopicsModel
end
-
+
class ItemsBase
class ItemBase
include TaxonomyTopicsModel
diff --git a/lib/rss/maker/trackback.rb b/lib/rss/maker/trackback.rb
index 278fe53ebe..00f001cb85 100644
--- a/lib/rss/maker/trackback.rb
+++ b/lib/rss/maker/trackback.rb
@@ -19,7 +19,7 @@ module RSS
class TrackBackAboutBase < Base
attr_accessor :value
add_need_initialize_variable("value")
-
+
alias_method(:resource, :value)
alias_method(:resource=, :value=)
alias_method(:content, :value)
diff --git a/lib/rss/parser.rb b/lib/rss/parser.rb
index f6e192e567..1a9e71ea57 100644
--- a/lib/rss/parser.rb
+++ b/lib/rss/parser.rb
@@ -98,7 +98,7 @@ module RSS
return rss if maybe_xml?(rss)
uri = to_uri(rss)
-
+
if uri.respond_to?(:read)
uri.read
elsif !rss.tainted? and File.readable?(rss)
@@ -133,7 +133,7 @@ module RSS
listener.raise_for_undefined_entity?
end
end
-
+
def initialize(rss)
@listener = self.class.listener.new
@rss = rss
@@ -196,13 +196,13 @@ module RSS
def available_tags(uri)
(@@accessor_bases[uri] || {}).keys
end
-
+
# register uri against this name.
def register_uri(uri, name)
@@registered_uris[name] ||= {}
@@registered_uris[name][uri] = nil
end
-
+
# test if this uri is registered against this name
def uri_registered?(uri, name)
@@registered_uris[name].has_key?(uri)
@@ -228,11 +228,11 @@ module RSS
install_accessor_base(uri, name, accessor_base)
def_get_text_element(uri, name, *get_file_and_line_from_caller(1))
end
-
+
def raise_for_undefined_entity?
true
end
-
+
private
# set the accessor for the uri, tag_name pair
def install_accessor_base(uri, tag_name, accessor_base)
@@ -279,7 +279,7 @@ module RSS
@xml_element = nil
@last_xml_element = nil
end
-
+
# set instance vars for version, encoding, standalone
def xmldecl(version, encoding, standalone)
@version, @encoding, @standalone = version, encoding, standalone
diff --git a/lib/rss/rexmlparser.rb b/lib/rss/rexmlparser.rb
index 4dabf59199..7112ac3669 100644
--- a/lib/rss/rexmlparser.rb
+++ b/lib/rss/rexmlparser.rb
@@ -7,7 +7,7 @@ if ([$1.to_i, $2.to_i] <=> [2, 5]) < 0
end
module RSS
-
+
class REXMLParser < BaseParser
class << self
@@ -15,7 +15,7 @@ module RSS
REXMLListener
end
end
-
+
private
def _parse
begin
@@ -28,9 +28,9 @@ module RSS
raise NotWellFormedError.new(line){e.message}
end
end
-
+
end
-
+
class REXMLListener < BaseListener
include REXML::StreamListener
@@ -41,7 +41,7 @@ module RSS
false
end
end
-
+
def xmldecl(version, encoding, standalone)
super(version, encoding, standalone == "yes")
# Encoding is converted to UTF-8 when REXML parse XML.
diff --git a/lib/rss/rss.rb b/lib/rss/rss.rb
index f68001a47b..6f008049ca 100644
--- a/lib/rss/rss.rb
+++ b/lib/rss/rss.rb
@@ -249,7 +249,7 @@ EOC
# accessor
convert_attr_reader name
date_writer(name, type, disp_name)
-
+
install_element(name) do |n, elem_name|
<<-EOC
if @#{n}
@@ -634,7 +634,7 @@ EOC
include SetupMaker
INDENT = " "
-
+
MUST_CALL_VALIDATORS = {}
MODELS = []
GET_ATTRIBUTES = []
@@ -830,7 +830,7 @@ EOC
def full_name
tag_name
end
-
+
def converter=(converter)
@converter = converter
targets = children.dup
@@ -865,7 +865,7 @@ EOC
ensure
@do_validate = do_validate
end
-
+
def validate_for_stream(tags, ignore_unknown_element=true)
validate_attribute
__validate(ignore_unknown_element, tags, false)
@@ -985,7 +985,7 @@ EOC
end_tag = "\n#{indent}</#{full_name}>"
end
end
-
+
start_tag + content.join("\n") + end_tag
end
@@ -1010,7 +1010,7 @@ EOC
end
attrs
end
-
+
def tag_name_with_prefix(prefix)
"#{prefix}:#{tag_name}"
end
@@ -1210,7 +1210,7 @@ EOC
module RootElementMixin
include XMLStyleSheetMixin
-
+
attr_reader :output_encoding
attr_reader :feed_type, :feed_subtype, :feed_version
attr_accessor :version, :encoding, :standalone
@@ -1296,7 +1296,7 @@ EOC
rv << "?>\n"
rv
end
-
+
def ns_declarations
decls = {}
self.class::NSPOOL.collect do |prefix, uri|
diff --git a/lib/rss/syndication.rb b/lib/rss/syndication.rb
index 3eb15429f6..c375645dd6 100644
--- a/lib/rss/syndication.rb
+++ b/lib/rss/syndication.rb
@@ -8,11 +8,11 @@ module RSS
RDF.install_ns(SY_PREFIX, SY_URI)
module SyndicationModel
-
+
extend BaseModel
-
+
ELEMENTS = []
-
+
def self.append_features(klass)
super
diff --git a/lib/rss/taxonomy.rb b/lib/rss/taxonomy.rb
index 276f63b05d..b82e55dacc 100644
--- a/lib/rss/taxonomy.rb
+++ b/lib/rss/taxonomy.rb
@@ -24,7 +24,7 @@ module RSS
module TaxonomyTopicsModel
extend BaseModel
-
+
def self.append_features(klass)
super
@@ -37,21 +37,21 @@ module RSS
class TaxonomyTopics < Element
include RSS10
-
+
Bag = ::RSS::RDF::Bag
class << self
def required_prefix
TAXO_PREFIX
end
-
+
def required_uri
TAXO_URI
end
end
@tag_name = "topics"
-
+
install_have_child_element("Bag", RDF::URI, nil)
install_must_call_validator('rdf', RDF::URI)
@@ -84,10 +84,10 @@ module RSS
end
end
end
-
+
module TaxonomyTopicModel
extend BaseModel
-
+
def self.append_features(klass)
super
var_name = "#{TAXO_PREFIX}_topic"
@@ -99,12 +99,12 @@ module RSS
include DublinCoreModel
include TaxonomyTopicsModel
-
+
class << self
def required_prefix
TAXO_PREFIX
end
-
+
def required_uri
TAXO_URI
end
@@ -115,7 +115,7 @@ module RSS
install_get_attribute("about", ::RSS::RDF::URI, true, nil, nil,
"#{RDF::PREFIX}:about")
install_text_element("link", TAXO_URI, "?", "#{TAXO_PREFIX}_link")
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
diff --git a/lib/rss/trackback.rb b/lib/rss/trackback.rb
index ee2491f332..59fedb5f3e 100644
--- a/lib/rss/trackback.rb
+++ b/lib/rss/trackback.rb
@@ -23,7 +23,7 @@ module RSS
module BaseTrackBackModel
ELEMENTS = %w(ping about)
-
+
def append_features(klass)
super
@@ -47,7 +47,7 @@ module RSS
end
EOC
end
-
+
[%w(about s)].each do |name, postfix|
var_name = "#{TRACKBACK_PREFIX}_#{name}"
klass_name = "TrackBack#{Utils.to_class_name(name)}"
@@ -105,7 +105,7 @@ module RSS
def required_prefix
TRACKBACK_PREFIX
end
-
+
def required_uri
TRACKBACK_URI
end
@@ -141,17 +141,17 @@ module RSS
include RSS10
class << self
-
+
def required_prefix
TRACKBACK_PREFIX
end
-
+
def required_uri
TRACKBACK_URI
end
end
-
+
@tag_name = "about"
[
@@ -163,7 +163,7 @@ module RSS
alias_method(:value, :resource)
alias_method(:value=, :resource=)
-
+
def initialize(*args)
if Utils.element_initialize_arguments?(args)
super
@@ -185,7 +185,7 @@ module RSS
def setup_maker_attributes(about)
about.resource = self.resource
end
-
+
end
end
@@ -197,7 +197,7 @@ module RSS
include RSS09
@tag_name = "ping"
-
+
content_setup
class << self
@@ -205,13 +205,13 @@ module RSS
def required_prefix
TRACKBACK_PREFIX
end
-
+
def required_uri
TRACKBACK_URI
end
end
-
+
alias_method(:value, :content)
alias_method(:value=, :content=)
@@ -223,26 +223,26 @@ module RSS
self.content = args[0]
end
end
-
+
def full_name
tag_name_with_prefix(TRACKBACK_PREFIX)
end
-
+
end
class TrackBackAbout < Element
include RSS09
@tag_name = "about"
-
+
content_setup
class << self
-
+
def required_prefix
TRACKBACK_PREFIX
end
-
+
def required_uri
TRACKBACK_URI
end
@@ -260,11 +260,11 @@ module RSS
self.content = args[0]
end
end
-
+
def full_name
tag_name_with_prefix(TRACKBACK_PREFIX)
end
-
+
end
end
diff --git a/lib/rss/utils.rb b/lib/rss/utils.rb
index 0e4001e1f3..75b05d45c7 100644
--- a/lib/rss/utils.rb
+++ b/lib/rss/utils.rb
@@ -8,7 +8,7 @@ module RSS
"#{part[0, 1].upcase}#{part[1..-1]}"
end.join("")
end
-
+
def get_file_and_line_from_caller(i=0)
file, line, = caller[i].split(':')
line = line.to_i
@@ -21,7 +21,7 @@ module RSS
s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;")
end
alias h html_escape
-
+
# If +value+ is an instance of class +klass+, return it, else
# create a new instance of +klass+ with value +value+.
def new_with_value_if_need(klass, value)
diff --git a/lib/rss/xml-stylesheet.rb b/lib/rss/xml-stylesheet.rb
index 559d6bcd56..96ee95050e 100644
--- a/lib/rss/xml-stylesheet.rb
+++ b/lib/rss/xml-stylesheet.rb
@@ -8,7 +8,7 @@ module RSS
super
@xml_stylesheets = []
end
-
+
private
def xml_stylesheet_pi
xsss = @xml_stylesheets.collect do |xss|
@@ -94,7 +94,7 @@ module RSS
xss.__send__("#{attr}=", __send__(attr))
end
end
-
+
private
def guess_type(filename)
/\.([^.]+)$/ =~ filename
diff --git a/lib/rss/xmlparser.rb b/lib/rss/xmlparser.rb
index 3dfe7d461a..aa902be396 100644
--- a/lib/rss/xmlparser.rb
+++ b/lib/rss/xmlparser.rb
@@ -26,9 +26,9 @@ module XML
end
module RSS
-
+
class REXMLLikeXMLParser < ::XML::Parser
-
+
include ::XML::Encoding_ja
def listener=(listener)
@@ -38,7 +38,7 @@ module RSS
def startElement(name, attrs)
@listener.tag_start(name, attrs)
end
-
+
def endElement(name)
@listener.tag_end(name)
end
@@ -64,7 +64,7 @@ module RSS
XMLParserListener
end
end
-
+
private
def _parse
begin
@@ -75,13 +75,13 @@ module RSS
raise NotWellFormedError.new(parser.line){e.message}
end
end
-
+
end
-
+
class XMLParserListener < BaseListener
include ListenerMixin
-
+
def xmldecl(version, encoding, standalone)
super
# Encoding is converted to UTF-8 when XMLParser parses XML.
diff --git a/lib/rss/xmlscanner.rb b/lib/rss/xmlscanner.rb
index 61b9fa6bf4..1cdf81c0c3 100644
--- a/lib/rss/xmlscanner.rb
+++ b/lib/rss/xmlscanner.rb
@@ -2,15 +2,15 @@ require 'xmlscan/scanner'
require 'stringio'
module RSS
-
+
class XMLScanParser < BaseParser
-
+
class << self
def listener
XMLScanListener
end
end
-
+
private
def _parse
begin
@@ -26,11 +26,11 @@ module RSS
raise NotWellFormedError.new(lineno){e.message}
end
end
-
+
end
class XMLScanListener < BaseListener
-
+
include XMLScan::Visitor
include ListenerMixin
diff --git a/lib/runit/cui/testrunner.rb b/lib/runit/cui/testrunner.rb
index d521ec16ad..d32e6b98f9 100644
--- a/lib/runit/cui/testrunner.rb
+++ b/lib/runit/cui/testrunner.rb
@@ -9,15 +9,15 @@ module RUNIT
module CUI
class TestRunner < Test::Unit::UI::Console::TestRunner
@@quiet_mode = false
-
+
def self.run(suite)
self.new().run(suite)
end
-
+
def initialize
super nil
end
-
+
def run(suite, quiet_mode=@@quiet_mode)
@suite = suite
def @suite.suite
@@ -26,7 +26,7 @@ module RUNIT
@output_level = (quiet_mode ? Test::Unit::UI::PROGRESS_ONLY : Test::Unit::UI::VERBOSE)
start
end
-
+
def create_mediator(suite)
mediator = Test::Unit::UI::TestRunnerMediator.new(suite)
class << mediator
@@ -38,11 +38,11 @@ module RUNIT
mediator.result_delegate = self
return mediator
end
-
+
def create_result
return RUNIT::TestResult.new
end
-
+
def self.quiet_mode=(boolean)
@@quiet_mode = boolean
end
diff --git a/lib/runit/testcase.rb b/lib/runit/testcase.rb
index 4576cb8644..b70b7817ae 100644
--- a/lib/runit/testcase.rb
+++ b/lib/runit/testcase.rb
@@ -9,9 +9,9 @@ require 'runit/error'
require 'test/unit/testcase'
module RUNIT
- class TestCase < Test::Unit::TestCase
+ class TestCase < Test::Unit::TestCase
include RUNIT::Assert
-
+
def self.suite
method_names = instance_methods(true)
tests = method_names.delete_if { |method_name| method_name !~ /^test/ }
@@ -24,19 +24,19 @@ module RUNIT
}
return suite
end
-
+
def initialize(test_name, suite_name=self.class.name)
super(test_name)
end
-
+
def assert_equals(*args)
assert_equal(*args)
end
-
+
def name
super.sub(/^(.*?)\((.*)\)$/, '\2#\1')
end
-
+
def run(result, &progress_block)
progress_block = proc {} unless (block_given?)
super(result, &progress_block)
diff --git a/lib/runit/testsuite.rb b/lib/runit/testsuite.rb
index 63baf65707..82a07e7c4c 100644
--- a/lib/runit/testsuite.rb
+++ b/lib/runit/testsuite.rb
@@ -9,15 +9,15 @@ module RUNIT
def add_test(*args)
add(*args)
end
-
+
def add(*args)
self.<<(*args)
end
-
+
def count_test_cases
return size
end
-
+
def run(result, &progress_block)
progress_block = proc {} unless (block_given?)
super(result, &progress_block)
diff --git a/lib/scanf.rb b/lib/scanf.rb
index a54485661d..1a3aa51af9 100644
--- a/lib/scanf.rb
+++ b/lib/scanf.rb
@@ -63,7 +63,7 @@ to the beginning of the format string, and yields a new array of
conversions to the block every time the format string is matched
(including partial matches, but not including complete failures). The
actual return value of scanf when called with a block is an array
-containing the results of all the executions of the block.
+containing the results of all the executions of the block.
str = "123 abc 456 def 789 ghi"
str.scanf("%d%s") { |num,str| [ num * 2, str.upcase ] }
@@ -100,7 +100,7 @@ and <tt>tests/scanftests.rb</tt> for examples.)
[u]
Same as d.
-[i]
+[i]
Matches an optionally signed integer. The integer is read in base
16 if it begins with `0x' or `0X', in base 8 if it begins with `0',
and in base 10 other- wise. Only characters that correspond to the
@@ -280,7 +280,7 @@ Project contributors:: Nolan Darilek, Jason Johnston
Thanks to Hal Fulton for hosting the Codefest.
-Thanks to Matz for suggestions about the class design.
+Thanks to Matz for suggestions about the class design.
Thanks to Gavin Sinclair for some feedback on the documentation.
@@ -332,7 +332,7 @@ module Scanf
@spec_string = str
h = '[A-Fa-f0-9]'
- @re_string, @handler =
+ @re_string, @handler =
case @spec_string
# %[[:...:]]
@@ -482,7 +482,7 @@ module Scanf
return width_left || cc_no_width
end
-
+
end
class FormatString
@@ -671,10 +671,10 @@ class String
if b
block_scanf(fstr,&b)
else
- fs =
+ fs =
if fstr.is_a? Scanf::FormatString
- fstr
- else
+ fstr
+ else
Scanf::FormatString.new(fstr)
end
fs.match(self)
diff --git a/lib/set.rb b/lib/set.rb
index e0451b65d2..0f94ed9e82 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -4,15 +4,15 @@
#++
# Copyright (c) 2002-2008 Akinori MUSHA <[email protected]>
#
-# Documentation by Akinori MUSHA and Gavin Sinclair.
+# Documentation by Akinori MUSHA and Gavin Sinclair.
#
# All rights reserved. You can redistribute and/or modify it under the same
# terms as Ruby.
#
# $Id$
#
-# == Overview
-#
+# == Overview
+#
# This library provides the Set class, which deals with a collection
# of unordered values with no duplicates. It is a hybrid of Array's
# intuitive inter-operation facilities and Hash's fast lookup. If you
@@ -442,35 +442,35 @@ class Set
end
end
-#
+#
# SortedSet implements a Set that guarantees that it's element are
# yielded in sorted order (according to the return values of their
# #<=> methods) when iterating over them.
-#
+#
# All elements that are added to a SortedSet must respond to the <=>
# method for comparison.
-#
+#
# Also, all elements must be <em>mutually comparable</em>: <tt>el1 <=>
# el2</tt> must not return <tt>nil</tt> for any elements <tt>el1</tt>
# and <tt>el2</tt>, else an ArgumentError will be raised when
# iterating over the SortedSet.
#
# == Example
-#
+#
# require "set"
-#
+#
# set = SortedSet.new([2, 1, 5, 6, 4, 5, 3, 3, 3])
# ary = []
-#
+#
# set.each do |obj|
# ary << obj
# end
-#
+#
# p ary # => [1, 2, 3, 4, 5, 6]
-#
+#
# set2 = SortedSet.new([1, 2, "3"])
# set2.each { |obj| } # => raises ArgumentError: comparison of Fixnum with String failed
-#
+#
class SortedSet < Set
@@setup = false
@@ -495,7 +495,7 @@ class SortedSet < Set
@hash = RBTree.new
super
end
-
+
def add(o)
o.respond_to?(:<=>) or raise ArgumentError, "value must repond to <=>"
super
@@ -580,33 +580,33 @@ end
# == RestricedSet class
# RestricedSet implements a set with restrictions defined by a given
# block.
-#
+#
# === Super class
# Set
-#
+#
# === Class Methods
# --- RestricedSet::new(enum = nil) { |o| ... }
# --- RestricedSet::new(enum = nil) { |rset, o| ... }
# Creates a new restricted set containing the elements of the given
# enumerable object. Restrictions are defined by the given block.
-#
+#
# If the block's arity is 2, it is called with the RestrictedSet
# itself and an object to see if the object is allowed to be put in
# the set.
-#
+#
# Otherwise, the block is called with an object to see if the object
# is allowed to be put in the set.
-#
+#
# === Instance Methods
# --- restriction_proc
# Returns the restriction procedure of the set.
-#
+#
# =end
-#
+#
# class RestricedSet < Set
# def initialize(*args, &block)
# @proc = block or raise ArgumentError, "missing a block"
-#
+#
# if @proc.arity == 2
# instance_eval %{
# def add(o)
@@ -614,7 +614,7 @@ end
# self
# end
# alias << add
-#
+#
# def add?(o)
# if include?(o) || [email protected](self, o)
# nil
@@ -623,19 +623,19 @@ end
# self
# end
# end
-#
+#
# def replace(enum)
# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
# clear
# enum.each { |o| add(o) }
-#
+#
# self
# end
-#
+#
# def merge(enum)
# enum.is_a?(Enumerable) or raise ArgumentError, "value must be enumerable"
# enum.each { |o| add(o) }
-#
+#
# self
# end
# }
@@ -643,12 +643,12 @@ end
# instance_eval %{
# def add(o)
# if @proc.call(o)
-# @hash[o] = true
+# @hash[o] = true
# end
# self
# end
# alias << add
-#
+#
# def add?(o)
# if include?(o) || [email protected](o)
# nil
@@ -659,10 +659,10 @@ end
# end
# }
# end
-#
+#
# super(*args)
# end
-#
+#
# def restriction_proc
# @proc
# end
@@ -1269,33 +1269,33 @@ end
# class TC_RestricedSet < Test::Unit::TestCase
# def test_s_new
# assert_raises(ArgumentError) { RestricedSet.new }
-#
+#
# s = RestricedSet.new([-1,2,3]) { |o| o > 0 }
# assert_equal([2,3], s.sort)
# end
-#
+#
# def test_restriction_proc
# s = RestricedSet.new([-1,2,3]) { |o| o > 0 }
-#
+#
# f = s.restriction_proc
# assert_instance_of(Proc, f)
# assert(f[1])
# assert(!f[0])
# end
-#
+#
# def test_replace
# s = RestricedSet.new(-3..3) { |o| o > 0 }
# assert_equal([1,2,3], s.sort)
-#
+#
# s.replace([-2,0,3,4,5])
# assert_equal([3,4,5], s.sort)
# end
-#
+#
# def test_merge
# s = RestricedSet.new { |o| o > 0 }
# s.merge(-5..5)
# assert_equal([1,2,3,4,5], s.sort)
-#
+#
# s.merge([10,-10,-8,8])
# assert_equal([1,2,3,4,5,8,10], s.sort)
# end
diff --git a/lib/shell.rb b/lib/shell.rb
index 039f849ef5..3593ca55c2 100644
--- a/lib/shell.rb
+++ b/lib/shell.rb
@@ -1,5 +1,5 @@
#
-# shell.rb -
+# shell.rb -
# $Release Version: 0.6.0 $
# $Revision: 1.8 $
# $Date: 2001/03/19 09:01:11 $
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
diff --git a/lib/shell/builtin-command.rb b/lib/shell/builtin-command.rb
index db1adfa48b..038da08e82 100644
--- a/lib/shell/builtin-command.rb
+++ b/lib/shell/builtin-command.rb
@@ -1,5 +1,5 @@
#
-# shell/builtin-command.rb -
+# shell/builtin-command.rb -
# $Release Version: 0.6.0 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "shell/filter"
@@ -27,7 +27,7 @@ class Shell
super sh
@strings = strings
end
-
+
def each(rs = nil)
rs = @shell.record_separator unless rs
for str in @strings
diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb
index 87575bcb18..80f9fa45f0 100644
--- a/lib/shell/command-processor.rb
+++ b/lib/shell/command-processor.rb
@@ -1,5 +1,5 @@
#
-# shell/command-controller.rb -
+# shell/command-controller.rb -
# $Release Version: 0.6.0 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
@@ -35,7 +35,7 @@ class Shell
for m in CommandProcessor.instance_methods(false) - NoDelegateMethods
add_delegate_command_to_shell(m)
end
-
+
def self.method_added(id)
add_delegate_command_to_shell(id)
end
@@ -80,7 +80,7 @@ class Shell
# Shell#test
#
# -
- #
+ #
# CommandProcessor#foreach(path, rs)
# path: String
# rs: String - record separator
@@ -154,7 +154,7 @@ class Shell
# sh["e", "foo"]
# sh[:exists?, "foo"]
# sh["exists?", "foo"]
- #
+ #
alias top_level_test test
def test(command, file1, file2=nil)
file1 = expand_path(file1)
@@ -197,7 +197,7 @@ class Shell
# CommandProcessor#mkdir(*path)
# path: String
# same as Dir.mkdir()
- #
+ #
def mkdir(*path)
for dir in path
Dir.mkdir(expand_path(dir))
@@ -208,7 +208,7 @@ class Shell
# CommandProcessor#rmdir(*path)
# path: String
# same as Dir.rmdir()
- #
+ #
def rmdir(*path)
for dir in path
Dir.rmdir(expand_path(dir))
@@ -224,7 +224,7 @@ class Shell
# example:
# print sh.system("ls", "-l")
# sh.system("ls", "-l") | sh.head > STDOUT
- #
+ #
def system(command, *opts)
if opts.empty?
if command =~ /\*|\?|\{|\}|\[|\]|<|>|\(|\)|~|&|\||\\|\$|;|'|`|"|\n/
@@ -307,7 +307,7 @@ class Shell
Thread.exclusive do
Shell.notify(*opts) {|mes|
yield mes if iterator?
-
+
mes.gsub!("%pwd", "#{@cwd}")
mes.gsub!("%cwd", "#{@cwd}")
}
@@ -369,10 +369,10 @@ class Shell
SystemCommand.new(@shell, '#{path}', *opts)
end]), nil, __FILE__, __LINE__ - 1)
rescue SyntaxError
- Shell.notify "warn: Can't define #{command} path: #{path}."
+ Shell.notify "warn: Can't define #{command} path: #{path}."
end
Shell.notify "Define #{command} path: #{path}.", Shell.debug?
- Shell.notify("Definition of #{command}: ", d,
+ Shell.notify("Definition of #{command}: ", d,
Shell.debug.kind_of?(Integer) && Shell.debug > 1)
end
@@ -404,7 +404,7 @@ class Shell
@shell.__send__(:#{command},
*(CommandProcessor.alias_map[:#{ali}].call *opts))
end]), nil, __FILE__, __LINE__ - 1)
-
+
else
args = opts.collect{|opt| '"' + opt + '"'}.join(",")
eval((d = %Q[def #{ali}(*opts)
@@ -412,22 +412,22 @@ class Shell
end]), nil, __FILE__, __LINE__ - 1)
end
rescue SyntaxError
- Shell.notify "warn: Can't alias #{ali} command: #{command}."
+ Shell.notify "warn: Can't alias #{ali} command: #{command}."
Shell.notify("Definition of #{ali}: ", d)
raise
end
Shell.notify "Define #{ali} command: #{command}.", Shell.debug?
- Shell.notify("Definition of #{ali}: ", d,
+ Shell.notify("Definition of #{ali}: ", d,
Shell.debug.kind_of?(Integer) && Shell.debug > 1)
self
end
-
+
def self.unalias_command(ali)
ali = ali.id2name if ali.kind_of?(Symbol)
@alias_map.delete ali.intern
undef_system_command(ali)
end
-
+
#
# CommandProcessor.def_builtin_commands(delegation_class, command_specs)
# delegation_class: Class or Module
@@ -458,7 +458,7 @@ class Shell
#{delegation_class}.#{meth}(#{call_arg_str})
end]
Shell.notify "Define #{meth}(#{arg_str})", Shell.debug?
- Shell.notify("Definition of #{meth}: ", d,
+ Shell.notify("Definition of #{meth}: ", d,
Shell.debug.kind_of?(Integer) && Shell.debug > 1)
eval d
end
@@ -499,7 +499,7 @@ class Shell
#----------------------------------------------------------------------
#
- # class initializing methods -
+ # class initializing methods -
#
#----------------------------------------------------------------------
def self.add_delegate_command_to_shell(id)
@@ -547,7 +547,7 @@ class Shell
normal_delegation_file_methods = [
["atime", ["FILENAME"]],
["basename", ["fn", "*opts"]],
- ["chmod", ["mode", "*FILENAMES"]],
+ ["chmod", ["mode", "*FILENAMES"]],
["chown", ["owner", "group", "*FILENAME"]],
["ctime", ["FILENAMES"]],
["delete", ["*FILENAMES"]],
@@ -570,7 +570,7 @@ class Shell
alias_method :rm, :delete
# method related FileTest
- def_builtin_commands(FileTest,
+ def_builtin_commands(FileTest,
FileTest.singleton_methods(false).collect{|m| [m, ["FILENAME"]]})
# method related ftools
diff --git a/lib/shell/error.rb b/lib/shell/error.rb
index d338b1c5d1..01de7552c2 100644
--- a/lib/shell/error.rb
+++ b/lib/shell/error.rb
@@ -1,5 +1,5 @@
#
-# shell/error.rb -
+# shell/error.rb -
# $Release Version: 0.6.0 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "e2mmap"
diff --git a/lib/shell/filter.rb b/lib/shell/filter.rb
index 27c5534695..c2932aa777 100644
--- a/lib/shell/filter.rb
+++ b/lib/shell/filter.rb
@@ -1,5 +1,5 @@
#
-# shell/filter.rb -
+# shell/filter.rb -
# $Release Version: 0.6.0 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
class Shell
@@ -29,7 +29,7 @@ class Shell
def input=(filter)
@input = filter
end
-
+
def each(rs = nil)
rs = @shell.record_separator unless rs
if @input
diff --git a/lib/shell/process-controller.rb b/lib/shell/process-controller.rb
index 04a1b5b302..31009fead8 100644
--- a/lib/shell/process-controller.rb
+++ b/lib/shell/process-controller.rb
@@ -1,5 +1,5 @@
#
-# shell/process-controller.rb -
+# shell/process-controller.rb -
# $Release Version: 0.6.0 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "mutex_m"
@@ -24,10 +24,10 @@ class Shell
def process_controllers_exclusive
begin
- @ProcessControllers.lock unless Thread.critical
+ @ProcessControllers.lock unless Thread.critical
yield
ensure
- @ProcessControllers.unlock unless Thread.critical
+ @ProcessControllers.unlock unless Thread.critical
end
end
@@ -83,7 +83,7 @@ class Shell
def waiting_jobs
@waiting_jobs
end
-
+
def jobs_exist?
@jobs_sync.synchronize(:SH) do
@active_jobs.empty? or @waiting_jobs.empty?
@@ -202,18 +202,18 @@ class Shell
jobs.flush
end
end
-
+
pid = fork {
Thread.critical = true
- Thread.list.each do |th|
+ Thread.list.each do |th|
th.kill unless [Thread.main, Thread.current].include?(th)
end
STDIN.reopen(pipe_peer_in)
STDOUT.reopen(pipe_peer_out)
- ObjectSpace.each_object(IO) do |io|
+ ObjectSpace.each_object(IO) do |io|
if ![STDIN, STDOUT, STDERR].include?(io)
io.close unless io.closed?
end
@@ -246,7 +246,7 @@ class Shell
redo
end
Thread.exclusive do
- @job_monitor.synchronize do
+ @job_monitor.synchronize do
terminate_job(command)
@job_condition.signal
command.notify "job(%id) finish.", @shell.debug?
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
index f87ba890ea..94ab4b065d 100644
--- a/lib/shell/system-command.rb
+++ b/lib/shell/system-command.rb
@@ -1,5 +1,5 @@
#
-# shell/system-command.rb -
+# shell/system-command.rb -
# $Release Version: 0.6.0 $
# $Revision$
# $Date$
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
require "shell/filter"
@@ -21,7 +21,7 @@ class Shell
super(sh)
@command = command
@opts = opts
-
+
@input_queue = Queue.new
@pid = nil
@@ -148,9 +148,9 @@ class Shell
end
# ex)
- # if you wish to output:
+ # if you wish to output:
# "shell: job(#{@command}:#{@pid}) close pipe-out."
- # then
+ # then
# mes: "job(%id) close pipe-out."
# yorn: Boolean(@shell.debug? or @shell.verbose?)
def notify(*opts, &block)
diff --git a/lib/shell/version.rb b/lib/shell/version.rb
index 6694c804d8..9788d37ac1 100644
--- a/lib/shell/version.rb
+++ b/lib/shell/version.rb
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
class Shell
diff --git a/lib/soap/mapping/registry.rb b/lib/soap/mapping/registry.rb
index 823e80666d..c577e48756 100644
--- a/lib/soap/mapping/registry.rb
+++ b/lib/soap/mapping/registry.rb
@@ -23,7 +23,7 @@ end
module Mapping
-
+
module MappedException; end
@@ -453,7 +453,7 @@ private
elsif obj.is_a?(SOAPBasetype)
return obj
end
- begin
+ begin
ret = @map.obj2soap(obj) ||
@default_factory.obj2soap(nil, obj, nil, self)
return ret if ret
diff --git a/lib/soap/mapping/wsdlliteralregistry.rb b/lib/soap/mapping/wsdlliteralregistry.rb
index 7bb8e12203..f816079051 100644
--- a/lib/soap/mapping/wsdlliteralregistry.rb
+++ b/lib/soap/mapping/wsdlliteralregistry.rb
@@ -222,7 +222,7 @@ private
end
end
end
-
+
def add_attributes2soap(obj, ele)
attributes = schema_attribute_definition(obj.class)
if attributes
diff --git a/lib/soap/netHttpClient.rb b/lib/soap/netHttpClient.rb
index 10d68e2a4c..8048fa3ef1 100644
--- a/lib/soap/netHttpClient.rb
+++ b/lib/soap/netHttpClient.rb
@@ -42,7 +42,7 @@ class NetHttpClient
def test_loopback_response
raise NotImplementedError.new("not supported for now")
end
-
+
def proxy=(proxy)
if proxy.nil?
@proxy = nil
diff --git a/lib/soap/rpc/cgistub.rb b/lib/soap/rpc/cgistub.rb
index 487f05a9bf..50197d9222 100644
--- a/lib/soap/rpc/cgistub.rb
+++ b/lib/soap/rpc/cgistub.rb
@@ -84,7 +84,7 @@ class CGIStub < Logger::Application
@soaplet = ::SOAP::RPC::SOAPlet.new(@router)
on_init
end
-
+
def on_init
# do extra initialization in a derived class if needed.
end
diff --git a/lib/soap/rpc/httpserver.rb b/lib/soap/rpc/httpserver.rb
index 6d2a72ebe3..d357ff673c 100644
--- a/lib/soap/rpc/httpserver.rb
+++ b/lib/soap/rpc/httpserver.rb
@@ -71,7 +71,7 @@ class HTTPServer < Logger::Application
def add_rpc_servant(obj, namespace = @default_namespace)
@router.add_rpc_servant(obj, namespace)
end
-
+
def add_request_headerhandler(factory)
@router.add_request_headerhandler(factory)
end
diff --git a/lib/soap/rpc/proxy.rb b/lib/soap/rpc/proxy.rb
index 7dfda62006..096edf98d2 100644
--- a/lib/soap/rpc/proxy.rb
+++ b/lib/soap/rpc/proxy.rb
@@ -401,7 +401,7 @@ private
params = {}
idx = 0
method.input_params.each do |name|
- params[name] = Mapping.obj2soap(values[idx], mapping_registry,
+ params[name] = Mapping.obj2soap(values[idx], mapping_registry,
XSD::QName.new(nil, name), opt)
idx += 1
end
diff --git a/lib/soap/rpc/router.rb b/lib/soap/rpc/router.rb
index 71c6eb625b..33ad441658 100644
--- a/lib/soap/rpc/router.rb
+++ b/lib/soap/rpc/router.rb
@@ -462,7 +462,7 @@ private
response_rpc_lit(result, literal_mapping_registry, opt)
end
end
-
+
def response_doc(result, mapping_registry, literal_mapping_registry, opt)
if @doc_response_qnames.size == 1 and !result.is_a?(Array)
result = [result]
diff --git a/lib/soap/streamHandler.rb b/lib/soap/streamHandler.rb
index 672396ecce..e5a9a254e7 100644
--- a/lib/soap/streamHandler.rb
+++ b/lib/soap/streamHandler.rb
@@ -74,10 +74,10 @@ class HTTPStreamHandler < StreamHandler
public
-
+
attr_reader :client
attr_accessor :wiredump_file_base
-
+
MAX_RETRY_COUNT = 10 # [times]
def initialize(options)
diff --git a/lib/soap/wsdlDriver.rb b/lib/soap/wsdlDriver.rb
index eba9608df5..10d3cf5a27 100644
--- a/lib/soap/wsdlDriver.rb
+++ b/lib/soap/wsdlDriver.rb
@@ -28,7 +28,7 @@ class WSDLDriverFactory
@wsdl = import(wsdl)
@methoddefcreator = WSDL::SOAP::MethodDefCreator.new(@wsdl)
end
-
+
def inspect
"#<#{self.class}:#{@wsdl.name}>"
end
diff --git a/lib/sync.rb b/lib/sync.rb
index c40ae2396f..00b7c57c17 100644
--- a/lib/sync.rb
+++ b/lib/sync.rb
@@ -36,7 +36,7 @@
# Sync#lock(mode) -- mode = :EX, :SH, :UN
# Sync#unlock
# Sync#synchronize(mode) {...}
-#
+#
#
unless defined? Thread
@@ -45,26 +45,26 @@ end
module Sync_m
RCS_ID='-$Id$-'
-
+
# lock mode
UN = :UN
SH = :SH
EX = :EX
-
+
# exceptions
class Err < StandardError
def Err.Fail(*opt)
Thread.critical = false
fail self, sprintf(self::Message, *opt)
end
-
+
class UnknownLocker < Err
Message = "Thread(%s) not locked."
def UnknownLocker.Fail(th)
super(th.inspect)
end
end
-
+
class LockModeFailer < Err
Message = "Unknown lock mode(%s)"
def LockModeFailer.Fail(mode)
@@ -75,7 +75,7 @@ module Sync_m
end
end
end
-
+
def Sync_m.define_aliases(cl)
cl.module_eval %q{
alias locked? sync_locked?
@@ -87,7 +87,7 @@ module Sync_m
alias synchronize sync_synchronize
}
end
-
+
def Sync_m.append_features(cl)
super
unless cl.instance_of?(Module)
@@ -96,7 +96,7 @@ module Sync_m
define_aliases(cl)
end
end
-
+
def Sync_m.extend_object(obj)
super
obj.sync_extended
@@ -119,25 +119,25 @@ module Sync_m
def sync_locked?
sync_mode != UN
end
-
+
def sync_shared?
sync_mode == SH
end
-
+
def sync_exclusive?
sync_mode == EX
end
-
+
# locking methods.
def sync_try_lock(mode = EX)
return unlock if mode == UN
-
+
Thread.critical = true
ret = sync_try_lock_sub(mode)
Thread.critical = false
ret
end
-
+
def sync_lock(m = EX)
return unlock if m == UN
@@ -153,22 +153,22 @@ module Sync_m
Thread.critical = false
self
end
-
+
def sync_unlock(m = EX)
Thread.critical = true
if sync_mode == UN
Thread.critical = false
Err::UnknownLocker.Fail(Thread.current)
end
-
+
m = sync_mode if m == EX and sync_mode == SH
-
+
runnable = false
case m
when UN
Thread.critical = false
Err::UnknownLocker.Fail(Thread.current)
-
+
when EX
if sync_ex_locker == Thread.current
if (self.sync_ex_count = sync_ex_count - 1) == 0
@@ -183,12 +183,12 @@ module Sync_m
else
Err::UnknownLocker.Fail(Thread.current)
end
-
+
when SH
if (count = sync_sh_locker[Thread.current]).nil?
Err::UnknownLocker.Fail(Thread.current)
else
- if (sync_sh_locker[Thread.current] = count - 1) == 0
+ if (sync_sh_locker[Thread.current] = count - 1) == 0
sync_sh_locker.delete(Thread.current)
if sync_sh_locker.empty? and sync_ex_count == 0
self.sync_mode = UN
@@ -197,7 +197,7 @@ module Sync_m
end
end
end
-
+
if runnable
if sync_upgrade_waiting.size > 0
for k, v in sync_upgrade_waiting
@@ -206,7 +206,7 @@ module Sync_m
wait = sync_upgrade_waiting
self.sync_upgrade_waiting = []
Thread.critical = false
-
+
for w, v in wait
w.run
end
@@ -219,11 +219,11 @@ module Sync_m
end
end
end
-
+
Thread.critical = false
self
end
-
+
def sync_synchronize(mode = EX)
begin
sync_lock(mode)
@@ -234,13 +234,13 @@ module Sync_m
end
attr :sync_mode, true
-
+
attr :sync_waiting, true
attr :sync_upgrade_waiting, true
attr :sync_sh_locker, true
attr :sync_ex_locker, true
attr :sync_ex_count, true
-
+
private
def sync_initialize
@@ -256,7 +256,7 @@ module Sync_m
sync_initialize
super
end
-
+
def sync_try_lock_sub(m)
case m
when SH
@@ -280,7 +280,7 @@ module Sync_m
end
when EX
if sync_mode == UN or
- sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
+ sync_mode == SH && sync_sh_locker.size == 1 && sync_sh_locker.include?(Thread.current)
self.sync_mode = m
self.sync_ex_locker = Thread.current
self.sync_ex_count = 1
@@ -303,10 +303,10 @@ Synchronizer_m = Sync_m
class Sync
#Sync_m.extend_class self
include Sync_m
-
+
def initialize
super
end
-
+
end
Synchronizer = Sync
diff --git a/lib/tempfile.rb b/lib/tempfile.rb
index 01c275540a..a88c1c5eaf 100644
--- a/lib/tempfile.rb
+++ b/lib/tempfile.rb
@@ -34,7 +34,7 @@ class Tempfile < DelegateClass(File)
lock = nil
n = failure = 0
-
+
begin
Thread.critical = true
@@ -79,7 +79,7 @@ class Tempfile < DelegateClass(File)
else
prefix, suffix = basename, ''
end
-
+
t = Time.now.strftime("%Y%m%d")
path = "#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}-#{n}#{suffix}"
end
@@ -97,7 +97,7 @@ class Tempfile < DelegateClass(File)
@tmpfile.close if @tmpfile
@tmpfile = nil
@data[1] = nil if @data
- end
+ end
protected :_close
# Closes the file. If the optional flag is true, unlinks the file
@@ -163,7 +163,7 @@ class Tempfile < DelegateClass(File)
end
def call(arg=nil)
- if @pid == $$
+ if @pid == $$
path, tmpfile, cleanlist = *@data
print "removing ", path, "..." if $DEBUG
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index b224dc62f8..c5e9111bb9 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -4,9 +4,9 @@ require 'test/unit/autorunner'
module Test # :nodoc:
#
# = Test::Unit - Ruby Unit Testing Framework
- #
+ #
# == Introduction
- #
+ #
# Unit testing is making waves all over the place, largely due to the
# fact that it is a core practice of XP. While XP is great, unit testing
# has been around for a long time and has always been a good idea. One
@@ -18,19 +18,19 @@ module Test # :nodoc:
# as possible, you slowly build up a wall of things that cannot break
# without you immediately knowing about it. This is when unit testing
# hits its peak usefulness.
- #
+ #
# Enter Test::Unit, a framework for unit testing in Ruby, helping you to
# design, debug and evaluate your code by making it easy to write and
# have tests for it.
- #
- #
+ #
+ #
# == Notes
- #
+ #
# Test::Unit has grown out of and superceded Lapidary.
- #
- #
+ #
+ #
# == Feedback
- #
+ #
# I like (and do my best to practice) XP, so I value early releases,
# user feedback, and clean, simple, expressive code. There is always
# room for improvement in everything I do, and Test::Unit is no
@@ -41,68 +41,68 @@ module Test # :nodoc:
# hear about any successes you have with Test::Unit, and any
# documentation you might add will be greatly appreciated. My contact
# info is below.
- #
- #
+ #
+ #
# == Contact Information
- #
+ #
# A lot of discussion happens about Ruby in general on the ruby-talk
# mailing list (http://www.ruby-lang.org/en/ml.html), and you can ask
# any questions you might have there. I monitor the list, as do many
# other helpful Rubyists, and you're sure to get a quick answer. Of
# course, you're also welcome to email me (Nathaniel Talbott) directly
# at mailto:[email protected], and I'll do my best to help you out.
- #
- #
+ #
+ #
# == Credits
- #
+ #
# I'd like to thank...
- #
+ #
# Matz, for a great language!
- #
+ #
# Masaki Suketa, for his work on RubyUnit, which filled a vital need in
# the Ruby world for a very long time. I'm also grateful for his help in
# polishing Test::Unit and getting the RubyUnit compatibility layer
# right. His graciousness in allowing Test::Unit to supercede RubyUnit
# continues to be a challenge to me to be more willing to defer my own
# rights.
- #
+ #
# Ken McKinlay, for his interest and work on unit testing, and for his
# willingness to dialog about it. He was also a great help in pointing
# out some of the holes in the RubyUnit compatibility layer.
- #
+ #
# Dave Thomas, for the original idea that led to the extremely simple
# "require 'test/unit'", plus his code to improve it even more by
# allowing the selection of tests from the command-line. Also, without
# RDoc, the documentation for Test::Unit would stink a lot more than it
# does now.
- #
+ #
# Everyone who's helped out with bug reports, feature ideas,
# encouragement to continue, etc. It's a real privilege to be a part of
# the Ruby community.
- #
+ #
# The guys at RoleModel Software, for putting up with me repeating, "But
# this would be so much easier in Ruby!" whenever we're coding in Java.
- #
+ #
# My Creator, for giving me life, and giving it more abundantly.
- #
- #
+ #
+ #
# == License
- #
+ #
# Test::Unit is copyright (c) 2000-2003 Nathaniel Talbott. It is free
# software, and is distributed under the Ruby license. See the COPYING
# file in the standard Ruby distribution for details.
- #
- #
+ #
+ #
# == Warranty
- #
+ #
# This software is provided "as is" and without any express or
# implied warranties, including, without limitation, the implied
# warranties of merchantibility and fitness for a particular
# purpose.
- #
- #
+ #
+ #
# == Author
- #
+ #
# Nathaniel Talbott.
# Copyright (c) 2000-2003, Nathaniel Talbott
#
@@ -178,14 +178,14 @@ module Test # :nodoc:
# commented out to indicate that they are completely optional):
#
# require 'test/unit'
- #
+ #
# class TC_MyTest < Test::Unit::TestCase
# # def setup
# # end
- #
+ #
# # def teardown
# # end
- #
+ #
# def test_fail
# assert(false, 'Assertion was false.')
# end
diff --git a/lib/test/unit/assertions.rb b/lib/test/unit/assertions.rb
index aa97799de8..807b56f1ec 100644
--- a/lib/test/unit/assertions.rb
+++ b/lib/test/unit/assertions.rb
@@ -42,7 +42,7 @@ module Test
# end
public
- def assert_block(message="assert_block failed.") # :yields:
+ def assert_block(message="assert_block failed.") # :yields:
_wrap_assertion do
if (! yield)
raise AssertionFailedError.new(message.to_s)
@@ -355,7 +355,7 @@ EOT
end
##
- # Passes if +regexp+ !~ +string+
+ # Passes if +regexp+ !~ +string+
#
# Example:
# assert_no_match(/two/, 'one 2 three')
@@ -500,7 +500,7 @@ EOT
return yield
end
end
-
+
##
# Called whenever an assertion is made. Define this in classes that
# include Test::Unit::Assertions to record assertion counts.
@@ -517,7 +517,7 @@ EOT
def self.use_pp=(value)
AssertionMessage.use_pp = value
end
-
+
# :stopdoc:
class AssertionMessage
@@ -530,7 +530,7 @@ EOT
def initialize(value)
@value = value
end
-
+
def inspect
@value.to_s
end
@@ -604,7 +604,7 @@ EOM
def to_s
message_parts = []
if (@head)
- head = @head.to_s
+ head = @head.to_s
unless(head.empty?)
message_parts << add_period(head)
end
diff --git a/lib/test/unit/autorunner.rb b/lib/test/unit/autorunner.rb
index 86c9b12940..6b89ca547d 100644
--- a/lib/test/unit/autorunner.rb
+++ b/lib/test/unit/autorunner.rb
@@ -11,7 +11,7 @@ module Test
r.process_args(argv)
r.run
end
-
+
def self.standalone?
return false unless("-e" == $0)
ObjectSpace.each_object(Class) do |klass|
diff --git a/lib/test/unit/collector/objectspace.rb b/lib/test/unit/collector/objectspace.rb
index d1127a981f..eab313779d 100644
--- a/lib/test/unit/collector/objectspace.rb
+++ b/lib/test/unit/collector/objectspace.rb
@@ -9,14 +9,14 @@ module Test
module Collector
class ObjectSpace
include Collector
-
+
NAME = 'collected from the ObjectSpace'
-
+
def initialize(source=::ObjectSpace)
super()
@source = source
end
-
+
def collect(name=NAME)
suite = TestSuite.new(name)
sub_suites = []
diff --git a/lib/test/unit/failure.rb b/lib/test/unit/failure.rb
index 832c99857c..2d798c6fa1 100644
--- a/lib/test/unit/failure.rb
+++ b/lib/test/unit/failure.rb
@@ -11,7 +11,7 @@ module Test
# when an assertion fails.
class Failure
attr_reader :test_name, :location, :message
-
+
SINGLE_CHARACTER = 'F'
# Creates a new Failure with the given location and
@@ -21,7 +21,7 @@ module Test
@location = location
@message = message
end
-
+
# Returns a single character representation of a failure.
def single_character_display
SINGLE_CHARACTER
diff --git a/lib/test/unit/testcase.rb b/lib/test/unit/testcase.rb
index f53b460c5d..b5ced034e5 100644
--- a/lib/test/unit/testcase.rb
+++ b/lib/test/unit/testcase.rb
@@ -22,9 +22,9 @@ module Test
class TestCase
include Assertions
include Util::BacktraceFilter
-
+
attr_reader :method_name
-
+
STARTED = name + "::STARTED"
FINISHED = name + "::FINISHED"
@@ -104,7 +104,7 @@ module Test
# down fixture information.
def teardown
end
-
+
def default_test
flunk("No tests were specified")
end
@@ -148,7 +148,7 @@ module Test
def to_s
name
end
-
+
# It's handy to be able to compare TestCase instances.
def ==(other)
return false unless(other.kind_of?(self.class))
diff --git a/lib/test/unit/testsuite.rb b/lib/test/unit/testsuite.rb
index 6fea976c50..d1be69f925 100644
--- a/lib/test/unit/testsuite.rb
+++ b/lib/test/unit/testsuite.rb
@@ -16,7 +16,7 @@ module Test
# meaningful TestSuite instance.
class TestSuite
attr_reader :name, :tests
-
+
STARTED = name + "::STARTED"
FINISHED = name + "::FINISHED"
@@ -54,7 +54,7 @@ module Test
@tests.each { |test| total_size += test.size }
total_size
end
-
+
def empty?
tests.empty?
end
@@ -64,7 +64,7 @@ module Test
def to_s
@name
end
-
+
# It's handy to be able to compare TestSuite instances.
def ==(other)
return false unless(other.kind_of?(self.class))
diff --git a/lib/test/unit/ui/console/testrunner.rb b/lib/test/unit/ui/console/testrunner.rb
index 6b600e319a..240fd6462a 100644
--- a/lib/test/unit/ui/console/testrunner.rb
+++ b/lib/test/unit/ui/console/testrunner.rb
@@ -50,11 +50,11 @@ module Test
end
output("Loaded suite #{suite_name}")
end
-
+
def create_mediator(suite)
return TestRunnerMediator.new(suite)
end
-
+
def attach_to_mediator
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
@mediator.add_listener(TestRunnerMediator::STARTED, &method(:started))
@@ -62,22 +62,22 @@ module Test
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
@mediator.add_listener(TestCase::FINISHED, &method(:test_finished))
end
-
+
def start_mediator
return @mediator.run_suite
end
-
+
def add_fault(fault)
@faults << fault
output_single(fault.single_character_display, PROGRESS_ONLY)
@already_outputted = true
end
-
+
def started(result)
@result = result
output("Started")
end
-
+
def finished(elapsed_time)
nl
output("Finished in #{elapsed_time} seconds.")
@@ -88,31 +88,31 @@ module Test
nl
output(@result)
end
-
+
def test_started(name)
output_single(name + ": ", VERBOSE)
end
-
+
def test_finished(name)
output_single(".", PROGRESS_ONLY) unless (@already_outputted)
nl(VERBOSE)
@already_outputted = false
end
-
+
def nl(level=NORMAL)
output("", level)
end
-
+
def output(something, level=NORMAL)
@io.puts(something) if (output?(level))
@io.flush
end
-
+
def output_single(something, level=NORMAL)
@io.write(something) if (output?(level))
@io.flush
end
-
+
def output?(level)
level <= @output_level
end
diff --git a/lib/test/unit/ui/fox/testrunner.rb b/lib/test/unit/ui/fox/testrunner.rb
index a23a450567..1ea78013ee 100644
--- a/lib/test/unit/ui/fox/testrunner.rb
+++ b/lib/test/unit/ui/fox/testrunner.rb
@@ -23,7 +23,7 @@ module Test
class TestRunner
extend TestRunnerUtilities
-
+
RED_STYLE = FXRGBA(0xFF,0,0,0xFF) #0xFF000000
GREEN_STYLE = FXRGBA(0,0xFF,0,0xFF) #0x00FF0000
@@ -39,7 +39,7 @@ module Test
@result = nil
@red = false
end
-
+
# Begins the test run.
def start
setup_ui
@@ -57,7 +57,7 @@ module Test
end
@suite_name_entry.text = suite_name
end
-
+
def attach_to_mediator
@mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui))
@mediator.add_listener(TestResult::FAULT, &method(:add_fault))
@@ -66,7 +66,7 @@ module Test
@mediator.add_listener(TestCase::STARTED, &method(:test_started))
@mediator.add_listener(TestRunnerMediator::FINISHED, &method(:finished))
end
-
+
def start_ui
@application.create
@window.show(PLACEMENT_SCREEN)
@@ -75,25 +75,25 @@ module Test
end
@application.run
end
-
+
def stop
@application.exit(0)
end
-
+
def reset_ui(count)
@test_progress_bar.barColor = GREEN_STYLE
@test_progress_bar.total = count
@test_progress_bar.progress = 0
@red = false
-
+
@test_count_label.text = "0"
@assertion_count_label.text = "0"
@failure_count_label.text = "0"
@error_count_label.text = "0"
-
+
@fault_list.clearItems
end
-
+
def add_fault(fault)
if ( ! @red )
@test_progress_bar.barColor = RED_STYLE
@@ -102,22 +102,22 @@ module Test
item = FaultListItem.new(fault)
@fault_list.appendItem(item)
end
-
+
def show_fault(fault)
raw_show_fault(fault.long_display)
end
-
+
def raw_show_fault(string)
@detail_text.setText(string)
end
-
+
def clear_fault
raw_show_fault("")
end
-
+
def result_changed(result)
@test_progress_bar.progress = result.run_count
-
+
@test_count_label.text = result.run_count.to_s
@assertion_count_label.text = result.assertion_count.to_s
@failure_count_label.text = result.failure_count.to_s
@@ -127,42 +127,42 @@ module Test
@info_panel.repaint
@application.flush
end
-
+
def started(result)
@result = result
output_status("Started...")
end
-
+
def test_started(test_name)
output_status("Running #{test_name}...")
end
-
+
def finished(elapsed_time)
output_status("Finished in #{elapsed_time} seconds")
end
-
+
def output_status(string)
@status_entry.text = string
@status_entry.repaint
end
-
+
def setup_ui
@application = create_application
create_tooltip(@application)
@window = create_window(@application)
-
+
@status_entry = create_entry(@window)
-
+
main_panel = create_main_panel(@window)
-
+
suite_panel = create_suite_panel(main_panel)
create_label(suite_panel, "Suite:")
@suite_name_entry = create_entry(suite_panel)
create_button(suite_panel, "&Run\tRun the current suite", proc { @mediator.run_suite })
-
+
@test_progress_bar = create_progress_bar(main_panel)
-
+
@info_panel = create_info_panel(main_panel)
create_label(@info_panel, "Tests:")
@test_count_label = create_label(@info_panel, "0")
@@ -172,58 +172,58 @@ module Test
@failure_count_label = create_label(@info_panel, "0")
create_label(@info_panel, "Errors:")
@error_count_label = create_label(@info_panel, "0")
-
+
list_panel = create_list_panel(main_panel)
@fault_list = create_fault_list(list_panel)
-
+
detail_panel = create_detail_panel(main_panel)
@detail_text = create_text(detail_panel)
end
-
+
def create_application
app = FXApp.new("TestRunner", "Test::Unit")
app.init([])
app
end
-
+
def create_window(app)
FXMainWindow.new(app, "Test::Unit TestRunner", nil, nil, DECOR_ALL, 0, 0, 450)
end
-
+
def create_tooltip(app)
FXTooltip.new(app)
end
-
+
def create_main_panel(parent)
panel = FXVerticalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y)
panel.vSpacing = 10
panel
end
-
+
def create_suite_panel(parent)
FXHorizontalFrame.new(parent, LAYOUT_SIDE_LEFT | LAYOUT_FILL_X)
end
-
+
def create_button(parent, text, action)
FXButton.new(parent, text).connect(SEL_COMMAND, &action)
end
-
+
def create_progress_bar(parent)
FXProgressBar.new(parent, nil, 0, PROGRESSBAR_NORMAL | LAYOUT_FILL_X)
end
-
+
def create_info_panel(parent)
FXMatrix.new(parent, 1, MATRIX_BY_ROWS | LAYOUT_FILL_X)
end
-
+
def create_label(parent, text)
FXLabel.new(parent, text, nil, JUSTIFY_CENTER_X | LAYOUT_FILL_COLUMN)
end
-
+
def create_list_panel(parent)
FXHorizontalFrame.new(parent, LAYOUT_FILL_X | FRAME_SUNKEN | FRAME_THICK)
end
-
+
def create_fault_list(parent)
list = FXList.new(parent, 10, nil, 0, LIST_SINGLESELECT | LAYOUT_FILL_X) #, 0, 0, 0, 150)
list.connect(SEL_COMMAND) do |sender, sel, ptr|
@@ -235,22 +235,22 @@ module Test
end
list
end
-
+
def create_detail_panel(parent)
FXHorizontalFrame.new(parent, LAYOUT_FILL_X | LAYOUT_FILL_Y | FRAME_SUNKEN | FRAME_THICK)
end
-
+
def create_text(parent)
FXText.new(parent, nil, 0, TEXT_READONLY | LAYOUT_FILL_X | LAYOUT_FILL_Y)
end
-
+
def create_entry(parent)
entry = FXTextField.new(parent, 30, nil, 0, TEXTFIELD_NORMAL | LAYOUT_SIDE_BOTTOM | LAYOUT_FILL_X)
entry.disable
entry
end
end
-
+
class FaultListItem < FXListItem
attr_reader(:fault)
def initialize(fault)
diff --git a/lib/test/unit/ui/gtk/testrunner.rb b/lib/test/unit/ui/gtk/testrunner.rb
index 994328dc9b..491cd621b2 100644
--- a/lib/test/unit/ui/gtk/testrunner.rb
+++ b/lib/test/unit/ui/gtk/testrunner.rb
@@ -57,7 +57,7 @@ module Test
end
suite_name_entry.set_text(suite_name)
end
-
+
def attach_to_mediator
run_button.signal_connect("clicked", nil, &method(:run_test))
@mediator.add_listener(TestRunnerMediator::RESET, &method(:reset_ui))
@@ -72,7 +72,7 @@ module Test
def run_test(*)
@runner.raise(@restart_signal)
end
-
+
def start_ui
@viewer.run
running = false
@@ -92,24 +92,24 @@ module Test
rescue
end
end
-
+
def stop(*)
Gtk.main_quit
end
-
+
def reset_ui(count)
test_progress_bar.set_style(green_style)
test_progress_bar.configure(0, 0, count)
@red = false
-
+
run_count_label.set_text("0")
assertion_count_label.set_text("0")
failure_count_label.set_text("0")
error_count_label.set_text("0")
-
+
fault_list.remove_items(fault_list.children)
end
-
+
def add_fault(fault)
if ( ! @red )
test_progress_bar.set_style(red_style)
@@ -119,48 +119,48 @@ module Test
item.show
fault_list.append_items([item])
end
-
+
def show_fault(fault)
raw_show_fault(fault.long_display)
end
-
+
def raw_show_fault(string)
fault_detail_label.set_text(string)
outer_detail_sub_panel.queue_resize
end
-
+
def clear_fault
raw_show_fault("")
end
-
+
def result_changed(result)
run_count_label.set_text(result.run_count.to_s)
assertion_count_label.set_text(result.assertion_count.to_s)
failure_count_label.set_text(result.failure_count.to_s)
error_count_label.set_text(result.error_count.to_s)
end
-
+
def started(result)
@result = result
output_status("Started...")
end
-
+
def test_started(test_name)
output_status("Running #{test_name}...")
end
-
+
def test_finished(test_name)
test_progress_bar.set_value(test_progress_bar.get_value + 1)
end
-
+
def finished(elapsed_time)
output_status("Finished in #{elapsed_time} seconds")
end
-
+
def output_status(string)
status_entry.set_text(string)
end
-
+
def setup_ui
main_window.signal_connect("destroy", nil, &method(:stop))
main_window.show_all
@@ -173,7 +173,7 @@ module Test
}
@red = false
end
-
+
def main_window
lazy_initialize(:main_window) {
@main_window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
@@ -184,7 +184,7 @@ module Test
@main_window.add(main_panel)
}
end
-
+
def main_panel
lazy_initialize(:main_panel) {
@main_panel = Gtk::VBox.new(false, 0)
@@ -196,7 +196,7 @@ module Test
@main_panel.pack_start(status_panel, false, false, 0)
}
end
-
+
def suite_panel
lazy_initialize(:suite_panel) {
@suite_panel = Gtk::HBox.new(false, 10)
@@ -206,20 +206,20 @@ module Test
@suite_panel.pack_start(run_button, false, false, 0)
}
end
-
+
def suite_name_entry
lazy_initialize(:suite_name_entry) {
@suite_name_entry = Gtk::Entry.new
@suite_name_entry.set_editable(false)
}
end
-
+
def run_button
lazy_initialize(:run_button) {
@run_button = Gtk::Button.new("Run")
}
end
-
+
def progress_panel
lazy_initialize(:progress_panel) {
@progress_panel = Gtk::HBox.new(false, 10)
@@ -227,7 +227,7 @@ module Test
@progress_panel.pack_start(test_progress_bar, true, true, 0)
}
end
-
+
def test_progress_bar
lazy_initialize(:test_progress_bar) {
@test_progress_bar = EnhancedProgressBar.new
@@ -236,21 +236,21 @@ module Test
@test_progress_bar.set_style(green_style)
}
end
-
+
def green_style
lazy_initialize(:green_style) {
@green_style = Gtk::Style.new
@green_style.set_bg(Gtk::STATE_PRELIGHT, 0x0000, 0xFFFF, 0x0000)
}
end
-
+
def red_style
lazy_initialize(:red_style) {
@red_style = Gtk::Style.new
@red_style.set_bg(Gtk::STATE_PRELIGHT, 0xFFFF, 0x0000, 0x0000)
}
end
-
+
def info_panel
lazy_initialize(:info_panel) {
@info_panel = Gtk::HBox.new(false, 0)
@@ -265,35 +265,35 @@ module Test
@info_panel.pack_start(error_count_label, true, false, 0)
}
end
-
+
def run_count_label
lazy_initialize(:run_count_label) {
@run_count_label = Gtk::Label.new("0")
@run_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
-
+
def assertion_count_label
lazy_initialize(:assertion_count_label) {
@assertion_count_label = Gtk::Label.new("0")
@assertion_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
-
+
def failure_count_label
lazy_initialize(:failure_count_label) {
@failure_count_label = Gtk::Label.new("0")
@failure_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
-
+
def error_count_label
lazy_initialize(:error_count_label) {
@error_count_label = Gtk::Label.new("0")
@error_count_label.set_justify(Gtk::JUSTIFY_LEFT)
}
end
-
+
def list_panel
lazy_initialize(:list_panel) {
@list_panel = Gtk::HBox.new
@@ -301,7 +301,7 @@ module Test
@list_panel.pack_start(list_scrolled_window, true, true, 0)
}
end
-
+
def list_scrolled_window
lazy_initialize(:list_scrolled_window) {
@list_scrolled_window = Gtk::ScrolledWindow.new
@@ -310,13 +310,13 @@ module Test
@list_scrolled_window.add_with_viewport(fault_list)
}
end
-
+
def fault_list
lazy_initialize(:fault_list) {
@fault_list = Gtk::List.new
}
end
-
+
def detail_panel
lazy_initialize(:detail_panel) {
@detail_panel = Gtk::HBox.new
@@ -324,7 +324,7 @@ module Test
@detail_panel.pack_start(detail_scrolled_window, true, true, 0)
}
end
-
+
def detail_scrolled_window
lazy_initialize(:detail_scrolled_window) {
@detail_scrolled_window = Gtk::ScrolledWindow.new
@@ -333,21 +333,21 @@ module Test
@detail_scrolled_window.add_with_viewport(outer_detail_sub_panel)
}
end
-
+
def outer_detail_sub_panel
lazy_initialize(:outer_detail_sub_panel) {
@outer_detail_sub_panel = Gtk::VBox.new
@outer_detail_sub_panel.pack_start(inner_detail_sub_panel, false, false, 0)
}
end
-
+
def inner_detail_sub_panel
lazy_initialize(:inner_detail_sub_panel) {
@inner_detail_sub_panel = Gtk::HBox.new
@inner_detail_sub_panel.pack_start(fault_detail_label, false, false, 0)
}
end
-
+
def fault_detail_label
lazy_initialize(:fault_detail_label) {
@fault_detail_label = EnhancedLabel.new("")
@@ -361,7 +361,7 @@ module Test
@fault_detail_label.set_line_wrap(false)
}
end
-
+
def status_panel
lazy_initialize(:status_panel) {
@status_panel = Gtk::HBox.new
@@ -369,14 +369,14 @@ module Test
@status_panel.pack_start(status_entry, true, true, 0)
}
end
-
+
def status_entry
lazy_initialize(:status_entry) {
@status_entry = Gtk::Entry.new
@status_entry.set_editable(false)
}
end
-
+
def lazy_initialize(symbol)
if (!instance_eval("defined?(@#{symbol.to_s})"))
yield
@@ -384,7 +384,7 @@ module Test
return instance_eval("@" + symbol.to_s)
end
end
-
+
class EnhancedProgressBar < Gtk::ProgressBar
def set_style(style)
super
@@ -392,13 +392,13 @@ module Test
show
end
end
-
+
class EnhancedLabel < Gtk::Label
def set_text(text)
super(text.gsub(/\n\t/, "\n" + (" " * 4)))
end
end
-
+
class FaultListItem < Gtk::ListItem
attr_reader(:fault)
def initialize(fault)
diff --git a/lib/test/unit/ui/gtk2/testrunner.rb b/lib/test/unit/ui/gtk2/testrunner.rb
index b05549c0e8..8c1280a146 100644
--- a/lib/test/unit/ui/gtk2/testrunner.rb
+++ b/lib/test/unit/ui/gtk2/testrunner.rb
@@ -189,7 +189,7 @@ module Test
end
end
private :run_count_label
-
+
def info_panel
lazy_initialize(:info_panel) do
@info_panel = Gtk::HBox.new(false, 0)
@@ -213,7 +213,7 @@ module Test
end
end # def green_style
private :green_style
-
+
def red_style
lazy_initialize(:red_style) do
@red_style = Gtk::Style.new
@@ -221,7 +221,7 @@ module Test
end
end # def red_style
private :red_style
-
+
def test_progress_bar
lazy_initialize(:test_progress_bar) {
@test_progress_bar = Gtk::ProgressBar.new
@@ -233,7 +233,7 @@ module Test
}
end # def test_progress_bar
private :test_progress_bar
-
+
def progress_panel
lazy_initialize(:progress_panel) do
@progress_panel = Gtk::HBox.new(false, 10)
diff --git a/lib/test/unit/ui/testrunnermediator.rb b/lib/test/unit/ui/testrunnermediator.rb
index d34510d1c6..b2b0b70d70 100644
--- a/lib/test/unit/ui/testrunnermediator.rb
+++ b/lib/test/unit/ui/testrunnermediator.rb
@@ -18,9 +18,9 @@ module Test
RESET = name + "::RESET"
STARTED = name + "::STARTED"
FINISHED = name + "::FINISHED"
-
+
include Util::Observable
-
+
# Creates a new TestRunnerMediator initialized to run
# the passed suite.
def initialize(suite)
@@ -38,15 +38,15 @@ module Test
result_listener = result.add_listener(TestResult::CHANGED) do |updated_result|
notify_listeners(TestResult::CHANGED, updated_result)
end
-
+
fault_listener = result.add_listener(TestResult::FAULT) do |fault|
notify_listeners(TestResult::FAULT, fault)
end
-
+
@suite.run(result) do |channel, value|
notify_listeners(channel, value)
end
-
+
result.remove_listener(TestResult::FAULT, fault_listener)
result.remove_listener(TestResult::CHANGED, result_listener)
end_time = Time.now
diff --git a/lib/test/unit/util/backtracefilter.rb b/lib/test/unit/util/backtracefilter.rb
index 7ebec2dfef..87d65e8fc6 100644
--- a/lib/test/unit/util/backtracefilter.rb
+++ b/lib/test/unit/util/backtracefilter.rb
@@ -5,7 +5,7 @@ module Test
TESTUNIT_FILE_SEPARATORS = %r{[\\/:]}
TESTUNIT_PREFIX = __FILE__.split(TESTUNIT_FILE_SEPARATORS)[0..-3]
TESTUNIT_RB_FILE = /\.rb\Z/
-
+
def filter_backtrace(backtrace, prefix=nil)
return ["No backtrace"] unless(backtrace)
split_p = if(prefix)
diff --git a/lib/test/unit/util/observable.rb b/lib/test/unit/util/observable.rb
index 3567d34271..8c8745e248 100644
--- a/lib/test/unit/util/observable.rb
+++ b/lib/test/unit/util/observable.rb
@@ -32,13 +32,13 @@ module Test
unless(block_given?)
raise ArgumentError.new("No callback was passed as a listener")
end
-
+
key = listener_key
if (listener_key == NOTHING)
listener_key = listener
key = ProcWrapper.new(listener)
end
-
+
channels[channel_name] ||= {}
channels[channel_name][key] = listener
return listener_key
diff --git a/lib/thread.rb b/lib/thread.rb
index 7df6a140f5..25ce907735 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -40,13 +40,13 @@ end
#
# require 'thread'
# semaphore = Mutex.new
-#
+#
# a = Thread.new {
# semaphore.synchronize {
# # access shared resource
# }
# }
-#
+#
# b = Thread.new {
# semaphore.synchronize {
# # access shared resource
@@ -153,7 +153,7 @@ class Mutex
end
end
-#
+#
# ConditionVariable objects augment class Mutex. Using condition variables,
# it is possible to suspend while in the middle of a critical section until a
# resource becomes available.
@@ -164,7 +164,7 @@ end
#
# mutex = Mutex.new
# resource = ConditionVariable.new
-#
+#
# a = Thread.new {
# mutex.synchronize {
# # Thread 'a' now needs the resource
@@ -172,7 +172,7 @@ end
# # 'a' can now have the resource
# }
# }
-#
+#
# b = Thread.new {
# mutex.synchronize {
# # Thread 'b' has finished using the resource
@@ -187,7 +187,7 @@ class ConditionVariable
def initialize
@waiters = []
end
-
+
#
# Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
#
@@ -201,7 +201,7 @@ class ConditionVariable
mutex.lock
end
end
-
+
#
# Wakes up the first thread in line waiting for this lock.
#
@@ -213,7 +213,7 @@ class ConditionVariable
retry
end
end
-
+
#
# Wakes up all threads waiting for this lock.
#
@@ -238,9 +238,9 @@ end
# Example:
#
# require 'thread'
-#
+#
# queue = Queue.new
-#
+#
# producer = Thread.new do
# 5.times do |i|
# sleep rand(i) # simulate expense
@@ -248,7 +248,7 @@ end
# puts "#{i} produced"
# end
# end
-#
+#
# consumer = Thread.new do
# 5.times do |i|
# value = queue.pop
@@ -256,7 +256,7 @@ end
# puts "consumed #{value}"
# end
# end
-#
+#
# consumer.join
#
class Queue
diff --git a/lib/thwait.rb b/lib/thwait.rb
index 35565a8afe..2f5cc41ba0 100644
--- a/lib/thwait.rb
+++ b/lib/thwait.rb
@@ -16,7 +16,7 @@
# each thread termination.
# * th = ThreadsWait.new(thread1,...)
# creates synchronization object, specifying thread(s) to wait.
-#
+#
# methods:
# * th.threads
# list threads to be synchronized
@@ -24,7 +24,7 @@
# is there any thread to be synchronized.
# * th.finished?
# is there already terminated thread.
-# * th.join(thread1,...)
+# * th.join(thread1,...)
# wait for specified thread(s).
# * th.join_nowait(threa1,...)
# specifies thread(s) to wait. non-blocking.
@@ -53,11 +53,11 @@ require "e2mmap.rb"
#
class ThreadsWait
RCS_ID='-$Id: thwait.rb,v 1.3 1998/06/26 03:19:34 keiju Exp keiju $-'
-
+
Exception2MessageMapper.extend_to(binding)
def_exception("ErrNoWaitingThread", "No threads for waiting.")
def_exception("ErrNoFinishedThread", "No finished threads.")
-
+
#
# Waits until all specified threads have terminated. If a block is provided,
# it is executed for each thread termination.
@@ -72,7 +72,7 @@ class ThreadsWait
tw.all_waits
end
end
-
+
#
# Creates a ThreadsWait object, specifying the threads to wait on.
# Non-blocking.
@@ -82,24 +82,24 @@ class ThreadsWait
@wait_queue = Queue.new
join_nowait(*threads) unless threads.empty?
end
-
+
# Returns the array of threads in the wait queue.
attr :threads
-
+
#
# Returns +true+ if there are no threads to be synchronized.
#
def empty?
@threads.empty?
end
-
+
#
# Returns +true+ if any thread has terminated.
#
def finished?
!@wait_queue.empty?
end
-
+
#
# Waits for specified threads to terminate.
#
@@ -107,7 +107,7 @@ class ThreadsWait
join_nowait(*threads)
next_wait
end
-
+
#
# Specifies the threads that this object will wait for, but does not actually
# wait.
@@ -125,7 +125,7 @@ class ThreadsWait
end
end
end
-
+
#
# Waits until any of the specified threads has terminated, and returns the one
# that does.
@@ -142,7 +142,7 @@ class ThreadsWait
ThreadsWait.fail ErrNoFinishedThread
end
end
-
+
#
# Waits until all of the specified threads are terminated. If a block is
# supplied for the method, it is executed for each thread termination.
diff --git a/lib/time.rb b/lib/time.rb
index 62212a06c1..605653b2c2 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -1,37 +1,37 @@
#
# == Introduction
-#
+#
# This library extends the Time class:
# * conversion between date string and time object.
# * date-time defined by RFC 2822
# * HTTP-date defined by RFC 2616
# * dateTime defined by XML Schema Part 2: Datatypes (ISO 8601)
# * various formats handled by Date._parse (string to time only)
-#
+#
# == Design Issues
-#
+#
# === Specialized interface
-#
+#
# This library provides methods dedicated to special purposes:
# * RFC 2822, RFC 2616 and XML Schema.
# * They makes usual life easier.
-#
+#
# === Doesn't depend on strftime
-#
+#
# This library doesn't use +strftime+. Especially #rfc2822 doesn't depend
# on +strftime+ because:
-#
+#
# * %a and %b are locale sensitive
-#
+#
# Since they are locale sensitive, they may be replaced to
# invalid weekday/month name in some locales.
# Since ruby-1.6 doesn't invoke setlocale by default,
# the problem doesn't arise until some external library invokes setlocale.
# Ruby/GTK is the example of such library.
-#
+#
# * %z is not portable
-#
+#
# %z is required to generate zone in date-time of RFC 2822
# but it is not portable.
#
@@ -61,9 +61,9 @@ class Time
'PST' => -8, 'PDT' => -7,
# Following definition of military zones is original one.
# See RFC 1123 and RFC 2822 for the error in RFC 822.
- 'A' => +1, 'B' => +2, 'C' => +3, 'D' => +4, 'E' => +5, 'F' => +6,
+ 'A' => +1, 'B' => +2, 'C' => +3, 'D' => +4, 'E' => +5, 'F' => +6,
'G' => +7, 'H' => +8, 'I' => +9, 'K' => +10, 'L' => +11, 'M' => +12,
- 'N' => -1, 'O' => -2, 'P' => -3, 'Q' => -4, 'R' => -5, 'S' => -6,
+ 'N' => -1, 'O' => -2, 'P' => -3, 'Q' => -4, 'R' => -5, 'S' => -6,
'T' => -7, 'U' => -8, 'V' => -9, 'W' => -10, 'X' => -11, 'Y' => -12,
}
def zone_offset(zone, year=self.now.year)
@@ -413,8 +413,8 @@ class Time
#
# Returns a string which represents the time as rfc1123-date of HTTP-date
- # defined by RFC 2616:
- #
+ # defined by RFC 2616:
+ #
# day-of-week, DD month-name CCYY hh:mm:ss GMT
#
# Note that the result is always UTC (GMT).
diff --git a/lib/tracer.rb b/lib/tracer.rb
index 71aa49c306..7a4218c59a 100644
--- a/lib/tracer.rb
+++ b/lib/tracer.rb
@@ -1,5 +1,5 @@
#
-# tracer.rb -
+# tracer.rb -
# $Release Version: 0.2$
# $Revision: 1.8 $
# $Date: 1998/05/19 03:42:49 $
@@ -7,7 +7,7 @@
#
# --
#
-#
+#
#
#
@@ -23,7 +23,7 @@ class Tracer
alias verbose? verbose
attr :stdout, true
end
-
+
EVENT_SYMBOL = {
"line" => "-",
"call" => ">",
@@ -33,7 +33,7 @@ class Tracer
"c-call" => ">",
"c-return" => "<",
}
-
+
def initialize
@threads = Hash.new
if defined? Thread.main
@@ -46,7 +46,7 @@ class Tracer
@filters = []
end
-
+
def stdout
Tracer.stdout
end
@@ -64,7 +64,7 @@ class Tracer
stdout.print "Trace on\n" if Tracer.verbose?
end
end
-
+
def off
set_trace_func nil
stdout.print "Trace off\n" if Tracer.verbose?
@@ -77,7 +77,7 @@ class Tracer
def set_get_line_procs(file, p = proc)
@get_line_procs[file] = p
end
-
+
def get_line(file, line)
if p = @get_line_procs[file]
return p.call(line)
@@ -86,7 +86,7 @@ class Tracer
unless list = SCRIPT_LINES__[file]
begin
f = open(file)
- begin
+ begin
SCRIPT_LINES__[file] = list = f.readlines
ensure
f.close
@@ -102,7 +102,7 @@ class Tracer
"-\n"
end
end
-
+
def get_thread_no
if no = @threads[Thread.current.object_id]
no
@@ -110,14 +110,14 @@ class Tracer
@threads[Thread.current.object_id] = @threads.size
end
end
-
+
def trace_func(event, file, line, id, binding, klass, *)
return if file == __FILE__
-
+
for p in @filters
return unless p.call event, file, line, id, binding, klass
end
-
+
saved_crit = Thread.critical
Thread.critical = true
stdout.printf("#%d:%s:%d:%s:%s: %s",
@@ -138,11 +138,11 @@ class Tracer
Single.on
end
end
-
+
def Tracer.off
Single.off
end
-
+
def Tracer.set_get_line_procs(file_name, p = proc)
Single.set_get_line_procs(file_name, p)
end
@@ -150,14 +150,14 @@ class Tracer
def Tracer.add_filter(p = proc)
Single.add_filter(p)
end
-
+
end
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
if $0 == __FILE__
# direct call
-
+
$0 = ARGV[0]
ARGV.shift
Tracer.on
diff --git a/lib/tsort.rb b/lib/tsort.rb
index a014e7f6c2..9fc4feadcd 100644
--- a/lib/tsort.rb
+++ b/lib/tsort.rb
@@ -32,7 +32,7 @@
# array using the user-supplied block.
#
# require 'tsort'
-#
+#
# class Hash
# include TSort
# alias tsort_each_node each_key
@@ -40,10 +40,10 @@
# fetch(node).each(&block)
# end
# end
-#
+#
# {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
# #=> [3, 2, 1, 4]
-#
+#
# {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
# #=> [[4], [2, 3], [1]]
#
@@ -52,19 +52,19 @@
# A very simple `make' like tool can be implemented as follows:
#
# require 'tsort'
-#
+#
# class Make
# def initialize
# @dep = {}
# @dep.default = []
# end
-#
+#
# def rule(outputs, inputs=[], &block)
# triple = [outputs, inputs, block]
# outputs.each {|f| @dep[f] = [triple]}
# @dep[triple] = inputs
# end
-#
+#
# def build(target)
# each_strongly_connected_component_from(target) {|ns|
# if ns.length != 1
@@ -88,18 +88,18 @@
# end
# }
# end
-#
+#
# def tsort_each_child(node, &block)
# @dep[node].each(&block)
# end
# include TSort
# end
-#
+#
# def command(arg)
# print arg, "\n"
# system arg
# end
-#
+#
# m = Make.new
# m.rule(%w[t1]) { command 'date > t1' }
# m.rule(%w[t2]) { command 'date > t2' }
@@ -189,7 +189,7 @@ module TSort
end
#
- # Iterates over strongly connected component in the subgraph reachable from
+ # Iterates over strongly connected component in the subgraph reachable from
# _node_.
#
# Return value is unspecified.
diff --git a/lib/uri.rb b/lib/uri.rb
index f7110f18fd..41bb09b467 100644
--- a/lib/uri.rb
+++ b/lib/uri.rb
@@ -3,11 +3,11 @@
#
# Author:: Akira Yamada <[email protected]>
# Documentation:: Akira Yamada <[email protected]>, Dmitry V. Sabanin <[email protected]>
-# License::
+# License::
# Copyright (c) 2001 akira yamada <[email protected]>
# You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id$
-#
+#
# See URI for documentation
#
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index af6aaf26fb..fe4e392f78 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -2,7 +2,7 @@
#
# Author:: Akira Yamada <[email protected]>
# Revision:: $Id$
-# License::
+# License::
# You can redistribute it and/or modify it under the same term as Ruby.
#
@@ -34,7 +34,7 @@ module URI
UNRESERVED = "-_.!~*'()#{ALNUM}"
# reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
# "$" | ","
- # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
+ # reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
# "$" | "," | "[" | "]" (RFC 2732)
RESERVED = ";/?:@&=+$,\\[\\]"
@@ -236,7 +236,7 @@ module URI
end
end
else
- raise ArgumentError,
+ raise ArgumentError,
"expected Array of or Hash of components of #{klass.to_s} (#{klass.component[1..-1].join(', ')})"
end
tmp[:scheme] = klass.to_s.sub(/\A.*::/, '').downcase
@@ -328,7 +328,7 @@ module URI
extend Escape
@@schemes = {}
-
+
#
# Base class for all URI exceptions.
#
@@ -369,7 +369,7 @@ module URI
# * Opaque
# * Query
# * Fragment
- #
+ #
# == Usage
#
# require 'uri'
@@ -383,7 +383,7 @@ module URI
# null uri
when ABS_URI
- scheme, opaque, userinfo, host, port,
+ scheme, opaque, userinfo, host, port,
registry, path, query, fragment = $~[1..-1]
# URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
@@ -399,19 +399,19 @@ module URI
# server = [ [ userinfo "@" ] hostport ]
if !scheme
- raise InvalidURIError,
+ raise InvalidURIError,
"bad URI(absolute but no scheme): #{uri}"
end
if !opaque && (!path && (!host && !registry))
raise InvalidURIError,
- "bad URI(absolute but no path): #{uri}"
+ "bad URI(absolute but no path): #{uri}"
end
when REL_URI
scheme = nil
opaque = nil
- userinfo, host, port, registry,
+ userinfo, host, port, registry,
rel_segment, abs_path, query, fragment = $~[1..-1]
if rel_segment && abs_path
path = rel_segment + abs_path
@@ -438,7 +438,7 @@ module URI
path = '' if !path && !opaque # (see RFC2396 Section 5.2)
ret = [
- scheme,
+ scheme,
userinfo, host, port, # X
registry, # X
path, # Y
@@ -462,7 +462,7 @@ module URI
# == Description
#
# Creates one of the URI's subclasses instance from the string.
- #
+ #
# == Raises
#
# URI::InvalidURIError
@@ -475,22 +475,22 @@ module URI
# uri = URI.parse("http://www.ruby-lang.org/")
# p uri
# # => #<URI::HTTP:0x202281be URL:http://www.ruby-lang.org/>
- # p uri.scheme
- # # => "http"
- # p uri.host
- # # => "www.ruby-lang.org"
- #
+ # p uri.scheme
+ # # => "http"
+ # p uri.host
+ # # => "www.ruby-lang.org"
+ #
def self.parse(uri)
- scheme, userinfo, host, port,
+ scheme, userinfo, host, port,
registry, path, opaque, query, fragment = self.split(uri)
if scheme && @@schemes.include?(scheme.upcase)
- @@schemes[scheme.upcase].new(scheme, userinfo, host, port,
- registry, path, opaque, query,
+ @@schemes[scheme.upcase].new(scheme, userinfo, host, port,
+ registry, path, opaque, query,
fragment)
else
- Generic.new(scheme, userinfo, host, port,
- registry, path, opaque, query,
+ Generic.new(scheme, userinfo, host, port,
+ registry, path, opaque, query,
fragment)
end
end
@@ -531,7 +531,7 @@ module URI
#
# == Args
#
- # +str+::
+ # +str+::
# String to extract URIs from.
# +schemes+::
# Limit URI matching to a specific schemes.
@@ -566,25 +566,25 @@ module URI
#
# == Args
#
- # +match_schemes+::
+ # +match_schemes+::
# Array of schemes. If given, resulting regexp matches to URIs
# whose scheme is one of the match_schemes.
- #
+ #
# == Description
# Returns a Regexp object which matches to URI-like strings.
# The Regexp object returned by this method includes arbitrary
# number of capture group (parentheses). Never rely on it's number.
- #
+ #
# == Usage
#
# require 'uri'
#
# # extract first URI from html_string
# html_string.slice(URI.regexp)
- #
+ #
# # remove ftp URIs
# html_string.sub(URI.regexp(['ftp'])
- #
+ #
# # You should not rely on the number of parentheses
# html_string.scan(URI.regexp) do |*matches|
# p $&
diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb
index 1a18e9cae7..dda43db4c9 100644
--- a/lib/uri/ftp.rb
+++ b/lib/uri/ftp.rb
@@ -17,12 +17,12 @@ module URI
DEFAULT_PORT = 21
COMPONENT = [
- :scheme,
+ :scheme,
:userinfo, :host, :port,
:path, :typecode
].freeze
#
- # Typecode is "a", "i" or "d".
+ # Typecode is "a", "i" or "d".
#
# * "a" indicates a text file (the FTP command was ASCII)
# * "i" indicates a binary file (FTP command IMAGE)
@@ -31,7 +31,7 @@ module URI
TYPECODE = ['a', 'i', 'd'].freeze
TYPECODE_PREFIX = ';type='.freeze
- def self.new2(user, password, host, port, path,
+ def self.new2(user, password, host, port, path,
typecode = nil, arg_check = true)
typecode = nil if typecode.size == 0
if typecode && !TYPECODE.include?(typecode)
@@ -42,22 +42,22 @@ module URI
# do escape
self.new('ftp',
- [user, password],
- host, port, nil,
- typecode ? path + TYPECODE_PREFIX + typecode : path,
+ [user, password],
+ host, port, nil,
+ typecode ? path + TYPECODE_PREFIX + typecode : path,
nil, nil, nil, arg_check)
end
#
# == Description
#
- # Creates a new URI::FTP object from components, with syntax checking.
+ # Creates a new URI::FTP object from components, with syntax checking.
#
- # The components accepted are +userinfo+, +host+, +port+, +path+ and
+ # The components accepted are +userinfo+, +host+, +port+, +path+ and
# +typecode+.
#
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
#
# If an Array is used, the components must be passed in the order
# [userinfo, host, port, path, typecode]
@@ -67,11 +67,11 @@ module URI
#
# require 'uri'
#
- # uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
+ # uri = URI::FTP.build(['user:password', 'ftp.example.com', nil,
# '/path/file.> zip', 'i'])
# puts uri.to_s -> ftp://user:[email protected]/%2Fpath/file.zip;type=a
#
- # uri2 = URI::FTP.build({:host => 'ftp.example.com',
+ # uri2 = URI::FTP.build({:host => 'ftp.example.com',
# :path => 'ruby/src'})
# puts uri2.to_s -> ftp://ftp.example.com/ruby/src
#
@@ -92,7 +92,7 @@ module URI
if tmp[:typecode]
if tmp[:typecode].size == 1
- tmp[:typecode] = TYPECODE_PREFIX + tmp[:typecode]
+ tmp[:typecode] = TYPECODE_PREFIX + tmp[:typecode]
end
tmp[:path] << tmp[:typecode]
end
@@ -109,7 +109,7 @@ module URI
# Unlike build(), this method does not escape the path component as
# required by RFC1738; instead it is treated as per RFC2396.
#
- # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
# +opaque+, +query+ and +fragment+, in that order.
#
def initialize(*arg)
@@ -119,7 +119,7 @@ module URI
if tmp
typecode = @path[tmp + TYPECODE_PREFIX.size..-1]
self.set_path(@path[0..tmp - 1])
-
+
if arg[-1]
self.typecode = typecode
else
@@ -164,9 +164,9 @@ module URI
# RFC 1738 specifically states that the path for an FTP URI does not
# include the / which separates the URI path from the URI host. Example:
#
- # ftp://ftp.example.com/pub/ruby
+ # ftp://ftp.example.com/pub/ruby
#
- # The above URI indicates that the client should connect to
+ # The above URI indicates that the client should connect to
# ftp.example.com then cd pub/ruby from the initial login directory.
#
# If you want to cd to an absolute directory, you must include an
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index c855d60610..4978816c94 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -9,7 +9,7 @@
require 'uri/common'
module URI
-
+
#
# Base class for all URI classes.
# Implements generic URI syntax as per RFC 2396.
@@ -32,10 +32,10 @@ module URI
end
COMPONENT = [
- :scheme,
- :userinfo, :host, :port, :registry,
- :path, :opaque,
- :query,
+ :scheme,
+ :userinfo, :host, :port, :registry,
+ :path, :opaque,
+ :query,
:fragment
].freeze
@@ -63,7 +63,7 @@ module URI
# == Description
#
# At first, tries to create a new URI::Generic instance using
- # URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
+ # URI::Generic::build. But, if exception URI::InvalidComponentError is raised,
# then it URI::Escape.escape all URI components and tries again.
#
#
@@ -72,7 +72,7 @@ module URI
return self.build(args)
rescue InvalidComponentError
if args.kind_of?(Array)
- return self.build(args.collect{|x|
+ return self.build(args.collect{|x|
if x
URI.escape(x)
else
@@ -118,7 +118,7 @@ module URI
end
end
else
- raise ArgumentError,
+ raise ArgumentError,
"expected Array of or Hash of components of #{self.class} (#{self.class.component.join(', ')})"
end
@@ -153,10 +153,10 @@ module URI
#
# Creates a new URI::Generic instance from ``generic'' components without check.
#
- def initialize(scheme,
- userinfo, host, port, registry,
- path, opaque,
- query,
+ def initialize(scheme,
+ userinfo, host, port, registry,
+ path, opaque,
+ query,
fragment,
arg_check = false)
@scheme = nil
@@ -192,10 +192,10 @@ module URI
self.set_fragment(fragment)
end
if @registry && !self.class.use_registry
- raise InvalidURIError,
+ raise InvalidURIError,
"the scheme #{@scheme} does not accept registry part: #{@registry} (or bad hostname?)"
end
-
+
@scheme.freeze if @scheme
self.set_path('') if !@path && !@opaque # (see RFC2396 Section 5.2)
self.set_port(self.default_port) if self.default_port && !@port
@@ -259,7 +259,7 @@ module URI
def check_user(v)
if @registry || @opaque
- raise InvalidURIError,
+ raise InvalidURIError,
"can not set user with registry or opaque"
end
@@ -276,7 +276,7 @@ module URI
def check_password(v, user = @user)
if @registry || @opaque
- raise InvalidURIError,
+ raise InvalidURIError,
"can not set password with registry or opaque"
end
return v unless v
@@ -312,7 +312,7 @@ module URI
set_user(user)
# returns user
end
-
+
def password=(password)
check_password(password)
set_password(password)
@@ -320,7 +320,7 @@ module URI
end
def set_userinfo(user, password = nil)
- unless password
+ unless password
user, password = split_userinfo(user)
end
@user = user
@@ -377,7 +377,7 @@ module URI
return v unless v
if @registry || @opaque
- raise InvalidURIError,
+ raise InvalidURIError,
"can not set host with registry or opaque"
elsif HOST !~ v
raise InvalidComponentError,
@@ -403,7 +403,7 @@ module URI
return v unless v
if @registry || @opaque
- raise InvalidURIError,
+ raise InvalidURIError,
"can not set port with registry or opaque"
elsif !v.kind_of?(Fixnum) && PORT !~ v
raise InvalidComponentError,
@@ -439,7 +439,7 @@ module URI
# authority = server | reg_name
# server = [ [ userinfo "@" ] hostport ]
if @host || @port || @user # userinfo = @user + ':' + @password
- raise InvalidURIError,
+ raise InvalidURIError,
"can not set registry with host, port, or userinfo"
elsif v && REGISTRY !~ v
raise InvalidComponentError,
@@ -466,18 +466,18 @@ module URI
# absoluteURI = scheme ":" ( hier_part | opaque_part )
# hier_part = ( net_path | abs_path ) [ "?" query ]
if v && @opaque
- raise InvalidURIError,
+ raise InvalidURIError,
"path conflicts with opaque"
end
if @scheme
if v && v != '' && ABS_PATH !~ v
- raise InvalidComponentError,
+ raise InvalidComponentError,
"bad component(expected absolute path component): #{v}"
end
else
if v && v != '' && ABS_PATH !~ v && REL_PATH !~ v
- raise InvalidComponentError,
+ raise InvalidComponentError,
"bad component(expected relative path component): #{v}"
end
end
@@ -504,12 +504,12 @@ module URI
# absoluteURI = scheme ":" ( hier_part | opaque_part )
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @opaque
- raise InvalidURIError,
+ raise InvalidURIError,
"query conflicts with opaque"
end
if v && v != '' && QUERY !~ v
- raise InvalidComponentError,
+ raise InvalidComponentError,
"bad component(expected query component): #{v}"
end
@@ -535,7 +535,7 @@ module URI
# absoluteURI = scheme ":" ( hier_part | opaque_part )
# hier_part = ( net_path | abs_path ) [ "?" query ]
if @host || @port || @user || @path # userinfo = @user + ':' + @password
- raise InvalidURIError,
+ raise InvalidURIError,
"can not set opaque with host, port, userinfo or path"
elsif v && OPAQUE !~ v
raise InvalidComponentError,
@@ -561,7 +561,7 @@ module URI
return v unless v
if v && v != '' && FRAGMENT !~ v
- raise InvalidComponentError,
+ raise InvalidComponentError,
"bad component(expected fragment component): #{v}"
end
@@ -779,12 +779,12 @@ module URI
end
if self.relative? && oth.relative?
- raise BadURIError,
+ raise BadURIError,
"both URI are relative"
end
if self.absolute? && oth.absolute?
- #raise BadURIError,
+ #raise BadURIError,
# "both URI are absolute"
# hmm... should return oth for usability?
return oth, oth
@@ -805,7 +805,7 @@ module URI
src_path = split_path(src)
dst_path = split_path(dst)
- # hmm... dst has abnormal absolute path,
+ # hmm... dst has abnormal absolute path,
# like "/./", "/../", "/x/../", ...
if dst_path.include?('..') ||
dst_path.include?('.')
@@ -850,11 +850,11 @@ module URI
end
if self.relative?
- raise BadURIError,
+ raise BadURIError,
"relative URI: #{self}"
end
if oth.relative?
- raise BadURIError,
+ raise BadURIError,
"relative URI: #{oth}"
end
@@ -862,7 +862,7 @@ module URI
return self, self.dup
end
rel = URI::Generic.new(nil, # it is relative URI
- self.userinfo, self.host, self.port,
+ self.userinfo, self.host, self.port,
self.registry, self.path, self.opaque,
self.query, self.fragment)
@@ -950,7 +950,7 @@ module URI
# uri = URI.parse('http://my.example.com')
# p uri.route_to('http://my.example.com/main.rbx?page=1')
# #=> #<URI::Generic:0x2020c2f6 URL:/main.rbx?page=1>
- #
+ #
def route_to(oth)
case oth
when Generic
@@ -966,7 +966,7 @@ module URI
#
# Returns normalized URI
- #
+ #
def normalize
uri = dup
uri.normalize!
@@ -982,7 +982,7 @@ module URI
end
if host && host != host.downcase
set_host(self.host.downcase)
- end
+ end
end
def path_query
@@ -996,7 +996,7 @@ module URI
#
# Constructs String from URI
- #
+ #
def to_s
str = ''
if @scheme
@@ -1098,7 +1098,7 @@ module URI
if component.include?(c)
self.send(c)
else
- raise ArgumentError,
+ raise ArgumentError,
"expected of components of #{self.class} (#{self.class.component.join(', ')})"
end
end
diff --git a/lib/uri/http.rb b/lib/uri/http.rb
index 87eb8893f2..69a7658918 100644
--- a/lib/uri/http.rb
+++ b/lib/uri/http.rb
@@ -14,18 +14,18 @@ module URI
# The syntax of HTTP URIs is defined in RFC1738 section 3.3.
#
# Note that the Ruby URI library allows HTTP URLs containing usernames and
- # passwords. This is not legal as per the RFC, but used to be
- # supported in Internet Explorer 5 and 6, before the MS04-004 security
+ # passwords. This is not legal as per the RFC, but used to be
+ # supported in Internet Explorer 5 and 6, before the MS04-004 security
# update. See <URL:http://support.microsoft.com/kb/834489>.
#
class HTTP < Generic
DEFAULT_PORT = 80
COMPONENT = [
- :scheme,
- :userinfo, :host, :port,
- :path,
- :query,
+ :scheme,
+ :userinfo, :host, :port,
+ :path,
+ :query,
:fragment
].freeze
@@ -37,21 +37,21 @@ module URI
# The components accepted are userinfo, host, port, path, query and
# fragment.
#
- # The components should be provided either as an Array, or as a Hash
- # with keys formed by preceding the component names with a colon.
+ # The components should be provided either as an Array, or as a Hash
+ # with keys formed by preceding the component names with a colon.
#
# If an Array is used, the components must be passed in the order
# [userinfo, host, port, path, query, fragment].
#
# Example:
#
- # newuri = URI::HTTP.build({:host => 'www.example.com',
+ # newuri = URI::HTTP.build({:host => 'www.example.com',
# :path> => '/foo/bar'})
#
- # newuri = URI::HTTP.build([nil, "www.example.com", nil, "/path",
+ # newuri = URI::HTTP.build([nil, "www.example.com", nil, "/path",
# "query", 'fragment'])
#
- # Currently, if passed userinfo components this method generates
+ # Currently, if passed userinfo components this method generates
# invalid HTTP URIs as per RFC 1738.
#
def self.build(args)
@@ -63,10 +63,10 @@ module URI
# == Description
#
# Create a new URI::HTTP object from generic URI components as per
- # RFC 2396. No HTTP-specific syntax checking (as per RFC 1738) is
+ # RFC 2396. No HTTP-specific syntax checking (as per RFC 1738) is
# performed.
#
- # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
# +opaque+, +query+ and +fragment+, in that order.
#
# Example:
diff --git a/lib/uri/ldap.rb b/lib/uri/ldap.rb
index 163d2cda24..6739a018af 100644
--- a/lib/uri/ldap.rb
+++ b/lib/uri/ldap.rb
@@ -1,10 +1,10 @@
#
# = uri/ldap.rb
#
-# Author::
+# Author::
# Takaaki Tateishi <[email protected]>
# Akira Yamada <[email protected]>
-# License::
+# License::
# URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
# You can redistribute it and/or modify it under the same term as Ruby.
# Revision:: $Id$
@@ -21,7 +21,7 @@ module URI
class LDAP < Generic
DEFAULT_PORT = 389
-
+
COMPONENT = [
:scheme,
:host, :port,
diff --git a/lib/uri/mailto.rb b/lib/uri/mailto.rb
index 44f04f2dd5..cfbb914893 100644
--- a/lib/uri/mailto.rb
+++ b/lib/uri/mailto.rb
@@ -68,20 +68,20 @@ module URI
#
# If a Hash is used, the keys are the component names preceded by colons.
#
- # The headers can be supplied as a pre-encoded string, such as
+ # The headers can be supplied as a pre-encoded string, such as
# "subject=subscribe&cc=address", or as an Array of Arrays like
# [['subject', 'subscribe'], ['cc', 'address']]
#
# Examples:
- #
+ #
# require 'uri'
- #
+ #
# m1 = URI::MailTo.build(['[email protected]', 'subject=Ruby'])
# puts m1.to_s -> mailto:[email protected]?subject=Ruby
- #
+ #
# m2 = URI::MailTo.build(['[email protected]', [['Subject', 'Ruby'], ['Cc', '[email protected]']]])
# puts m2.to_s -> mailto:[email protected]?Subject=Ruby&[email protected]
- #
+ #
# m3 = URI::MailTo.build({:to => '[email protected]', :headers => [['subject', 'subscribe']]})
# puts m3.to_s -> mailto:[email protected]?subject=subscribe
#
@@ -183,7 +183,7 @@ module URI
return true unless v
return true if v.size == 0
- if OPAQUE !~ v ||
+ if OPAQUE !~ v ||
/\A(#{HEADER_PATTERN}(?:\&#{HEADER_PATTERN})*)\z/o !~ v
raise InvalidComponentError,
"bad component(expected opaque component): #{v}"
@@ -210,12 +210,12 @@ module URI
end
def to_s
- @scheme + ':' +
- if @to
+ @scheme + ':' +
+ if @to
@to
else
''
- end +
+ end +
if @headers.size > 0
'?' + @headers.collect{|x| x.join('=')}.join('&')
else
@@ -227,7 +227,7 @@ module URI
''
end
end
-
+
# Returns the RFC822 e-mail text equivalent of the URL, as a String.
#
# Example:
diff --git a/lib/webrick/cgi.rb b/lib/webrick/cgi.rb
index 6783803aba..d37ae6b23a 100644
--- a/lib/webrick/cgi.rb
+++ b/lib/webrick/cgi.rb
@@ -77,7 +77,7 @@ module WEBrick
res.set_error(ex)
rescue HTTPStatus::Status => ex
res.status = ex.code
- rescue Exception => ex
+ rescue Exception => ex
@logger.error(ex)
res.set_error(ex, true)
ensure
@@ -122,7 +122,7 @@ module WEBrick
include Enumerable
private
-
+
def initialize(config, env, stdin, stdout)
@config = config
@env = env
@@ -130,7 +130,7 @@ module WEBrick
@body_part = stdin
@out_port = stdout
@out_port.binmode
-
+
@server_addr = @env["SERVER_ADDR"] || "0.0.0.0"
@server_name = @env["SERVER_NAME"]
@server_port = @env["SERVER_PORT"]
@@ -164,7 +164,7 @@ module WEBrick
httpv = @config[:HTTPVersion]
return "#{meth} #{url} HTTP/#{httpv}"
end
-
+
def setup_header
add_header("CONTENT_TYPE", "Content-Type")
add_header("CONTENT_LENGTH", "Content-length")
@@ -174,7 +174,7 @@ module WEBrick
end
}
end
-
+
def add_header(envname, hdrname)
if value = @env[envname]
unless value.empty?
@@ -186,21 +186,21 @@ module WEBrick
def input
@header_part.eof? ? @body_part : @header_part
end
-
+
public
-
+
def peeraddr
[nil, @remote_port, @remote_host, @remote_addr]
end
-
+
def addr
[nil, @server_port, @server_name, @server_addr]
end
-
+
def gets(eol=LF)
input.gets(eol)
end
-
+
def read(size=nil)
input.read(size)
end
@@ -212,7 +212,7 @@ module WEBrick
def eof?
input.eof?
end
-
+
def <<(data)
@out_port << data
end
@@ -257,5 +257,5 @@ module WEBrick
end
end
end
- end
-end
+ end
+end
diff --git a/lib/webrick/config.rb b/lib/webrick/config.rb
index 5897b977d8..a96f8a7945 100644
--- a/lib/webrick/config.rb
+++ b/lib/webrick/config.rb
@@ -80,7 +80,7 @@ module WEBrick
}
DigestAuth = {
- :Algorithm => 'MD5-sess', # or 'MD5'
+ :Algorithm => 'MD5-sess', # or 'MD5'
:Domain => nil, # an array includes domain names.
:Qop => [ 'auth' ], # 'auth' or 'auth-int' or both.
:UseOpaque => true,
diff --git a/lib/webrick/httpauth/authenticator.rb b/lib/webrick/httpauth/authenticator.rb
index fe2dbf4e0c..9fdc38bf70 100644
--- a/lib/webrick/httpauth/authenticator.rb
+++ b/lib/webrick/httpauth/authenticator.rb
@@ -25,7 +25,7 @@ module WEBrick
unless config[sym]
raise ArgumentError, "Argument #{sym.inspect} missing."
end
- }
+ }
@realm = config[:Realm]
@userdb = config[:UserDB]
@logger = config[:Logger] || Log::new($stderr)
@@ -40,8 +40,8 @@ module WEBrick
def check_scheme(req)
unless credentials = req[@request_field]
error("no credentials in the request.")
- return nil
- end
+ return nil
+ end
unless match = /^#{@auth_scheme}\s+/.match(credentials)
error("invalid scheme in %s.", credentials)
info("%s: %s", @request_field, credentials) if $DEBUG
@@ -60,7 +60,7 @@ module WEBrick
if @logger.error?
log(:error, fmt, *args)
end
- end
+ end
def info(fmt, *args)
if @logger.info?
diff --git a/lib/webrick/httpauth/basicauth.rb b/lib/webrick/httpauth/basicauth.rb
index e835361dc2..210fb00bbe 100644
--- a/lib/webrick/httpauth/basicauth.rb
+++ b/lib/webrick/httpauth/basicauth.rb
@@ -34,7 +34,7 @@ module WEBrick
unless basic_credentials = check_scheme(req)
challenge(req, res)
end
- userid, password = basic_credentials.unpack("m*")[0].split(":", 2)
+ userid, password = basic_credentials.unpack("m*")[0].split(":", 2)
password ||= ""
if userid.empty?
error("user id was not given.")
diff --git a/lib/webrick/httpauth/digestauth.rb b/lib/webrick/httpauth/digestauth.rb
index 1644eecfc8..fbc9925bdd 100644
--- a/lib/webrick/httpauth/digestauth.rb
+++ b/lib/webrick/httpauth/digestauth.rb
@@ -118,16 +118,16 @@ module WEBrick
}
if !check_uri(req, auth_req)
- raise HTTPStatus::BadRequest
+ raise HTTPStatus::BadRequest
end
- if auth_req['realm'] != @realm
+ if auth_req['realm'] != @realm
error('%s: realm unmatch. "%s" for "%s"',
auth_req['username'], auth_req['realm'], @realm)
return false
end
- auth_req['algorithm'] ||= 'MD5'
+ auth_req['algorithm'] ||= 'MD5'
if auth_req['algorithm'] != @algorithm &&
(@opera_hack && auth_req['algorithm'] != @algorithm.upcase)
error('%s: algorithm unmatch. "%s" for "%s"',
@@ -230,7 +230,7 @@ module WEBrick
def split_param_value(string)
ret = {}
while string.size != 0
- case string
+ case string
when /^\s*([\w\-\.\*\%\!]+)=\s*\"((\\.|[^\"])*)\"\s*,?/
key = $1
matched = $2
@@ -320,7 +320,7 @@ module WEBrick
uri = auth_req['uri']
if uri != req.request_uri.to_s && uri != req.unparsed_uri &&
(@internet_explorer_hack && uri != req.path)
- error('%s: uri unmatch. "%s" for "%s"', auth_req['username'],
+ error('%s: uri unmatch. "%s" for "%s"', auth_req['username'],
auth_req['uri'], req.request_uri.to_s)
return false
end
diff --git a/lib/webrick/httpauth/userdb.rb b/lib/webrick/httpauth/userdb.rb
index 33e01405f4..0285f89352 100644
--- a/lib/webrick/httpauth/userdb.rb
+++ b/lib/webrick/httpauth/userdb.rb
@@ -18,7 +18,7 @@ module WEBrick
def set_passwd(realm, user, pass)
self[user] = pass
- end
+ end
def get_passwd(realm, user, reload_db=false)
# reload_db is dummy
diff --git a/lib/webrick/httpproxy.rb b/lib/webrick/httpproxy.rb
index 9295259085..528e173b5b 100644
--- a/lib/webrick/httpproxy.rb
+++ b/lib/webrick/httpproxy.rb
@@ -101,7 +101,7 @@ module WEBrick
def proxy_service(req, res)
# Proxy Authentication
- proxy_auth(req, res)
+ proxy_auth(req, res)
# Create Request-URI to send to the origin server
uri = req.request_uri
@@ -129,7 +129,7 @@ module WEBrick
http = Net::HTTP.new(uri.host, uri.port, proxy_host, proxy_port)
http.start{
if @config[:ProxyTimeout]
- ################################## these issues are
+ ################################## these issues are
http.open_timeout = 30 # secs # necessary (maybe bacause
http.read_timeout = 60 # secs # Ruby's bug, but why?)
##################################
@@ -147,7 +147,7 @@ module WEBrick
logger.debug("#{err.class}: #{err.message}")
raise HTTPStatus::ServiceUnavailable, err.message
end
-
+
# Persistent connction requirements are mysterious for me.
# So I will close the connection in every response.
res['proxy-connection'] = "close"
diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb
index 5bb470285f..0547a3acd6 100644
--- a/lib/webrick/httprequest.rb
+++ b/lib/webrick/httprequest.rb
@@ -274,7 +274,7 @@ module WEBrick
end
elsif self['content-length'] || @remaining_size
@remaining_size ||= self['content-length'].to_i
- while @remaining_size > 0
+ while @remaining_size > 0
sz = BUFSIZE < @remaining_size ? BUFSIZE : @remaining_size
break unless buf = read_data(socket, sz)
@remaining_size -= buf.size
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 62156b1abd..df78daac13 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -202,10 +202,10 @@ module WEBrick
def set_error(ex, backtrace=false)
case ex
- when HTTPStatus::Status
+ when HTTPStatus::Status
@keep_alive = false if HTTPStatus::error?(ex.code)
self.status = ex.code
- else
+ else
@keep_alive = false
self.status = HTTPStatus::RC_INTERNAL_SERVER_ERROR
end
diff --git a/lib/webrick/httpserver.rb b/lib/webrick/httpserver.rb
index 9edb0018f8..9f3c07e134 100644
--- a/lib/webrick/httpserver.rb
+++ b/lib/webrick/httpserver.rb
@@ -36,12 +36,12 @@ module WEBrick
[ $stderr, AccessLog::REFERER_LOG_FORMAT ]
]
end
-
+
@virtual_hosts = Array.new
end
def run(sock)
- while true
+ while true
res = HTTPResponse.new(@config)
req = HTTPRequest.new(@config)
server = self
diff --git a/lib/webrick/httpservlet/cgihandler.rb b/lib/webrick/httpservlet/cgihandler.rb
index 584208cef3..c3d24fc651 100644
--- a/lib/webrick/httpservlet/cgihandler.rb
+++ b/lib/webrick/httpservlet/cgihandler.rb
@@ -1,11 +1,11 @@
-#
+#
# cgihandler.rb -- CGIHandler Class
-#
+#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
-#
+#
# $IPR: cgihandler.rb,v 1.27 2003/03/21 19:56:01 gotoyuzo Exp $
require 'rbconfig'
@@ -66,16 +66,16 @@ module WEBrick
if errmsg.size > 0
@logger.error("CGIHandler: #{@script_filename}:\n" + errmsg)
end
- end
+ end
cgi_err.close(true)
end
-
+
if status != 0
@logger.error("CGIHandler: #{@script_filename} exit with #{status}")
end
data = "" unless data
- raw_header, body = data.split(/^[\xd\xa]+/on, 2)
+ raw_header, body = data.split(/^[\xd\xa]+/on, 2)
raise HTTPStatus::InternalServerError,
"Premature end of script headers: #{@script_filename}" if body.nil?
diff --git a/lib/webrick/httpservlet/erbhandler.rb b/lib/webrick/httpservlet/erbhandler.rb
index b9d5e65b65..c8f829acce 100644
--- a/lib/webrick/httpservlet/erbhandler.rb
+++ b/lib/webrick/httpservlet/erbhandler.rb
@@ -1,11 +1,11 @@
-#
+#
# erbhandler.rb -- ERBHandler Class
-#
+#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
-#
+#
# $IPR: erbhandler.rb,v 1.25 2003/02/24 19:25:31 gotoyuzo Exp $
require 'webrick/httpservlet/abstract.rb'
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb
index 6f6074d81f..948de2f883 100644
--- a/lib/webrick/httpservlet/filehandler.rb
+++ b/lib/webrick/httpservlet/filehandler.rb
@@ -32,7 +32,7 @@ module WEBrick
if not_modified?(req, res, mtime, res['etag'])
res.body = ''
raise HTTPStatus::NotModified
- elsif req['range']
+ elsif req['range']
make_partial_content(req, res, @local_path, st.size)
raise HTTPStatus::PartialContent
else
@@ -402,7 +402,7 @@ module WEBrick
res.body << "<A HREF=\"?M=#{d1}\">Last modified</A> "
res.body << "<A HREF=\"?S=#{d1}\">Size</A>\n"
res.body << "<HR>\n"
-
+
list.unshift [ "..", File::mtime(local_path+"/.."), -1 ]
list.each{ |name, time, size|
if name == ".."
@@ -420,7 +420,7 @@ module WEBrick
}
res.body << "</PRE><HR>"
- res.body << <<-_end_of_html_
+ res.body << <<-_end_of_html_
<ADDRESS>
#{HTMLUtils::escape(@config[:ServerSoftware])}<BR>
at #{req.host}:#{req.port}
diff --git a/lib/webrick/httpservlet/prochandler.rb b/lib/webrick/httpservlet/prochandler.rb
index 783cb27896..2be3c854c1 100644
--- a/lib/webrick/httpservlet/prochandler.rb
+++ b/lib/webrick/httpservlet/prochandler.rb
@@ -1,11 +1,11 @@
-#
+#
# prochandler.rb -- ProcHandler Class
-#
+#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
-#
+#
# $IPR: prochandler.rb,v 1.7 2002/09/21 12:23:42 gotoyuzo Exp $
require 'webrick/httpservlet/abstract.rb'
@@ -16,7 +16,7 @@ module WEBrick
class ProcHandler < AbstractServlet
def get_instance(server, *options)
self
- end
+ end
def initialize(proc)
@proc = proc
diff --git a/lib/webrick/httpstatus.rb b/lib/webrick/httpstatus.rb
index 6623983f87..f5be6bfdfe 100644
--- a/lib/webrick/httpstatus.rb
+++ b/lib/webrick/httpstatus.rb
@@ -30,7 +30,7 @@ module WEBrick
class Error < Status; end
class ClientError < Error; end
class ServerError < Error; end
-
+
class EOFError < StandardError; end
StatusMessage = {
diff --git a/lib/webrick/httputils.rb b/lib/webrick/httputils.rb
index 5c78379ca0..e749d87ec9 100644
--- a/lib/webrick/httputils.rb
+++ b/lib/webrick/httputils.rb
@@ -97,7 +97,7 @@ module WEBrick
next if /^#/ =~ line
line.chomp!
mimetype, ext0 = line.split(/\s+/, 2)
- next unless ext0
+ next unless ext0
next if ext0.empty?
ext0.split(/\s+/).each{ |ext| hash[ext] = mimetype }
}
@@ -215,7 +215,7 @@ module WEBrick
super("")
else
@raw_header = EmptyRawHeader
- @header = EmptyHeader
+ @header = EmptyHeader
super(args.shift)
unless args.empty?
@next_data = self.class.new(*args)
@@ -249,7 +249,7 @@ module WEBrick
def append_data(data)
tmp = self
while tmp
- unless tmp.next_data
+ unless tmp.next_data
tmp.next_data = data
break
end
@@ -286,7 +286,7 @@ module WEBrick
query = Hash.new
if str
str.split(/[&;]/).each{|x|
- next if x.empty?
+ next if x.empty?
key, val = x.split(/=/,2)
key = unescape_form(key)
val = unescape_form(val.to_s)
@@ -316,7 +316,7 @@ module WEBrick
if form_data.has_key?(key)
form_data[key].append_data(data)
else
- form_data[key] = data
+ form_data[key] = data
end
end
data = FormData.new
diff --git a/lib/webrick/log.rb b/lib/webrick/log.rb
index 5d4fd0a174..0ffa12dd96 100644
--- a/lib/webrick/log.rb
+++ b/lib/webrick/log.rb
@@ -72,7 +72,7 @@ module WEBrick
end
class Log < BasicLog
- attr_accessor :time_format
+ attr_accessor :time_format
def initialize(log_file=nil, level=nil)
super(log_file, level)
diff --git a/lib/webrick/ssl.rb b/lib/webrick/ssl.rb
index 03bfdf4aa0..896206b483 100644
--- a/lib/webrick/ssl.rb
+++ b/lib/webrick/ssl.rb
@@ -2,7 +2,7 @@
# ssl.rb -- SSL/TLS enhancement for GenericServer
#
# Copyright (c) 2003 GOTOU Yuuzou All rights reserved.
-#
+#
# $Id$
require 'webrick'
@@ -41,7 +41,7 @@ module WEBrick
case p
when 0; $stderr.putc "." # BN_generate_prime
when 1; $stderr.putc "+" # BN_generate_prime
- when 2; $stderr.putc "*" # searching good prime,
+ when 2; $stderr.putc "*" # searching good prime,
# n = #of try,
# but also data from BN_generate_prime
when 3; $stderr.putc "\n" # found good prime, n==0 - p, n==1 - q,
@@ -88,7 +88,7 @@ module WEBrick
if @config[:SSLEnable]
unless ssl_context
@ssl_context = setup_ssl_context(@config)
- @logger.info("\n" + @config[:SSLCertificate].to_text)
+ @logger.info("\n" + @config[:SSLCertificate].to_text)
end
listeners.collect!{|svr|
ssvr = ::OpenSSL::SSL::SSLServer.new(svr, ssl_context)
diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb
index cf9da6f2ce..823a329fbd 100644
--- a/lib/webrick/utils.rb
+++ b/lib/webrick/utils.rb
@@ -86,13 +86,13 @@ module WEBrick
RAND_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
"0123456789" +
- "abcdefghijklmnopqrstuvwxyz"
+ "abcdefghijklmnopqrstuvwxyz"
def random_string(len)
rand_max = RAND_CHARS.size
- ret = ""
+ ret = ""
len.times{ ret << RAND_CHARS[rand(rand_max)] }
- ret
+ ret
end
module_function :random_string
diff --git a/lib/wsdl/info.rb b/lib/wsdl/info.rb
index ffd90390a4..069fc46996 100644
--- a/lib/wsdl/info.rb
+++ b/lib/wsdl/info.rb
@@ -29,7 +29,7 @@ class Info
end
def parse_element(element); end # abstract
-
+
def parse_attr(attr, value); end # abstract
def parse_epilogue; end # abstract
diff --git a/lib/wsdl/soap/classDefCreator.rb b/lib/wsdl/soap/classDefCreator.rb
index aeb67c0613..ac9724fde4 100644
--- a/lib/wsdl/soap/classDefCreator.rb
+++ b/lib/wsdl/soap/classDefCreator.rb
@@ -250,13 +250,13 @@ private
end
def name_element(element)
- return element.name if element.name
+ return element.name if element.name
return element.ref if element.ref
raise RuntimeError.new("cannot define name of #{element}")
end
def name_attribute(attribute)
- return attribute.name if attribute.name
+ return attribute.name if attribute.name
return attribute.ref if attribute.ref
raise RuntimeError.new("cannot define name of #{attribute}")
end
diff --git a/lib/wsdl/soap/complexType.rb b/lib/wsdl/soap/complexType.rb
index b2e13d0564..ab794ad68b 100644
--- a/lib/wsdl/soap/complexType.rb
+++ b/lib/wsdl/soap/complexType.rb
@@ -132,7 +132,7 @@ private
def element_simpletype(element)
if element.type
- element.type
+ element.type
elsif element.local_simpletype
element.local_simpletype.base
else
diff --git a/lib/wsdl/soap/definitions.rb b/lib/wsdl/soap/definitions.rb
index b014d5af6b..02d588a6e0 100644
--- a/lib/wsdl/soap/definitions.rb
+++ b/lib/wsdl/soap/definitions.rb
@@ -39,10 +39,10 @@ class Definitions < Info
=begin
<xs:complexType name="Fault" final="extension">
<xs:sequence>
- <xs:element name="faultcode" type="xs:QName" />
- <xs:element name="faultstring" type="xs:string" />
- <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
- <xs:element name="detail" type="tns:detail" minOccurs="0" />
+ <xs:element name="faultcode" type="xs:QName" />
+ <xs:element name="faultstring" type="xs:string" />
+ <xs:element name="faultactor" type="xs:anyURI" minOccurs="0" />
+ <xs:element name="detail" type="tns:detail" minOccurs="0" />
</xs:sequence>
</xs:complexType>
=end
diff --git a/lib/wsdl/soap/methodDefCreator.rb b/lib/wsdl/soap/methodDefCreator.rb
index f3ffadbe69..b7890a6441 100644
--- a/lib/wsdl/soap/methodDefCreator.rb
+++ b/lib/wsdl/soap/methodDefCreator.rb
@@ -201,9 +201,9 @@ __EOD__
def type2str(type)
if type.size == 1
- "[#{dq(type[0])}]"
+ "[#{dq(type[0])}]"
else
- "[#{dq(type[0])}, #{ndq(type[1])}, #{dq(type[2])}]"
+ "[#{dq(type[0])}, #{ndq(type[1])}, #{dq(type[2])}]"
end
end
diff --git a/lib/wsdl/soap/operation.rb b/lib/wsdl/soap/operation.rb
index 502d34a07d..f5fb3332ba 100644
--- a/lib/wsdl/soap/operation.rb
+++ b/lib/wsdl/soap/operation.rb
@@ -22,7 +22,7 @@ class Operation < Info
attr_reader :bodyparts
attr_reader :faultpart
attr_reader :soapaction
-
+
def initialize(style, op_name, optype_name, headerparts, bodyparts, faultpart, soapaction)
@style = style
@op_name = op_name
diff --git a/lib/wsdl/xmlSchema/complexType.rb b/lib/wsdl/xmlSchema/complexType.rb
index dc9ec954fc..c9ef733b3e 100644
--- a/lib/wsdl/xmlSchema/complexType.rb
+++ b/lib/wsdl/xmlSchema/complexType.rb
@@ -45,7 +45,7 @@ class ComplexType < Info
def elementformdefault
parent.elementformdefault
end
-
+
AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName)
def each_element
if content
diff --git a/lib/wsdl/xmlSchema/simpleExtension.rb b/lib/wsdl/xmlSchema/simpleExtension.rb
index 3c53a7328c..a8782174e3 100644
--- a/lib/wsdl/xmlSchema/simpleExtension.rb
+++ b/lib/wsdl/xmlSchema/simpleExtension.rb
@@ -27,7 +27,7 @@ class SimpleExtension < Info
def targetnamespace
parent.targetnamespace
end
-
+
def valid?(value)
true
end
diff --git a/lib/wsdl/xmlSchema/simpleRestriction.rb b/lib/wsdl/xmlSchema/simpleRestriction.rb
index e8bf3ebfa5..2e8deb8b1d 100644
--- a/lib/wsdl/xmlSchema/simpleRestriction.rb
+++ b/lib/wsdl/xmlSchema/simpleRestriction.rb
@@ -27,7 +27,7 @@ class SimpleRestriction < Info
@length = nil
@pattern = nil
end
-
+
def valid?(value)
return false unless check_restriction(value)
return false unless check_length(value)
diff --git a/lib/xmlrpc/base64.rb b/lib/xmlrpc/base64.rb
index f9a21c703a..bfa8c0a2d5 100644
--- a/lib/xmlrpc/base64.rb
+++ b/lib/xmlrpc/base64.rb
@@ -9,19 +9,19 @@ Released under the same term of license as Ruby.
= XMLRPC::Base64
== Description
-This class is necessary for (('xmlrpc4r')) to determine that a string should
-be transmitted base64-encoded and not as a raw-string.
-You can use (({XMLRPC::Base64})) on the client and server-side as a
+This class is necessary for (('xmlrpc4r')) to determine that a string should
+be transmitted base64-encoded and not as a raw-string.
+You can use (({XMLRPC::Base64})) on the client and server-side as a
parameter and/or return-value.
== Class Methods
--- XMLRPC::Base64.new( str, state = :dec )
Creates a new (({XMLRPC::Base64})) instance with string ((|str|)) as the
- internal string. When ((|state|)) is (({:dec})) it assumes that the
- string ((|str|)) is not in base64 format (perhaps already decoded),
- otherwise if ((|state|)) is (({:enc})) it decodes ((|str|))
+ internal string. When ((|state|)) is (({:dec})) it assumes that the
+ string ((|str|)) is not in base64 format (perhaps already decoded),
+ otherwise if ((|state|)) is (({:enc})) it decodes ((|str|))
and stores it as the internal string.
-
+
--- XMLRPC::Base64.decode( str )
Decodes string ((|str|)) with base64 and returns that value.
@@ -40,7 +40,7 @@ parameter and/or return-value.
module XMLRPC
class Base64
-
+
def initialize(str, state = :dec)
case state
when :enc
@@ -51,11 +51,11 @@ class Base64
raise ArgumentError, "wrong argument; either :enc or :dec"
end
end
-
+
def decoded
- @str
+ @str
end
-
+
def encoded
Base64.encode(@str)
end
diff --git a/lib/xmlrpc/client.rb b/lib/xmlrpc/client.rb
index 278855e01d..7c12f2b96b 100644
--- a/lib/xmlrpc/client.rb
+++ b/lib/xmlrpc/client.rb
@@ -26,7 +26,7 @@ Released under the same term of license as Ruby.
or
require "xmlrpc/client"
-
+
server = XMLRPC::Client.new("www.ruby-lang.org", "/RPC2", 80)
ok, param = server.call2("michael.add", 4, 5)
if ok then
@@ -40,14 +40,14 @@ or
== Description
Class (({XMLRPC::Client})) provides remote procedure calls to a XML-RPC server.
After setting the connection-parameters with ((<XMLRPC::Client.new>)) which
-creates a new (({XMLRPC::Client})) instance, you can execute a remote procedure
+creates a new (({XMLRPC::Client})) instance, you can execute a remote procedure
by sending the ((<call|XMLRPC::Client#call>)) or ((<call2|XMLRPC::Client#call2>))
-message to this new instance. The given parameters indicate which method to
+message to this new instance. The given parameters indicate which method to
call on the remote-side and of course the parameters for the remote procedure.
== Class Methods
--- XMLRPC::Client.new( host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil, user=nil, password=nil, use_ssl=false, timeout =nil)
- Creates an object which represents the remote XML-RPC server on the
+ Creates an object which represents the remote XML-RPC server on the
given host ((|host|)). If the server is CGI-based, ((|path|)) is the
path to the CGI-script, which will be called, otherwise (in the
case of a standalone server) ((|path|)) should be (({"/RPC2"})).
@@ -59,8 +59,8 @@ call on the remote-side and of course the parameters for the remote procedure.
Default values for ((|host|)), ((|path|)) and ((|port|)) are 'localhost', '/RPC2' and
'80' respectively using SSL '443'.
- If ((|user|)) and ((|password|)) are given, each time a request is send,
- a Authorization header is send. Currently only Basic Authentification is
+ If ((|user|)) and ((|password|)) are given, each time a request is send,
+ a Authorization header is send. Currently only Basic Authentification is
implemented no Digest.
If ((|use_ssl|)) is set to (({true})), comunication over SSL is enabled.
@@ -76,9 +76,9 @@ call on the remote-side and of course the parameters for the remote procedure.
: proxy
Is of the form "host:port".
-
+
: timeout
- Defaults to 30.
+ Defaults to 30.
--- XMLRPC::Client.new3( hash={} )
--- XMLRPC::Client.new_from_hash( hash={} )
@@ -97,10 +97,10 @@ call on the remote-side and of course the parameters for the remote procedure.
== Instance Methods
--- XMLRPC::Client#call( method, *args )
- Invokes the method named ((|method|)) with the parameters given by
+ Invokes the method named ((|method|)) with the parameters given by
((|args|)) on the XML-RPC server.
- The parameter ((|method|)) is converted into a (({String})) and should
- be a valid XML-RPC method-name.
+ The parameter ((|method|)) is converted into a (({String})) and should
+ be a valid XML-RPC method-name.
Each parameter of ((|args|)) must be of one of the following types,
where (({Hash})), (({Struct})) and (({Array})) can contain any of these listed ((:types:)):
* (({Fixnum})), (({Bignum}))
@@ -110,31 +110,31 @@ call on the remote-side and of course the parameters for the remote procedure.
* (({Hash})), (({Struct}))
* (({Array}))
* (({Date})), (({Time})), (({XMLRPC::DateTime}))
- * (({XMLRPC::Base64}))
- * A Ruby object which class includes XMLRPC::Marshallable (only if Config::ENABLE_MARSHALLABLE is (({true}))).
+ * (({XMLRPC::Base64}))
+ * A Ruby object which class includes XMLRPC::Marshallable (only if Config::ENABLE_MARSHALLABLE is (({true}))).
That object is converted into a hash, with one additional key/value pair "___class___" which contains the class name
for restoring later that object.
-
- The method returns the return-value from the RPC
- ((-stands for Remote Procedure Call-)).
+
+ The method returns the return-value from the RPC
+ ((-stands for Remote Procedure Call-)).
The type of the return-value is one of the above shown,
only that a (({Bignum})) is only allowed when it fits in 32-bit and
that a XML-RPC (('dateTime.iso8601')) type is always returned as
- a ((<(({XMLRPC::DateTime}))|URL:datetime.html>)) object and
+ a ((<(({XMLRPC::DateTime}))|URL:datetime.html>)) object and
a (({Struct})) is never returned, only a (({Hash})), the same for a (({Symbol})), where
- always a (({String})) is returned.
+ always a (({String})) is returned.
A (({XMLRPC::Base64})) is returned as a (({String})) from xmlrpc4r version 1.6.1 on.
-
- If the remote procedure returned a fault-structure, then a
+
+ If the remote procedure returned a fault-structure, then a
(({XMLRPC::FaultException})) exception is raised, which has two accessor-methods
(({faultCode})) and (({faultString})) of type (({Integer})) and (({String})).
--- XMLRPC::Client#call2( method, *args )
The difference between this method and ((<call|XMLRPC::Client#call>)) is, that
this method do ((*not*)) raise a (({XMLRPC::FaultException})) exception.
- The method returns an array of two values. The first value indicates if
+ The method returns an array of two values. The first value indicates if
the second value is a return-value ((({true}))) or an object of type
- (({XMLRPC::FaultException})).
+ (({XMLRPC::FaultException})).
Both are explained in ((<call|XMLRPC::Client#call>)).
Simple to remember: The "2" in "call2" denotes the number of values it returns.
@@ -151,19 +151,19 @@ call on the remote-side and of course the parameters for the remote procedure.
# => [7, -1]
--- XMLRPC::Client#multicall2( *methods )
- Same as ((<XMLRPC::Client#multicall>)), but returns like ((<XMLRPC::Client#call2>)) two parameters
+ Same as ((<XMLRPC::Client#multicall>)), but returns like ((<XMLRPC::Client#call2>)) two parameters
instead of raising an (({XMLRPC::FaultException})).
--- XMLRPC::Client#proxy( prefix, *args )
Returns an object of class (({XMLRPC::Client::Proxy})), initialized with
((|prefix|)) and ((|args|)). A proxy object returned by this method behaves
like ((<XMLRPC::Client#call>)), i.e. a call on that object will raise a
- (({XMLRPC::FaultException})) when a fault-structure is returned by that call.
+ (({XMLRPC::FaultException})) when a fault-structure is returned by that call.
--- XMLRPC::Client#proxy2( prefix, *args )
Almost the same like ((<XMLRPC::Client#proxy>)) only that a call on the returned
(({XMLRPC::Client::Proxy})) object behaves like ((<XMLRPC::Client#call2>)), i.e.
- a call on that object will return two parameters.
+ a call on that object will return two parameters.
@@ -175,21 +175,21 @@ call on the remote-side and of course the parameters for the remote procedure.
--- XMLRPC::Client#proxy_async(...)
--- XMLRPC::Client#proxy2_async(...)
In contrast to corresponding methods without "_async", these can be
- called concurrently and use for each request a new connection, where the
+ called concurrently and use for each request a new connection, where the
non-asynchronous counterparts use connection-alive (one connection for all requests)
- if possible.
+ if possible.
- Note, that you have to use Threads to call these methods concurrently.
+ Note, that you have to use Threads to call these methods concurrently.
The following example calls two methods concurrently:
-
+
Thread.new {
p client.call_async("michael.add", 4, 5)
}
-
+
Thread.new {
p client.call_async("michael.div", 7, 9)
}
-
+
--- XMLRPC::Client#timeout
--- XMLRPC::Client#user
@@ -200,12 +200,12 @@ call on the remote-side and of course the parameters for the remote procedure.
--- XMLRPC::Client#user= (new_user)
--- XMLRPC::Client#password= (new_password)
Set the corresponding attributes.
-
+
--- XMLRPC::Client#set_writer( writer )
Sets the XML writer to use for generating XML output.
Should be an instance of a class from module (({XMLRPC::XMLWriter})).
- If this method is not called, then (({XMLRPC::Config::DEFAULT_WRITER})) is used.
+ If this method is not called, then (({XMLRPC::Config::DEFAULT_WRITER})) is used.
--- XMLRPC::Client#set_parser( parser )
Sets the XML parser to use for parsing XML documents.
@@ -220,7 +220,7 @@ call on the remote-side and of course the parameters for the remote procedure.
Set extra HTTP headers that are included in the request.
--- XMLRPC::Client#http_header_extra
- Access the via ((<XMLRPC::Client#http_header_extra=>)) assigned header.
+ Access the via ((<XMLRPC::Client#http_header_extra=>)) assigned header.
--- XMLRPC::Client#http_last_response
Returns the (({Net::HTTPResponse})) object of the last RPC.
@@ -240,31 +240,31 @@ call on the remote-side and of course the parameters for the remote procedure.
== Description
Class (({XMLRPC::Client::Proxy})) makes XML-RPC calls look nicer!
-You can call any method onto objects of that class - the object handles
+You can call any method onto objects of that class - the object handles
(({method_missing})) and will forward the method call to a XML-RPC server.
Don't use this class directly, but use instead method ((<XMLRPC::Client#proxy>)) or
((<XMLRPC::Client#proxy2>)).
== Class Methods
---- XMLRPC::Client::Proxy.new( server, prefix, args=[], meth=:call, delim="." )
+--- XMLRPC::Client::Proxy.new( server, prefix, args=[], meth=:call, delim="." )
Creates an object which provides (({method_missing})).
((|server|)) must be of type (({XMLRPC::Client})), which is the XML-RPC server to be used
for a XML-RPC call. ((|prefix|)) and ((|delim|)) will be prepended to the methodname
- called onto this object.
+ called onto this object.
Parameter ((|meth|)) is the method (call, call2, call_async, call2_async) to use for
a RPC.
((|args|)) are arguments which are automatically given
to every XML-RPC call before the arguments provides through (({method_missing})).
-
+
== Instance Methods
Every method call is forwarded to the XML-RPC server defined in ((<new|XMLRPC::Client::Proxy#new>)).
-
+
Note: Inherited methods from class (({Object})) cannot be used as XML-RPC names, because they get around
-(({method_missing})).
-
+(({method_missing})).
+
= History
@@ -283,7 +283,7 @@ require "net/http"
module XMLRPC
class Client
-
+
USER_AGENT = "XMLRPC::Client (Ruby #{RUBY_VERSION})"
include ParserWriterChooseMixin
@@ -292,11 +292,11 @@ module XMLRPC
# Constructors -------------------------------------------------------------------
- def initialize(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil,
+ def initialize(host=nil, path=nil, port=nil, proxy_host=nil, proxy_port=nil,
user=nil, password=nil, use_ssl=nil, timeout=nil)
@http_header_extra = nil
- @http_last_response = nil
+ @http_last_response = nil
@cookie = nil
@host = host || "localhost"
@@ -325,7 +325,7 @@ module XMLRPC
# HTTP object for synchronous calls
Net::HTTP.version_1_2
- @http = Net::HTTP.new(@host, @port, @proxy_host, @proxy_port)
+ @http = Net::HTTP.new(@host, @port, @proxy_host, @proxy_port)
@http.use_ssl = @use_ssl if @use_ssl
@http.read_timeout = @timeout
@http.open_timeout = @timeout
@@ -341,7 +341,7 @@ module XMLRPC
if match = /^([^:]+):\/\/(([^@]+)@)?([^\/]+)(\/.*)?$/.match(uri)
proto = match[1]
user, passwd = (match[3] || "").split(":")
- host, port = match[4].split(":")
+ host, port = match[4].split(":")
path = match[5]
if proto != "http" and proto != "https"
@@ -351,7 +351,7 @@ module XMLRPC
else
raise "Wrong URI as parameter!"
end
-
+
proxy_host, proxy_port = (proxy || "").split(":")
self.new(host, path, port, proxy_host, proxy_port, user, passwd, (proto == "https"), timeout)
@@ -384,7 +384,7 @@ module XMLRPC
# Cookie support
attr_accessor :cookie
-
+
attr_reader :timeout, :user, :password
@@ -407,13 +407,13 @@ module XMLRPC
# Call methods --------------------------------------------------------------
def call(method, *args)
- ok, param = call2(method, *args)
+ ok, param = call2(method, *args)
if ok
param
else
raise param
end
- end
+ end
def call2(method, *args)
request = create().methodCall(method, *args)
@@ -422,13 +422,13 @@ module XMLRPC
end
def call_async(method, *args)
- ok, param = call2_async(method, *args)
+ ok, param = call2_async(method, *args)
if ok
param
else
raise param
end
- end
+ end
def call2_async(method, *args)
request = create().methodCall(method, *args)
@@ -467,7 +467,7 @@ module XMLRPC
# Proxy generating methods ------------------------------------------
-
+
def proxy(prefix=nil, *args)
Proxy.new(self, prefix, args, :call)
end
@@ -498,10 +498,10 @@ module XMLRPC
end
def do_rpc(request, async=false)
- header = {
+ header = {
"User-Agent" => USER_AGENT,
"Content-Type" => "text/xml; charset=utf-8",
- "Content-Length" => request.size.to_s,
+ "Content-Length" => request.size.to_s,
"Connection" => (async ? "close" : "keep-alive")
}
@@ -512,41 +512,41 @@ module XMLRPC
# add authorization header
header["Authorization"] = @auth
end
-
+
resp = nil
@http_last_response = nil
if async
- # use a new HTTP object for each call
+ # use a new HTTP object for each call
Net::HTTP.version_1_2
- http = Net::HTTP.new(@host, @port, @proxy_host, @proxy_port)
+ http = Net::HTTP.new(@host, @port, @proxy_host, @proxy_port)
http.use_ssl = @use_ssl if @use_ssl
http.read_timeout = @timeout
http.open_timeout = @timeout
-
+
# post request
http.start {
- resp = http.post2(@path, request, header)
+ resp = http.post2(@path, request, header)
}
else
# reuse the HTTP object for each call => connection alive is possible
# we must start connection explicitely first time so that http.request
# does not assume that we don't want keepalive
@http.start if not @http.started?
-
+
# post request
- resp = @http.post2(@path, request, header)
+ resp = @http.post2(@path, request, header)
end
-
+
@http_last_response = resp
data = resp.body
if resp.code == "401"
# Authorization Required
- raise "Authorization failed.\nHTTP-Error: #{resp.code} #{resp.message}"
+ raise "Authorization failed.\nHTTP-Error: #{resp.code} #{resp.message}"
elsif resp.code[0,1] != "2"
- raise "HTTP-Error: #{resp.code} #{resp.message}"
+ raise "HTTP-Error: #{resp.code} #{resp.message}"
end
ct = parse_content_type(resp["Content-Type"]).first
@@ -559,8 +559,8 @@ module XMLRPC
end
expected = resp["Content-Length"] || "<unknown>"
- if data.nil? or data.size == 0
- raise "Wrong size. Was #{data.size}, should be #{expected}"
+ if data.nil? or data.size == 0
+ raise "Wrong size. Was #{data.size}, should be #{expected}"
elsif expected != "<unknown>" and expected.to_i != data.size and resp["Transfer-Encoding"].nil?
raise "Wrong size. Was #{data.size}, should be #{expected}"
end
@@ -581,11 +581,11 @@ module XMLRPC
meth = :call2
meth = :call2_async if async
- ok, params = self.send(meth, "system.multicall",
+ ok, params = self.send(meth, "system.multicall",
methods.collect {|m| {'methodName' => m[0], 'params' => m[1..-1]} }
)
- if ok
+ if ok
params = params.collect do |param|
if param.is_a? Array
param[0]
@@ -593,7 +593,7 @@ module XMLRPC
XMLRPC::FaultException.new(param["faultCode"], param["faultString"])
else
raise "Wrong multicall return value"
- end
+ end
end
end
@@ -607,7 +607,7 @@ module XMLRPC
def initialize(server, prefix, args=[], meth=:call, delim=".")
@server = server
@prefix = prefix ? prefix + delim : ""
- @args = args
+ @args = args
@meth = meth
end
diff --git a/lib/xmlrpc/config.rb b/lib/xmlrpc/config.rb
index c4d2c41aac..34c3bbaf1b 100644
--- a/lib/xmlrpc/config.rb
+++ b/lib/xmlrpc/config.rb
@@ -8,7 +8,7 @@ module XMLRPC
module Config
DEFAULT_WRITER = XMLWriter::Simple # or XMLWriter::XMLParser
-
+
# available parser:
# * XMLParser::NQXMLTreeParser
# * XMLParser::NQXMLStreamParser
@@ -21,16 +21,16 @@ module XMLRPC
# enable <nil/> tag
ENABLE_NIL_CREATE = false
ENABLE_NIL_PARSER = false
-
+
# allows integers greater than 32-bit if true
ENABLE_BIGINT = false
# enable marshalling ruby objects which include XMLRPC::Marshallable
- ENABLE_MARSHALLING = true
+ ENABLE_MARSHALLING = true
# enable multiCall extension by default
ENABLE_MULTICALL = false
-
+
# enable Introspection extension by default
ENABLE_INTROSPECTION = false
diff --git a/lib/xmlrpc/create.rb b/lib/xmlrpc/create.rb
index b5c94254a4..334d9e0d8b 100644
--- a/lib/xmlrpc/create.rb
+++ b/lib/xmlrpc/create.rb
@@ -1,6 +1,6 @@
#
# Creates XML-RPC call/response documents
-#
+#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann ([email protected])
#
# $Id$
@@ -41,7 +41,7 @@ module XMLRPC
def element(name, attrs, *children)
raise "attributes not yet implemented" unless attrs.nil?
if children.empty?
- "<#{name}/>"
+ "<#{name}/>"
else
"<#{name}>" + children.join("") + "</#{name}>"
end
@@ -69,7 +69,7 @@ module XMLRPC
end
def document(*params)
- XML::SimpleTree::Document.new(*params)
+ XML::SimpleTree::Document.new(*params)
end
def pi(name, *params)
@@ -120,9 +120,9 @@ module XMLRPC
tree = @writer.document(
@writer.pi("xml", 'version="1.0"'),
- @writer.ele("methodCall",
+ @writer.ele("methodCall",
@writer.tag("methodName", name),
- @writer.ele("params", *parameter)
+ @writer.ele("params", *parameter)
)
)
@@ -137,29 +137,29 @@ module XMLRPC
# if is_ret == false then the params array must
# contain only one element, which is a structure
# of a fault return-value.
- #
- # if is_ret == true then a normal
+ #
+ # if is_ret == true then a normal
# return-value of all the given params is created.
#
def methodResponse(is_ret, *params)
- if is_ret
+ if is_ret
resp = params.collect do |param|
@writer.ele("param", conv2value(param))
end
-
+
resp = [@writer.ele("params", *resp)]
else
- if params.size != 1 or params[0] === XMLRPC::FaultException
+ if params.size != 1 or params[0] === XMLRPC::FaultException
raise ArgumentError, "no valid fault-structure given"
end
resp = @writer.ele("fault", conv2value(params[0].to_h))
end
-
+
tree = @writer.document(
@writer.pi("xml", 'version="1.0"'),
- @writer.ele("methodResponse", resp)
+ @writer.ele("methodResponse", resp)
)
@writer.document_to_str(tree) + "\n"
@@ -178,7 +178,7 @@ module XMLRPC
def conv2value(param)
val = case param
- when Fixnum
+ when Fixnum
@writer.tag("i4", param.to_s)
when Bignum
@@ -194,10 +194,10 @@ module XMLRPC
when TrueClass, FalseClass
@writer.tag("boolean", param ? "1" : "0")
- when String
+ when String
@writer.tag("string", param)
- when Symbol
+ when Symbol
@writer.tag("string", param.to_s)
when NilClass
@@ -211,51 +211,51 @@ module XMLRPC
@writer.tag("double", param.to_s)
when Struct
- h = param.members.collect do |key|
+ h = param.members.collect do |key|
value = param[key]
- @writer.ele("member",
+ @writer.ele("member",
@writer.tag("name", key.to_s),
- conv2value(value)
+ conv2value(value)
)
end
- @writer.ele("struct", *h)
+ @writer.ele("struct", *h)
when Hash
# TODO: can a Hash be empty?
-
+
h = param.collect do |key, value|
- @writer.ele("member",
+ @writer.ele("member",
@writer.tag("name", key.to_s),
- conv2value(value)
+ conv2value(value)
)
end
- @writer.ele("struct", *h)
+ @writer.ele("struct", *h)
when Array
# TODO: can an Array be empty?
a = param.collect {|v| conv2value(v) }
-
- @writer.ele("array",
+
+ @writer.ele("array",
@writer.ele("data", *a)
)
when Time, Date, ::DateTime
- @writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S"))
+ @writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S"))
when XMLRPC::DateTime
- @writer.tag("dateTime.iso8601",
+ @writer.tag("dateTime.iso8601",
format("%.4d%02d%02dT%02d:%02d:%02d", *param.to_a))
-
+
when XMLRPC::Base64
- @writer.tag("base64", param.encoded)
+ @writer.tag("base64", param.encoded)
- else
+ else
if Config::ENABLE_MARSHALLING and param.class.included_modules.include? XMLRPC::Marshallable
# convert Ruby object into Hash
ret = {"___class___" => param.class.name}
- param.instance_variables.each {|v|
+ param.instance_variables.each {|v|
name = v[1..-1]
val = param.instance_variable_get(v)
@@ -266,16 +266,16 @@ module XMLRPC
end
}
return conv2value(ret)
- else
+ else
ok, pa = wrong_type(param)
if ok
return conv2value(pa)
- else
+ else
raise "Wrong type!"
end
end
end
-
+
@writer.ele("value", val)
end
@@ -283,7 +283,7 @@ module XMLRPC
false
end
-
+
end # class Create
end # module XMLRPC
diff --git a/lib/xmlrpc/datetime.rb b/lib/xmlrpc/datetime.rb
index 298263fe8a..a1acad33b9 100644
--- a/lib/xmlrpc/datetime.rb
+++ b/lib/xmlrpc/datetime.rb
@@ -10,19 +10,19 @@ Released under the same term of license as Ruby.
= XMLRPC::DateTime
== Description
This class is important to handle XMLRPC (('dateTime.iso8601')) values,
-correcly, because normal UNIX-dates (class (({Date}))) only handle dates
+correcly, because normal UNIX-dates (class (({Date}))) only handle dates
from year 1970 on, and class (({Time})) handles dates without the time
-component. (({XMLRPC::DateTime})) is able to store a XMLRPC
+component. (({XMLRPC::DateTime})) is able to store a XMLRPC
(('dateTime.iso8601')) value correctly.
== Class Methods
--- XMLRPC::DateTime.new( year, month, day, hour, min, sec )
Creates a new (({XMLRPC::DateTime})) instance with the
- parameters ((|year|)), ((|month|)), ((|day|)) as date and
+ parameters ((|year|)), ((|month|)), ((|day|)) as date and
((|hour|)), ((|min|)), ((|sec|)) as time.
Raises (({ArgumentError})) if a parameter is out of range, or ((|year|)) is not
of type (({Integer})).
-
+
== Instance Methods
--- XMLRPC::DateTime#year
--- XMLRPC::DateTime#month
@@ -50,7 +50,7 @@ component. (({XMLRPC::DateTime})) is able to store a XMLRPC
--- XMLRPC::DateTime#to_time
Return a (({Time})) object of the date/time which (({self})) represents.
- If the (('year')) is below 1970, this method returns (({nil})),
+ If the (('year')) is below 1970, this method returns (({nil})),
because (({Time})) cannot handle years below 1970.
The used timezone is GMT.
@@ -68,7 +68,7 @@ require "date"
module XMLRPC
class DateTime
-
+
attr_reader :year, :month, :day, :hour, :min, :sec
def year= (value)
@@ -102,14 +102,14 @@ class DateTime
end
alias mon month
- alias mon= month=
-
+ alias mon= month=
+
def initialize(year, month, day, hour, min, sec)
self.year, self.month, self.day = year, month, day
self.hour, self.min, self.sec = hour, min, sec
end
-
+
def to_time
if @year >= 1970
Time.gm(*to_a)
diff --git a/lib/xmlrpc/httpserver.rb b/lib/xmlrpc/httpserver.rb
index 9afb5fd5ec..6fc1554462 100644
--- a/lib/xmlrpc/httpserver.rb
+++ b/lib/xmlrpc/httpserver.rb
@@ -1,7 +1,7 @@
#
-# Implements a simple HTTP-server by using John W. Small's ([email protected])
+# Implements a simple HTTP-server by using John W. Small's ([email protected])
# ruby-generic-server.
-#
+#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann ([email protected])
#
# $Id$
@@ -14,8 +14,8 @@ class HttpServer < GServer
##
# handle_obj specifies the object, that receives calls to request_handler
- # and ip_auth_handler
- def initialize(handle_obj, port = 8080, host = DEFAULT_HOST, maxConnections = 4,
+ # and ip_auth_handler
+ def initialize(handle_obj, port = 8080, host = DEFAULT_HOST, maxConnections = 4,
stdlog = $stdout, audit = true, debug = true)
@handler = handle_obj
super(port, host, maxConnections, stdlog, audit, debug)
@@ -24,7 +24,7 @@ class HttpServer < GServer
private
# Constants -----------------------------------------------
-
+
CRLF = "\r\n"
HTTP_PROTO = "HTTP/1.0"
SERVER_NAME = "HttpServer (Ruby #{RUBY_VERSION})"
@@ -46,27 +46,27 @@ private
}
# Classes -------------------------------------------------
-
+
class Request
attr_reader :data, :header, :method, :path, :proto
-
+
def initialize(data, method=nil, path=nil, proto=nil)
@header, @data = Table.new, data
@method, @path, @proto = method, path, proto
end
-
+
def content_length
len = @header['Content-Length']
return nil if len.nil?
- return len.to_i
+ return len.to_i
end
-
+
end
-
+
class Response
attr_reader :header
attr_accessor :body, :status, :status_message
-
+
def initialize(status=200)
@status = status
@status_message = nil
@@ -82,7 +82,7 @@ private
include Enumerable
def initialize(hash={})
- @hash = hash
+ @hash = hash
update(hash)
end
@@ -113,7 +113,7 @@ private
def http_header(header=nil)
new_header = Table.new(DEFAULT_HEADER)
- new_header.update(header) unless header.nil?
+ new_header.update(header) unless header.nil?
new_header["Connection"] = "close"
new_header["Date"] = http_date(Time.now)
@@ -127,7 +127,7 @@ private
def http_resp(status_code, status_message=nil, header=nil, body=nil)
status_message ||= StatusCodeMapping[status_code]
-
+
str = ""
str << "#{HTTP_PROTO} #{status_code} #{status_message}" << CRLF
http_header(header).writeTo(str)
@@ -137,8 +137,8 @@ private
end
# Main Serve Loop -----------------------------------------
-
- def serve(io)
+
+ def serve(io)
# perform IP authentification
unless @handler.ip_auth_handler(io)
io << http_resp(403, "Forbidden")
@@ -149,10 +149,10 @@ private
if io.gets =~ /^(\S+)\s+(\S+)\s+(\S+)/
request = Request.new(io, $1, $2, $3)
else
- io << http_resp(400, "Bad Request")
+ io << http_resp(400, "Bad Request")
return
end
-
+
# parse HTTP headers
while (line=io.gets) !~ /^(\n|\r)/
if line =~ /^([\w-]+):\s*(.*)$/
@@ -160,15 +160,15 @@ private
end
end
- io.binmode
+ io.binmode
response = Response.new
# execute request handler
@handler.request_handler(request, response)
-
+
# write response back to the client
io << http_resp(response.status, response.status_message,
- response.header, response.body)
+ response.header, response.body)
rescue Exception => e
io << http_resp(500, "Internal Server Error")
diff --git a/lib/xmlrpc/marshal.rb b/lib/xmlrpc/marshal.rb
index 26510124c2..d121828312 100644
--- a/lib/xmlrpc/marshal.rb
+++ b/lib/xmlrpc/marshal.rb
@@ -1,6 +1,6 @@
#
# Marshalling of XML-RPC methodCall and methodResponse
-#
+#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann ([email protected])
#
# $Id$
@@ -17,7 +17,7 @@ module XMLRPC
include ParserWriterChooseMixin
# class methods -------------------------------
-
+
class << self
def dump_call( methodName, *params )
@@ -52,7 +52,7 @@ module XMLRPC
create.methodCall( methodName, *params )
end
- def dump_response( param )
+ def dump_response( param )
create.methodResponse( ! param.kind_of?( XMLRPC::FaultException ) , param )
end
diff --git a/lib/xmlrpc/parser.rb b/lib/xmlrpc/parser.rb
index 6d10fde9d9..9d1a7a73e4 100644
--- a/lib/xmlrpc/parser.rb
+++ b/lib/xmlrpc/parser.rb
@@ -1,6 +1,6 @@
#
# Parser for XML-RPC call and response
-#
+#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann ([email protected])
#
# $Id$
@@ -60,7 +60,7 @@ module XMLRPC
@faultCode = faultCode
@faultString = faultString
end
-
+
# returns a hash
def to_h
{"faultCode" => @faultCode, "faultString" => @faultString}
@@ -77,7 +77,7 @@ module XMLRPC
when "0" then false
when "1" then true
else
- raise "RPC-value of type boolean is wrong"
+ raise "RPC-value of type boolean is wrong"
end
end
@@ -122,7 +122,7 @@ module XMLRPC
def self.struct(hash)
# convert to marhalled object
klass = hash["___class___"]
- if klass.nil? or Config::ENABLE_MARSHALLING == false
+ if klass.nil? or Config::ENABLE_MARSHALLING == false
hash
else
begin
@@ -130,9 +130,9 @@ module XMLRPC
klass.split("::").each {|const| mod = mod.const_get(const.strip)}
obj = mod.allocate
-
+
hash.delete "___class___"
- hash.each {|key, value|
+ hash.each {|key, value|
obj.instance_variable_set("@#{ key }", value) if key =~ /^([\w_][\w_0-9]*)$/
}
obj
@@ -143,11 +143,11 @@ module XMLRPC
end
def self.fault(hash)
- if hash.kind_of? Hash and hash.size == 2 and
- hash.has_key? "faultCode" and hash.has_key? "faultString" and
+ if hash.kind_of? Hash and hash.size == 2 and
+ hash.has_key? "faultCode" and hash.has_key? "faultString" and
hash["faultCode"].kind_of? Integer and hash["faultString"].kind_of? String
- XMLRPC::FaultException.new(hash["faultCode"], hash["faultString"])
+ XMLRPC::FaultException.new(hash["faultCode"], hash["faultString"])
else
raise "wrong fault-structure: #{hash.inspect}"
end
@@ -182,9 +182,9 @@ module XMLRPC
# TODO: add nil?
unless %w(i4 int boolean string double dateTime.iso8601 base64).include? node.nodeName
- if node.nodeName == "value"
+ if node.nodeName == "value"
if not node.childNodes.to_a.detect {|n| _nodeType(n) == :ELEMENT}.nil?
- remove << nd if nd.nodeValue.strip == ""
+ remove << nd if nd.nodeValue.strip == ""
end
else
remove << nd if nd.nodeValue.strip == ""
@@ -194,7 +194,7 @@ module XMLRPC
remove << nd
else
removeWhitespacesAndComments(nd)
- end
+ end
end
remove.each { |i| node.removeChild(i) }
@@ -203,13 +203,13 @@ module XMLRPC
def nodeMustBe(node, name)
cmp = case name
- when Array
+ when Array
name.include?(node.nodeName)
when String
name == node.nodeName
else
raise "error"
- end
+ end
if not cmp then
raise "wrong xml-rpc (name)"
@@ -233,7 +233,7 @@ module XMLRPC
def assert(b)
if not b then
- raise "assert-fail"
+ raise "assert-fail"
end
end
@@ -249,21 +249,21 @@ module XMLRPC
raise "wrong xml-rpc (size)"
end
end
-
+
def integer(node)
#TODO: check string for float because to_i returnsa
# 0 when wrong string
- nodeMustBe(node, %w(i4 int))
+ nodeMustBe(node, %w(i4 int))
hasOnlyOneChild(node)
-
+
Convert.int(text(node.firstChild))
end
def boolean(node)
- nodeMustBe(node, "boolean")
+ nodeMustBe(node, "boolean")
hasOnlyOneChild(node)
-
+
Convert.boolean(text(node.firstChild))
end
@@ -274,36 +274,36 @@ module XMLRPC
end
def string(node)
- nodeMustBe(node, "string")
+ nodeMustBe(node, "string")
text_zero_one(node)
end
def double(node)
#TODO: check string for float because to_f returnsa
# 0.0 when wrong string
- nodeMustBe(node, "double")
+ nodeMustBe(node, "double")
hasOnlyOneChild(node)
-
+
Convert.double(text(node.firstChild))
end
def dateTime(node)
nodeMustBe(node, "dateTime.iso8601")
hasOnlyOneChild(node)
-
+
Convert.dateTime( text(node.firstChild) )
end
def base64(node)
nodeMustBe(node, "base64")
#hasOnlyOneChild(node)
-
+
Convert.base64(text_zero_one(node))
end
def member(node)
nodeMustBe(node, "member")
- assert( node.childNodes.to_a.size == 2 )
+ assert( node.childNodes.to_a.size == 2 )
[ name(node[0]), value(node[1]) ]
end
@@ -311,13 +311,13 @@ module XMLRPC
def name(node)
nodeMustBe(node, "name")
#hasOnlyOneChild(node)
- text_zero_one(node)
+ text_zero_one(node)
end
def array(node)
nodeMustBe(node, "array")
- hasOnlyOneChild(node, "data")
- data(node.firstChild)
+ hasOnlyOneChild(node, "data")
+ data(node.firstChild)
end
def data(node)
@@ -325,15 +325,15 @@ module XMLRPC
node.childNodes.to_a.collect do |val|
value(val)
- end
+ end
end
def param(node)
nodeMustBe(node, "param")
hasOnlyOneChild(node, "value")
- value(node.firstChild)
+ value(node.firstChild)
end
-
+
def methodResponse(node)
nodeMustBe(node, "methodResponse")
hasOnlyOneChild(node, %w(params fault))
@@ -341,7 +341,7 @@ module XMLRPC
case child.nodeName
when "params"
- [ true, params(child,false) ]
+ [ true, params(child,false) ]
when "fault"
[ false, fault(child) ]
else
@@ -353,13 +353,13 @@ module XMLRPC
def methodName(node)
nodeMustBe(node, "methodName")
hasOnlyOneChild(node)
- text(node.firstChild)
+ text(node.firstChild)
end
def params(node, call=true)
nodeMustBe(node, "params")
- if call
+ if call
node.childNodes.to_a.collect do |n|
param(n)
end
@@ -372,7 +372,7 @@ module XMLRPC
def fault(node)
nodeMustBe(node, "fault")
hasOnlyOneChild(node, "value")
- f = value(node.firstChild)
+ f = value(node.firstChild)
Convert.fault(f)
end
@@ -388,13 +388,13 @@ module XMLRPC
end
def struct(node)
- nodeMustBe(node, "struct")
+ nodeMustBe(node, "struct")
hash = {}
node.childNodes.to_a.each do |me|
- n, v = member(me)
+ n, v = member(me)
hash[n] = v
- end
+ end
Convert.struct(hash)
end
@@ -403,9 +403,9 @@ module XMLRPC
def value(node)
nodeMustBe(node, "value")
nodes = node.childNodes.to_a.size
- if nodes == 0
+ if nodes == 0
return ""
- elsif nodes > 1
+ elsif nodes > 1
raise "wrong xml-rpc (size)"
end
@@ -423,14 +423,14 @@ module XMLRPC
when "dateTime.iso8601" then dateTime(child)
when "base64" then base64(child)
when "struct" then struct(child)
- when "array" then array(child)
- when "nil"
+ when "array" then array(child)
+ when "nil"
if Config::ENABLE_NIL_PARSER
v_nil(child)
else
raise "wrong/unknown XML-RPC type 'nil'"
end
- else
+ else
raise "wrong/unknown XML-RPC type"
end
else
@@ -441,7 +441,7 @@ module XMLRPC
def methodCall(node)
nodeMustBe(node, "methodCall")
- assert( (1..2).include?( node.childNodes.to_a.size ) )
+ assert( (1..2).include?( node.childNodes.to_a.size ) )
name = methodName(node[0])
if node.childNodes.to_a.size == 2 then
@@ -461,7 +461,7 @@ module XMLRPC
raise "No valid method response!" if parser.method_name != nil
if parser.fault != nil
# is a fault structure
- [false, parser.fault]
+ [false, parser.fault]
else
# is a normal return value
raise "Missing return value!" if parser.params.size == 0
@@ -508,7 +508,7 @@ module XMLRPC
@value = nil
when "nil"
raise "wrong/unknown XML-RPC type 'nil'" unless Config::ENABLE_NIL_PARSER
- @value = :nil
+ @value = :nil
when "array"
@val_stack << @values
@values = []
@@ -517,7 +517,7 @@ module XMLRPC
@name = []
@structs << @struct
- @struct = {}
+ @struct = {}
end
end
@@ -538,7 +538,7 @@ module XMLRPC
@value = Convert.base64(@data)
when "value"
@value = @data if @value.nil?
- @values << (@value == :nil ? nil : @value)
+ @values << (@value == :nil ? nil : @value)
when "array"
@value = @values
@values = @val_stack.pop
@@ -548,9 +548,9 @@ module XMLRPC
@name = @names.pop
@struct = @structs.pop
when "name"
- @name[0] = @data
+ @name[0] = @data
when "member"
- @struct[@name[0]] = @values.pop
+ @struct[@name[0]] = @values.pop
when "param"
@params << @values[0]
@@ -560,7 +560,7 @@ module XMLRPC
@fault = Convert.fault(@values[0])
when "methodName"
- @method_name = @data
+ @method_name = @data
end
@data = nil
@@ -592,7 +592,7 @@ module XMLRPC
@parser_class = XMLRPCParser
end
- class XMLRPCParser
+ class XMLRPCParser
include StreamParserMixin
def parse(str)
@@ -620,9 +620,9 @@ module XMLRPC
def initialize
require "xmltreebuilder"
- # The new XMLParser library (0.6.2+) uses a slightly different DOM implementation.
+ # The new XMLParser library (0.6.2+) uses a slightly different DOM implementation.
# The following code removes the differences between both versions.
- if defined? XML::DOM::Builder
+ if defined? XML::DOM::Builder
return if defined? XML::DOM::Node::DOCUMENT # code below has been already executed
klass = XML::DOM::Node
klass.const_set("DOCUMENT", klass::DOCUMENT_NODE)
@@ -637,8 +637,8 @@ module XMLRPC
def _nodeType(node)
tp = node.nodeType
if tp == XML::SimpleTree::Node::TEXT then :TEXT
- elsif tp == XML::SimpleTree::Node::COMMENT then :COMMENT
- elsif tp == XML::SimpleTree::Node::ELEMENT then :ELEMENT
+ elsif tp == XML::SimpleTree::Node::COMMENT then :COMMENT
+ elsif tp == XML::SimpleTree::Node::ELEMENT then :ELEMENT
else :ELSE
end
end
@@ -647,14 +647,14 @@ module XMLRPC
def methodResponse_document(node)
assert( node.nodeType == XML::SimpleTree::Node::DOCUMENT )
hasOnlyOneChild(node, "methodResponse")
-
+
methodResponse(node.firstChild)
end
def methodCall_document(node)
assert( node.nodeType == XML::SimpleTree::Node::DOCUMENT )
hasOnlyOneChild(node, "methodCall")
-
+
methodCall(node.firstChild)
end
@@ -688,7 +688,7 @@ module XMLRPC
end
def createCleanedTree(str)
- doc = ::NQXML::TreeParser.new(str).document.rootNode
+ doc = ::NQXML::TreeParser.new(str).document.rootNode
removeWhitespacesAndComments(doc)
doc
end
@@ -701,7 +701,7 @@ module XMLRPC
@parser_class = StreamListener
end
- class StreamListener
+ class StreamListener
include StreamParserMixin
alias :tag_start :startElement
@@ -716,7 +716,7 @@ module XMLRPC
def parse(str)
parser = REXML::Document.parse_stream(str, self)
end
- end
+ end
end
# ---------------------------------------------------------------------------
@@ -751,7 +751,7 @@ module XMLRPC
startElement(name)
endElement(name)
end
-
+
def on_chardata(str)
character(str)
end
@@ -784,7 +784,7 @@ module XMLRPC
# valid_name?
# valid_chardata?
# valid_char?
- # parse_error
+ # parse_error
end
end
@@ -792,8 +792,8 @@ module XMLRPC
XMLParser = XMLTreeParser
NQXMLParser = NQXMLTreeParser
- Classes = [XMLStreamParser, XMLTreeParser,
- NQXMLStreamParser, NQXMLTreeParser,
+ Classes = [XMLStreamParser, XMLTreeParser,
+ NQXMLStreamParser, NQXMLTreeParser,
REXMLStreamParser, XMLScanStreamParser]
# yields an instance of each installed parser
diff --git a/lib/xmlrpc/server.rb b/lib/xmlrpc/server.rb
index 9234aeec15..c070a281db 100644
--- a/lib/xmlrpc/server.rb
+++ b/lib/xmlrpc/server.rb
@@ -14,23 +14,23 @@ Released under the same term of license as Ruby.
= XMLRPC::BasicServer
== Description
Is the base class for all XML-RPC server-types (CGI, standalone).
-You can add handler and set a default handler.
+You can add handler and set a default handler.
Do not use this server, as this is/should be an abstract class.
=== How the method to call is found
-The arity (number of accepted arguments) of a handler (method or (({Proc})) object) is
-compared to the given arguments submitted by the client for a RPC ((-Remote Procedure Call-)).
-A handler is only called if it accepts the number of arguments, otherwise the search
-for another handler will go on. When at the end no handler was found,
+The arity (number of accepted arguments) of a handler (method or (({Proc})) object) is
+compared to the given arguments submitted by the client for a RPC ((-Remote Procedure Call-)).
+A handler is only called if it accepts the number of arguments, otherwise the search
+for another handler will go on. When at the end no handler was found,
the ((<default_handler|XMLRPC::BasicServer#set_default_handler>)) will be called.
With this technique it is possible to do overloading by number of parameters, but
only for (({Proc})) handler, because you cannot define two methods of the same name in
-the same class.
+the same class.
== Class Methods
--- XMLRPC::BasicServer.new( class_delim="." )
- Creates a new (({XMLRPC::BasicServer})) instance, which should not be
+ Creates a new (({XMLRPC::BasicServer})) instance, which should not be
done, because (({XMLRPC::BasicServer})) is an abstract class. This
method should be called from a subclass indirectly by a (({super})) call
in the method (({initialize})). The paramter ((|class_delim|)) is used
@@ -40,24 +40,24 @@ the same class.
== Instance Methods
--- XMLRPC::BasicServer#add_handler( name, signature=nil, help=nil ) { aBlock }
Adds ((|aBlock|)) to the list of handlers, with ((|name|)) as the name of the method.
- Parameters ((|signature|)) and ((|help|)) are used by the Introspection method if specified,
- where ((|signature|)) is either an Array containing strings each representing a type of it's
- signature (the first is the return value) or an Array of Arrays if the method has multiple
+ Parameters ((|signature|)) and ((|help|)) are used by the Introspection method if specified,
+ where ((|signature|)) is either an Array containing strings each representing a type of it's
+ signature (the first is the return value) or an Array of Arrays if the method has multiple
signatures. Value type-names are "int, boolean, double, string, dateTime.iso8601, base64, array, struct".
Parameter ((|help|)) is a String with informations about how to call this method etc.
A handler method or code-block can return the types listed at
- ((<XMLRPC::Client#call|URL:client.html#index:0>)).
- When a method fails, it can tell it the client by throwing an
+ ((<XMLRPC::Client#call|URL:client.html#index:0>)).
+ When a method fails, it can tell it the client by throwing an
(({XMLRPC::FaultException})) like in this example:
s.add_handler("michael.div") do |a,b|
if b == 0
raise XMLRPC::FaultException.new(1, "division by zero")
else
- a / b
+ a / b
end
- end
+ end
The client gets in the case of (({b==0})) an object back of type
(({XMLRPC::FaultException})) that has a ((|faultCode|)) and ((|faultString|))
field.
@@ -67,10 +67,10 @@ the same class.
To add an object write:
server.add_handler("michael", MyHandlerClass.new)
All public methods of (({MyHandlerClass})) are accessible to
- the XML-RPC clients by (('michael."name of method"')). This is
- where the ((|class_delim|)) in ((<new|XMLRPC::BasicServer.new>))
- has it's role, a XML-RPC method-name is defined by
- ((|prefix|)) + ((|class_delim|)) + (('"name of method"')).
+ the XML-RPC clients by (('michael."name of method"')). This is
+ where the ((|class_delim|)) in ((<new|XMLRPC::BasicServer.new>))
+ has it's role, a XML-RPC method-name is defined by
+ ((|prefix|)) + ((|class_delim|)) + (('"name of method"')).
--- XMLRPC::BasicServer#add_handler( interface, obj )
This is the third form of ((<add_handler|XMLRPC::BasicServer#add_handler>)).
@@ -91,11 +91,11 @@ the same class.
It is a (({Proc})) object or (({nil})).
--- XMLRPC::BasicServer#set_default_handler ( &handler )
- Sets ((|handler|)) as the default-handler, which is called when
+ Sets ((|handler|)) as the default-handler, which is called when
no handler for a method-name is found. ((|handler|)) is a code-block.
The default-handler is called with the (XML-RPC) method-name as first argument, and
the other arguments are the parameters given by the client-call.
-
+
If no block is specified the default of (({XMLRPC::BasicServer})) is used, which raises a
XMLRPC::FaultException saying "method missing".
@@ -103,7 +103,7 @@ the same class.
--- XMLRPC::BasicServer#set_writer( writer )
Sets the XML writer to use for generating XML output.
Should be an instance of a class from module (({XMLRPC::XMLWriter})).
- If this method is not called, then (({XMLRPC::Config::DEFAULT_WRITER})) is used.
+ If this method is not called, then (({XMLRPC::Config::DEFAULT_WRITER})) is used.
--- XMLRPC::BasicServer#set_parser( parser )
Sets the XML parser to use for parsing XML documents.
@@ -111,7 +111,7 @@ the same class.
If this method is not called, then (({XMLRPC::Config::DEFAULT_PARSER})) is used.
--- XMLRPC::BasicServer#add_introspection
- Adds the introspection handlers "system.listMethods", "system.methodSignature" and "system.methodHelp",
+ Adds the introspection handlers "system.listMethods", "system.methodSignature" and "system.methodHelp",
where only the first one works.
--- XMLRPC::BasicServer#add_multicall
@@ -123,7 +123,7 @@ the same class.
--- XMLRPC::BasicServer#set_service_hook ( &handler )
A service-hook is called for each service request (RPC).
You can use a service-hook for example to wrap existing methods and catch exceptions of them or
- convert values to values recognized by XMLRPC. You can disable it by passing (({nil})) as parameter
+ convert values to values recognized by XMLRPC. You can disable it by passing (({nil})) as parameter
((|handler|)) .
The service-hook is called with a (({Proc})) object and with the parameters for this (({Proc})).
@@ -157,7 +157,7 @@ class BasicServer
include ParserWriterChooseMixin
include ParseContentType
- ERR_METHOD_MISSING = 1
+ ERR_METHOD_MISSING = 1
ERR_UNCAUGHT_EXCEPTION = 2
ERR_MC_WRONG_PARAM = 3
ERR_MC_MISSING_PARAMS = 4
@@ -169,7 +169,7 @@ class BasicServer
def initialize(class_delim=".")
@handler = []
- @default_handler = nil
+ @default_handler = nil
@service_hook = nil
@class_delim = class_delim
@@ -183,7 +183,7 @@ class BasicServer
def add_handler(prefix, obj_or_signature=nil, help=nil, &block)
if block_given?
# proc-handler
- @handler << [prefix, block, obj_or_signature, help]
+ @handler << [prefix, block, obj_or_signature, help]
else
if prefix.kind_of? String
# class-handler
@@ -208,7 +208,7 @@ class BasicServer
@service_hook = handler
self
end
-
+
def get_default_handler
@default_handler
end
@@ -216,18 +216,18 @@ class BasicServer
def set_default_handler (&handler)
@default_handler = handler
self
- end
+ end
def add_multicall
add_handler("system.multicall", %w(array array), "Multicall Extension") do |arrStructs|
- unless arrStructs.is_a? Array
+ unless arrStructs.is_a? Array
raise XMLRPC::FaultException.new(ERR_MC_WRONG_PARAM, "system.multicall expects an array")
end
arrStructs.collect {|call|
if call.is_a? Hash
methodName = call["methodName"]
- params = call["params"]
+ params = call["params"]
if params.nil?
multicall_fault(ERR_MC_MISSING_PARAMS, "Missing params")
@@ -246,16 +246,16 @@ class BasicServer
[val]
else
# exception
- multicall_fault(val.faultCode, val.faultString)
+ multicall_fault(val.faultCode, val.faultString)
end
end
end
- end
-
+ end
+
else
multicall_fault(ERR_MC_EXPECTED_STRUCT, "system.multicall expected struct")
end
- }
+ }
end # end add_handler
self
end
@@ -284,7 +284,7 @@ class BasicServer
sig.each {|s| sigs << s}
else
# sig is a single signature, e.g. ["array"]
- sigs << sig
+ sigs << sig
end
end
end
@@ -292,11 +292,11 @@ class BasicServer
end
add_handler("system.methodHelp", %w(string string), "Returns help on using this method") do |meth|
- help = nil
+ help = nil
@handler.each do |name, obj, sig, hlp|
- if obj.kind_of? Proc and name == meth
+ if obj.kind_of? Proc and name == meth
help = hlp
- break
+ break
end
end
help || ""
@@ -306,18 +306,18 @@ class BasicServer
end
-
+
def process(data)
- method, params = parser().parseMethodCall(data)
+ method, params = parser().parseMethodCall(data)
handle(method, *params)
end
-
+
private # --------------------------------------------------------------
def multicall_fault(nr, str)
{"faultCode" => nr, "faultString" => str}
end
-
+
#
# method dispatch
#
@@ -333,17 +333,17 @@ class BasicServer
if check_arity(obj, args.size)
if @service_hook.nil?
- return obj.call(*args)
+ return obj.call(*args)
else
return @service_hook.call(obj, *args)
end
end
- end
-
+ end
+
if @default_handler.nil?
raise XMLRPC::FaultException.new(ERR_METHOD_MISSING, "Method #{methodname} missing or wrong number of parameters!")
else
- @default_handler.call(methodname, *args)
+ @default_handler.call(methodname, *args)
end
end
@@ -357,7 +357,7 @@ class BasicServer
if ary >= 0
n_args == ary
else
- n_args >= (ary+1).abs
+ n_args >= (ary+1).abs
end
end
@@ -366,8 +366,8 @@ class BasicServer
def call_method(methodname, *args)
begin
[true, dispatch(methodname, *args)]
- rescue XMLRPC::FaultException => e
- [false, e]
+ rescue XMLRPC::FaultException => e
+ [false, e]
rescue Exception => e
[false, XMLRPC::FaultException.new(ERR_UNCAUGHT_EXCEPTION, "Uncaught exception #{e.message} in method #{methodname}")]
end
@@ -388,8 +388,8 @@ end
= XMLRPC::CGIServer
== Synopsis
require "xmlrpc/server"
-
- s = XMLRPC::CGIServer.new
+
+ s = XMLRPC::CGIServer.new
s.add_handler("michael.add") do |a,b|
a + b
@@ -399,15 +399,15 @@ end
if b == 0
raise XMLRPC::FaultException.new(1, "division by zero")
else
- a / b
+ a / b
end
- end
+ end
s.set_default_handler do |name, *args|
raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
" or wrong number of parameters!")
end
-
+
s.serve
== Description
@@ -419,7 +419,7 @@ Implements a CGI-based XML-RPC server.
== Class Methods
--- XMLRPC::CGIServer.new( *a )
Creates a new (({XMLRPC::CGIServer})) instance. All parameters given
- are by-passed to ((<XMLRPC::BasicServer.new>)). You can only create
+ are by-passed to ((<XMLRPC::BasicServer.new>)). You can only create
((*one*)) (({XMLRPC::CGIServer})) instance, because more than one makes
no sense.
@@ -427,7 +427,7 @@ Implements a CGI-based XML-RPC server.
--- XMLRPC::CGIServer#serve
Call this after you have added all you handlers to the server.
This method processes a XML-RPC methodCall and sends the answer
- back to the client.
+ back to the client.
Make sure that you don't write to standard-output in a handler, or in
any other part of your program, this would case a CGI-based server to fail!
=end
@@ -443,14 +443,14 @@ class CGIServer < BasicServer
def initialize(*a)
super(*a)
end
-
+
def serve
catch(:exit_serve) {
length = ENV['CONTENT_LENGTH'].to_i
- http_error(405, "Method Not Allowed") unless ENV['REQUEST_METHOD'] == "POST"
+ http_error(405, "Method Not Allowed") unless ENV['REQUEST_METHOD'] == "POST"
http_error(400, "Bad Request") unless parse_content_type(ENV['CONTENT_TYPE']).first == "text/xml"
- http_error(411, "Length Required") unless length > 0
+ http_error(411, "Length Required") unless length > 0
# TODO: do we need a call to binmode?
$stdin.binmode if $stdin.respond_to? :binmode
@@ -467,7 +467,7 @@ class CGIServer < BasicServer
def http_error(status, message)
err = "#{status} #{message}"
- msg = <<-"MSGEND"
+ msg = <<-"MSGEND"
<html>
<head>
<title>#{err}</title>
@@ -487,7 +487,7 @@ class CGIServer < BasicServer
h = {}
header.each {|key, value| h[key.to_s.capitalize] = value}
h['Status'] ||= "200 OK"
- h['Content-length'] ||= body.size.to_s
+ h['Content-length'] ||= body.size.to_s
str = ""
h.each {|key, value| str << "#{key}: #{value}\r\n"}
@@ -507,7 +507,7 @@ Use it in the same way as CGIServer!
== Superclass
((<XMLRPC::BasicServer>))
-=end
+=end
class ModRubyServer < BasicServer
@@ -523,9 +523,9 @@ class ModRubyServer < BasicServer
length = header['Content-length'].to_i
- http_error(405, "Method Not Allowed") unless @ap.request_method == "POST"
+ http_error(405, "Method Not Allowed") unless @ap.request_method == "POST"
http_error(400, "Bad Request") unless parse_content_type(header['Content-type']).first == "text/xml"
- http_error(411, "Length Required") unless length > 0
+ http_error(411, "Length Required") unless length > 0
# TODO: do we need a call to binmode?
@ap.binmode
@@ -542,7 +542,7 @@ class ModRubyServer < BasicServer
def http_error(status, message)
err = "#{status} #{message}"
- msg = <<-"MSGEND"
+ msg = <<-"MSGEND"
<html>
<head>
<title>#{err}</title>
@@ -562,12 +562,12 @@ class ModRubyServer < BasicServer
h = {}
header.each {|key, value| h[key.to_s.capitalize] = value}
h['Status'] ||= "200 OK"
- h['Content-length'] ||= body.size.to_s
+ h['Content-length'] ||= body.size.to_s
h.each {|key, value| @ap.headers_out[key] = value }
- @ap.content_type = h["Content-type"]
- @ap.status = status.to_i
- @ap.send_http_header
+ @ap.content_type = h["Content-type"]
+ @ap.status = status.to_i
+ @ap.send_http_header
@ap.print body
end
@@ -578,8 +578,8 @@ end
= XMLRPC::Server
== Synopsis
require "xmlrpc/server"
-
- s = XMLRPC::Server.new(8080)
+
+ s = XMLRPC::Server.new(8080)
s.add_handler("michael.add") do |a,b|
a + b
@@ -589,15 +589,15 @@ end
if b == 0
raise XMLRPC::FaultException.new(1, "division by zero")
else
- a / b
+ a / b
end
- end
+ end
s.set_default_handler do |name, *args|
raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
" or wrong number of parameters!")
end
-
+
s.serve
== Description
@@ -610,13 +610,13 @@ program.
== Class Methods
--- XMLRPC::Server.new( port=8080, host="127.0.0.1", maxConnections=4, stdlog=$stdout, audit=true, debug=true, *a )
Creates a new (({XMLRPC::Server})) instance, which is a XML-RPC server listening on
- port ((|port|)) and accepts requests for the host ((|host|)), which is by default only the localhost.
+ port ((|port|)) and accepts requests for the host ((|host|)), which is by default only the localhost.
The server is not started, to start it you have to call ((<serve|XMLRPC::Server#serve>)).
Parameters ((|audit|)) and ((|debug|)) are obsolete!
- All additionally given parameters in ((|*a|)) are by-passed to ((<XMLRPC::BasicServer.new>)).
-
+ All additionally given parameters in ((|*a|)) are by-passed to ((<XMLRPC::BasicServer.new>)).
+
== Instance Methods
--- XMLRPC::Server#serve
Call this after you have added all you handlers to the server.
@@ -624,7 +624,7 @@ program.
--- XMLRPC::Server#shutdown
Stops and shuts the server down.
-
+
=end
class WEBrickServlet < BasicServer; end # forward declaration
@@ -634,11 +634,11 @@ class Server < WEBrickServlet
def initialize(port=8080, host="127.0.0.1", maxConnections=4, stdlog=$stdout, audit=true, debug=true, *a)
super(*a)
require 'webrick'
- @server = WEBrick::HTTPServer.new(:Port => port, :BindAddress => host, :MaxClients => maxConnections,
+ @server = WEBrick::HTTPServer.new(:Port => port, :BindAddress => host, :MaxClients => maxConnections,
:Logger => WEBrick::Log.new(stdlog))
@server.mount("/", self)
end
-
+
def serve
if RUBY_PLATFORM =~ /mingw|mswin32/
signals = [1]
@@ -649,11 +649,11 @@ class Server < WEBrickServlet
@server.start
end
-
+
def shutdown
@server.shutdown
end
-
+
end
=begin
@@ -672,16 +672,16 @@ end
if b == 0
raise XMLRPC::FaultException.new(1, "division by zero")
else
- a / b
+ a / b
end
- end
+ end
s.set_default_handler do |name, *args|
raise XMLRPC::FaultException.new(-99, "Method #{name} missing" +
" or wrong number of parameters!")
end
- httpserver = WEBrick::HTTPServer.new(:Port => 8080)
+ httpserver = WEBrick::HTTPServer.new(:Port => 8080)
httpserver.mount("/RPC2", s)
trap("HUP") { httpserver.shutdown } # use 1 instead of "HUP" on Windows
httpserver.start
@@ -695,7 +695,7 @@ end
--- XMLRPC::WEBrickServlet#get_valid_ip
Return the via method ((<set_valid_ip|XMLRPC::Server#set_valid_ip>)) specified
valid IP addresses.
-
+
== Description
Implements a servlet for use with WEBrick, a pure Ruby (HTTP-) server framework.
@@ -711,10 +711,10 @@ class WEBrickServlet < BasicServer
@valid_ip = nil
end
- # deprecated from WEBrick/1.2.2.
+ # deprecated from WEBrick/1.2.2.
# but does not break anything.
def require_path_info?
- false
+ false
end
def get_instance(config, *options)
@@ -736,7 +736,7 @@ class WEBrickServlet < BasicServer
def service(request, response)
- if @valid_ip
+ if @valid_ip
raise WEBrick::HTTPStatus::Forbidden unless @valid_ip.any? { |ip| request.peeraddr[3] =~ ip }
end
@@ -745,9 +745,9 @@ class WEBrickServlet < BasicServer
"unsupported method `#{request.request_method}'."
end
- if parse_content_type(request['Content-type']).first != "text/xml"
+ if parse_content_type(request['Content-type']).first != "text/xml"
raise WEBrick::HTTPStatus::BadRequest
- end
+ end
length = (request['Content-length'] || 0).to_i
@@ -760,14 +760,14 @@ class WEBrickServlet < BasicServer
end
resp = process(data)
- if resp.nil? or resp.size <= 0
+ if resp.nil? or resp.size <= 0
raise WEBrick::HTTPStatus::InternalServerError
end
response.status = 200
response['Content-Length'] = resp.size
response['Content-Type'] = "text/xml; charset=utf-8"
- response.body = resp
+ response.body = resp
end
end
@@ -777,6 +777,6 @@ end # module XMLRPC
=begin
= History
- $Id$
+ $Id$
=end
diff --git a/lib/xmlrpc/utils.rb b/lib/xmlrpc/utils.rb
index f0966fee40..85319a7e36 100644
--- a/lib/xmlrpc/utils.rb
+++ b/lib/xmlrpc/utils.rb
@@ -1,12 +1,12 @@
#
# Defines ParserWriterChooseMixin, which makes it possible to choose a
# different XML writer and/or XML parser then the default one.
-# The Mixin is used in client.rb (class Client) and server.rb (class
+# The Mixin is used in client.rb (class Client) and server.rb (class
# BasicServer)
-#
+#
# Copyright (C) 2001, 2002, 2003 by Michael Neumann ([email protected])
#
-# $Id$
+# $Id$
#
module XMLRPC
@@ -15,7 +15,7 @@ module XMLRPC
# This module enables a user-class to be marshalled
# by XML-RPC for Ruby into a Hash, with one additional
# key/value pair "___class___" => ClassName
- #
+ #
module Marshallable
end
@@ -72,9 +72,9 @@ module XMLRPC
mname = nil
sig = [sig] if sig.kind_of? String
- sig = sig.collect do |s|
+ sig = sig.collect do |s|
name, si = parse_sig(s)
- raise "Wrong signatures!" if mname != nil and name != mname
+ raise "Wrong signatures!" if mname != nil and name != mname
mname = name
si
end
@@ -83,12 +83,12 @@ module XMLRPC
end
private # ---------------------------------
-
+
def parse_sig(sig)
# sig is a String
if sig =~ /^\s*(\w+)\s+([^(]+)(\(([^)]*)\))?\s*$/
params = [$1]
- name = $2.strip
+ name = $2.strip
$4.split(",").each {|i| params << i.strip} if $4 != nil
return name, params
else
@@ -109,10 +109,10 @@ module XMLRPC
instance_eval(&p)
end
- def get_methods(obj, delim=".")
+ def get_methods(obj, delim=".")
prefix = @prefix + delim
- @methods.collect { |name, meth, sig, help|
- [prefix + name, obj.method(meth).to_proc, sig, help]
+ @methods.collect { |name, meth, sig, help|
+ [prefix + name, obj.method(meth).to_proc, sig, help]
}
end
@@ -132,7 +132,7 @@ module XMLRPC
def get_methods(obj, delim=".")
prefix = @prefix + delim
obj.class.public_instance_methods(false).collect { |name|
- [prefix + name, obj.method(name).to_proc, nil, nil]
+ [prefix + name, obj.method(name).to_proc, nil, nil]
}
end
end
@@ -141,16 +141,16 @@ module XMLRPC
end # module Service
- #
+ #
# short-form to create a Service::Interface
#
def self.interface(prefix, &p)
- Service::Interface.new(prefix, &p)
+ Service::Interface.new(prefix, &p)
end
# short-cut for creating a PublicInstanceMethodsInterface
def self.iPIMethods(prefix)
- Service::PublicInstanceMethodsInterface.new(prefix)
+ Service::PublicInstanceMethodsInterface.new(prefix)
end
diff --git a/lib/xsd/charset.rb b/lib/xsd/charset.rb
index 15d5500fce..09cdd28dc6 100644
--- a/lib/xsd/charset.rb
+++ b/lib/xsd/charset.rb
@@ -54,7 +54,7 @@ public
Proc.new { |str| NKF.nkf('-eXm0', str) }
rescue LoadError
end
-
+
begin
require 'uconv'
@internal_encoding = 'UTF8'
diff --git a/lib/xsd/codegen/classdef.rb b/lib/xsd/codegen/classdef.rb
index 9eb1ce6607..5f4839514c 100644
--- a/lib/xsd/codegen/classdef.rb
+++ b/lib/xsd/codegen/classdef.rb
@@ -43,7 +43,7 @@ class ClassDef < ModuleDef
def dump
buf = ""
unless @requirepath.empty?
- buf << dump_requirepath
+ buf << dump_requirepath
end
buf << dump_emptyline unless buf.empty?
package = @name.split(/::/)[0..-2]
diff --git a/lib/xsd/codegen/moduledef.rb b/lib/xsd/codegen/moduledef.rb
index 744af2ff97..19233acba9 100644
--- a/lib/xsd/codegen/moduledef.rb
+++ b/lib/xsd/codegen/moduledef.rb
@@ -64,7 +64,7 @@ class ModuleDef
def dump
buf = ""
unless @requirepath.empty?
- buf << dump_requirepath
+ buf << dump_requirepath
end
buf << dump_emptyline unless buf.empty?
package = @name.split(/::/)[0..-2]
diff --git a/lib/xsd/namedelements.rb b/lib/xsd/namedelements.rb
index a13396bb71..a0e60fa8ca 100644
--- a/lib/xsd/namedelements.rb
+++ b/lib/xsd/namedelements.rb
@@ -63,7 +63,7 @@ class NamedElements
@elements << rhs
self
end
-
+
def delete(rhs)
@elements.delete(rhs)
end
diff --git a/lib/xsd/qname.rb b/lib/xsd/qname.rb
index bb9763a69a..8b6bc8b626 100644
--- a/lib/xsd/qname.rb
+++ b/lib/xsd/qname.rb
@@ -55,7 +55,7 @@ class QName
def hash
@namespace.hash ^ @name.hash
end
-
+
def to_s
"{#{ namespace }}#{ name }"
end
diff --git a/lib/yaml.rb b/lib/yaml.rb
index a8da42a321..30e7b1a94e 100644
--- a/lib/yaml.rb
+++ b/lib/yaml.rb
@@ -4,7 +4,7 @@
# = yaml.rb: top-level module with methods for loading and parsing YAML documents
#
# Author:: why the lucky stiff
-#
+#
require 'stringio'
require 'yaml/error'
@@ -24,18 +24,18 @@ require 'yaml/constants'
# serialization format. Together with the Unicode standard for characters, it
# provides all the information necessary to understand YAML Version 1.0
# and construct computer programs to process it.
-#
+#
# See http://yaml.org/ for more information. For a quick tutorial, please
# visit YAML In Five Minutes (http://yaml.kwiki.org/?YamlInFiveMinutes).
-#
+#
# == About This Library
-#
+#
# The YAML 1.0 specification outlines four stages of YAML loading and dumping.
# This library honors all four of those stages, although data is really only
# available to you in three stages.
-#
+#
# The four stages are: native, representation, serialization, and presentation.
-#
+#
# The native stage refers to data which has been loaded completely into Ruby's
# own types. (See +YAML::load+.)
#
@@ -43,14 +43,14 @@ require 'yaml/constants'
# +YAML::BaseNode+ objects. In this stage, the document is available as a
# tree of node objects. You can perform YPath queries and transformations
# at this level. (See +YAML::parse+.)
-#
+#
# The serialization stage happens inside the parser. The YAML parser used in
# Ruby is called Syck. Serialized nodes are available in the extension as
# SyckNode structs.
-#
+#
# The presentation stage is the YAML document itself. This is accessible
# to you as a string. (See +YAML::dump+.)
-#
+#
# For more information about the various information models, see Chapter
# 3 of the YAML 1.0 Specification (http://yaml.org/spec/#id2491269).
#
@@ -102,7 +102,7 @@ module YAML
#
# Converts _obj_ to YAML and writes the YAML result to _io_.
- #
+ #
# File.open( 'animals.yaml', 'w' ) do |out|
# YAML.dump( ['badger', 'elephant', 'tiger'], out )
# end
@@ -168,8 +168,8 @@ module YAML
# Can also load from a string.
#
# YAML.parse( "--- :locked" )
- # #=> #<YAML::Syck::Node:0x82edddc
- # @type_id="tag:ruby.yaml.org,2002:sym",
+ # #=> #<YAML::Syck::Node:0x82edddc
+ # @type_id="tag:ruby.yaml.org,2002:sym",
# @value=":locked", @kind=:scalar>
#
def YAML.parse( io )
@@ -263,7 +263,7 @@ module YAML
end
#
- # Loads all documents from the current _io_ stream,
+ # Loads all documents from the current _io_ stream,
# returning a +YAML::Stream+ object containing all
# loaded documents.
#
@@ -271,7 +271,7 @@ module YAML
d = nil
parser.load_documents( io ) do |doc|
d = YAML::Stream.new if not d
- d.add( doc )
+ d.add( doc )
end
return d
end
@@ -288,7 +288,7 @@ module YAML
def YAML.dump_stream( *objs )
d = YAML::Stream.new
objs.each do |doc|
- d.add( doc )
+ d.add( doc )
end
d.emit
end
@@ -378,7 +378,7 @@ module YAML
# Allocate an Emitter if needed
#
def YAML.quick_emit( oid, opts = {}, &e )
- out =
+ out =
if opts.is_a? YAML::Emitter
opts
else
@@ -390,7 +390,7 @@ module YAML
end
out.emit( oid, &e )
end
-
+
end
require 'yaml/rubytypes'
@@ -422,7 +422,7 @@ module Kernel
#
# _produces:_
#
- # --- !ruby/struct:S
+ # --- !ruby/struct:S
# name: dave
# state: TX
#
diff --git a/lib/yaml/baseemitter.rb b/lib/yaml/baseemitter.rb
index a1992f498b..e06fae073a 100644
--- a/lib/yaml/baseemitter.rb
+++ b/lib/yaml/baseemitter.rb
@@ -44,7 +44,7 @@ module YAML
'|'
else
'>'
- end
+ end
indt = $&.to_i if block =~ /\d+/
if valx =~ /(\A\n*[ \t#]|^---\s+)/
@@ -67,8 +67,8 @@ module YAML
valx = fold( YAML::escape( valx, esc_skip ) + "\"" ).chomp
self << '"' + indent_text( valx, indt, false )
else
- if block[0] == ?>
- valx = fold( valx )
+ if block[0] == ?>
+ valx = fold( valx )
end
#p [block, indt]
self << block + indent_text( valx, indt )
@@ -87,7 +87,7 @@ module YAML
# Emit double-quoted string
#
def double( value )
- "\"#{YAML.escape( value )}\""
+ "\"#{YAML.escape( value )}\""
end
#
@@ -153,8 +153,8 @@ module YAML
@seq_map = false
else
# FIXME
- # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
- # @headless = 1
+ # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
+ # @headless = 1
# end
defkey = @options.delete( :DefaultKey )
@@ -177,7 +177,7 @@ module YAML
self << "\n"
indent!
end
- self << ": "
+ self << ": "
v[1].to_yaml( :Emitter => self )
}
end
@@ -190,7 +190,7 @@ module YAML
# @seq_map = false
# else
self << "\n"
- indent!
+ indent!
# end
end
@@ -210,8 +210,8 @@ module YAML
self << "[]"
else
# FIXME
- # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
- # @headless = 1
+ # if @buffer.length == 1 and options(:UseHeader) == false and type.length.zero?
+ # @headless = 1
# end
#
diff --git a/lib/yaml/constants.rb b/lib/yaml/constants.rb
index fb833d3077..728d3b7932 100644
--- a/lib/yaml/constants.rb
+++ b/lib/yaml/constants.rb
@@ -13,7 +13,7 @@ module YAML
# Parser tokens
#
WORD_CHAR = 'A-Za-z0-9'
- PRINTABLE_CHAR = '-_A-Za-z0-9!?/()$\'". '
+ PRINTABLE_CHAR = '-_A-Za-z0-9!?/()$\'". '
NOT_PLAIN_CHAR = '\x7f\x0-\x1f\x80-\x9f'
ESCAPE_CHAR = '[\\x00-\\x09\\x0b-\\x1f]'
INDICATOR_CHAR = '*&!|\\\\^@%{}[]='
@@ -27,7 +27,7 @@ module YAML
\x18 \x19 \x1a \e \x1c \x1d \x1e \x1f
}
UNESCAPES = {
- 'a' => "\x07", 'b' => "\x08", 't' => "\x09",
+ 'a' => "\x07", 'b' => "\x08", 't' => "\x09",
'n' => "\x0a", 'v' => "\x0b", 'f' => "\x0c",
'r' => "\x0d", 'e' => "\x1b", '\\' => '\\',
}
diff --git a/lib/yaml/dbm.rb b/lib/yaml/dbm.rb
index 87d6009250..a28fd04f19 100644
--- a/lib/yaml/dbm.rb
+++ b/lib/yaml/dbm.rb
@@ -35,14 +35,14 @@ class DBM < ::DBM
def delete( key )
v = super( key )
if String === v
- v = YAML::load( v )
+ v = YAML::load( v )
end
v
end
def delete_if
del_keys = keys.dup
del_keys.delete_if { |k| yield( k, fetch( k ) ) == false }
- del_keys.each { |k| delete( k ) }
+ del_keys.each { |k| delete( k ) }
self
end
def reject
diff --git a/lib/yaml/encoding.rb b/lib/yaml/encoding.rb
index 57dc553606..98e83c3853 100644
--- a/lib/yaml/encoding.rb
+++ b/lib/yaml/encoding.rb
@@ -23,9 +23,9 @@ module YAML
if $3
["#$3".hex ].pack('U*')
elsif $2
- [$2].pack( "H2" )
+ [$2].pack( "H2" )
else
- UNESCAPES[$1]
+ UNESCAPES[$1]
end
}
end
diff --git a/lib/yaml/error.rb b/lib/yaml/error.rb
index 15865a9aa9..75de0ec18a 100644
--- a/lib/yaml/error.rb
+++ b/lib/yaml/error.rb
@@ -26,7 +26,7 @@ module YAML
#
# YAML Error classes
#
-
+
class Error < StandardError; end
class ParseError < Error; end
class TypeError < StandardError; end
diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb
index 35b719196e..413508c66a 100644
--- a/lib/yaml/rubytypes.rb
+++ b/lib/yaml/rubytypes.rb
@@ -64,7 +64,7 @@ class Struct
end
if not struct_type
struct_def = [ tag.split( ':', 4 ).last ]
- struct_type = Struct.new( *struct_def.concat( val.keys.collect { |k| k.intern } ) )
+ struct_type = Struct.new( *struct_def.concat( val.keys.collect { |k| k.intern } ) )
end
#
@@ -317,7 +317,7 @@ class Time
utc_same_instant = self.dup.utc
utc_same_writing = Time.utc(year,month,day,hour,min,sec,usec)
difference_to_utc = utc_same_writing - utc_same_instant
- if (difference_to_utc < 0)
+ if (difference_to_utc < 0)
difference_sign = '-'
absolute_difference = -difference_to_utc
else
@@ -397,7 +397,7 @@ class FalseClass
end
end
-class NilClass
+class NilClass
yaml_as "tag:yaml.org,2002:null"
def to_yaml( opts = {} )
YAML::quick_emit( nil, opts ) do |out|
diff --git a/lib/yaml/stream.rb b/lib/yaml/stream.rb
index 060fbc4200..651a1bbbef 100644
--- a/lib/yaml/stream.rb
+++ b/lib/yaml/stream.rb
@@ -11,7 +11,7 @@ module YAML
@options = opts
@documents = []
end
-
+
def []( i )
@documents[ i ]
end
diff --git a/lib/yaml/stringio.rb b/lib/yaml/stringio.rb
index 8ad949fa2b..b0fda19e28 100644
--- a/lib/yaml/stringio.rb
+++ b/lib/yaml/stringio.rb
@@ -13,7 +13,7 @@ rescue LoadError
end
def pos
@pos
- end
+ end
def eof
@eof
end
diff --git a/lib/yaml/tag.rb b/lib/yaml/tag.rb
index a39fef375d..ac587165c2 100644
--- a/lib/yaml/tag.rb
+++ b/lib/yaml/tag.rb
@@ -4,13 +4,13 @@
# = yaml/tag.rb: methods for associating a taguri to a class.
#
# Author:: why the lucky stiff
-#
+#
module YAML
# A dictionary of taguris which map to
# Ruby classes.
@@tagged_classes = {}
-
- #
+
+ #
# Associates a taguri _tag_ with a Ruby class _cls_. The taguri is used to give types
# to classes when loading YAML. Taguris are of the form:
#
@@ -19,7 +19,7 @@ module YAML
# The +authorityName+ is a domain name or email address. The +date+ is the date the type
# was issued in YYYY or YYYY-MM or YYYY-MM-DD format. The +specific+ is a name for
# the type being added.
- #
+ #
# For example, built-in YAML types have 'yaml.org' as the +authorityName+ and '2002' as the
# +date+. The +specific+ is simply the name of the type:
#
diff --git a/lib/yaml/types.rb b/lib/yaml/types.rb
index 3871c628fe..60aebc0481 100644
--- a/lib/yaml/types.rb
+++ b/lib/yaml/types.rb
@@ -58,7 +58,7 @@ module YAML
#
# YAML Hash class to support comments and defaults
#
- class SpecialHash < ::Hash
+ class SpecialHash < ::Hash
attr_accessor :default
def inspect
self.default.to_s
@@ -112,7 +112,7 @@ module YAML
if ( tmp = self.assoc( k ) ) and not set
tmp[1] = val
else
- self << [ k, val ]
+ self << [ k, val ]
end
val
end
@@ -163,7 +163,7 @@ module YAML
self.assoc( k ).to_a
end
def []=( k, val )
- self << [ k, val ]
+ self << [ k, val ]
val
end
def has_key?( k )