Project

General

Profile

Bug #5203 ยป 0001-fix-grammar-mistakes-and-typos-mainly-in-standard-li.patch

luke-gru (Luke Gruber), 08/19/2011 06:44 AM

View differences:

ext/json/lib/json.rb
#
# Built on two universally available structures:
# 1. A collection of name/value pairs. Often referred to as an _object_, hash table, record, struct, keyed list, or associative array.
# 2. An orderd list of values. More commonly named as an _array_, vector, sequence, or list.
# 2. An ordered list of values. More commonly called an _array_, vector, sequence or list.
#
# To read more about JSON visit: http://json.org
#
# == Parsing JSON
#
# To parse a JSON string received by another application, or generated within
# To parse a JSON string received by another application or generated within
# your existing application:
#
# require 'json'
......
# puts {:hello => "goodbye"}.to_json => "{\"hello\":\"goodbye\"}"
#
# <tt>JSON.generate</tt> only allows objects or arrays to be converted
# to JSON syntax. While <tt>to_json</tt> accepts many Ruby classes
# even though it only acts a method for serialization:
# to JSON syntax. <tt>to_json</tt>, however, accepts many Ruby classes
# even though it acts only as a method for serialization:
#
# require 'json'
#
ext/json/lib/json/common.rb
module JSON
class << self
# If _object_ is string-like parse the string and return the parsed result
# If _object_ is string-like, parse the string and return the parsed result
# as a Ruby data structure. Otherwise generate a JSON text from the Ruby
# data structure object and return it.
#
# The _opts_ argument is passed through to generate/parse respectively, see
# The _opts_ argument is passed through to generate/parse respectively. See
# generate and parse for their documentation.
def [](object, opts = {})
if object.respond_to? :to_str
......
end
end
# Returns the JSON parser class, that is used by JSON. This might be either
# Returns the JSON parser class that is used by JSON. This is either
# JSON::Ext::Parser or JSON::Pure::Parser.
attr_reader :parser
......
end
# Return the constant located at _path_. The format of _path_ has to be
# either ::A::B::C or A::B::C. In any case A has to be located at the top
# either ::A::B::C or A::B::C. In any case, A has to be located at the top
# level (absolute namespace path?). If there doesn't exist a constant at
# the given path, an ArgumentError is raised.
def deep_const_get(path) # :nodoc:
......
$VERBOSE = old
end
# Returns the JSON generator modul, that is used by JSON. This might be
# Returns the JSON generator module that is used by JSON. This is
# either JSON::Ext::Generator or JSON::Pure::Generator.
attr_reader :generator
# Returns the JSON generator state class, that is used by JSON. This might
# be either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
# Returns the JSON generator state class that is used by JSON. This is
# either JSON::Ext::Generator::State or JSON::Pure::Generator::State.
attr_accessor :state
# This is create identifier, that is used to decide, if the _json_create_
# This is create identifier, which is used to decide if the _json_create_
# hook of a class should be called. It defaults to 'json_class'.
attr_accessor :create_id
end
......
# The base exception for JSON errors.
class JSONError < StandardError; end
# This exception is raised, if a parser error occurs.
# This exception is raised if a parser error occurs.
class ParserError < JSONError; end
# This exception is raised, if the nesting of parsed datastructures is too
# This exception is raised if the nesting of parsed data structures is too
# deep.
class NestingError < ParserError; end
......
class CircularDatastructure < NestingError; end
# :startdoc:
# This exception is raised, if a generator or unparser error occurs.
# This exception is raised if a generator or unparser error occurs.
class GeneratorError < JSONError; end
# For backwards compatibility
UnparserError = GeneratorError
# This exception is raised, if the required unicode support is missing on the
# system. Usually this means, that the iconv library is not installed.
# This exception is raised if the required unicode support is missing on the
# system. Usually this means that the iconv library is not installed.
class MissingUnicodeSupport < JSONError; end
module_function
......
# _opts_ can have the following
# keys:
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
# structures. Disable depth checking with :max_nesting => false, it defaults
# structures. Disable depth checking with :max_nesting => false. It defaults
# to 19.
# * *allow_nan*: If set to true, allow NaN, Infinity and -Infinity in
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
# to false.
# * *symbolize_names*: If set to true, returns symbols for the names
# (keys) in a JSON object. Otherwise strings are returned, which is also
# (keys) in a JSON object. Otherwise strings are returned. Strings are
# the default.
# * *create_additions*: If set to false, the Parser doesn't create
# additions even if a matchin class and create_id was found. This option
# additions even if a matching class and create_id was found. This option
# defaults to true.
# * *object_class*: Defaults to Hash
# * *array_class*: Defaults to Array
......
end
# Parse the JSON document _source_ into a Ruby data structure and return it.
# The bang version of the parse method, defaults to the more dangerous values
# The bang version of the parse method defaults to the more dangerous values
# for the _opts_ hash, so be sure only to parse trusted _source_ documents.
#
# _opts_ can have the following keys:
# * *max_nesting*: The maximum depth of nesting allowed in the parsed data
# structures. Enable depth checking with :max_nesting => anInteger. The parse!
# methods defaults to not doing max depth checking: This can be dangerous,
# methods defaults to not doing max depth checking: This can be dangerous
# if someone wants to fill up your stack.
# * *allow_nan*: If set to true, allow NaN, Infinity, and -Infinity in
# defiance of RFC 4627 to be parsed by the Parser. This option defaults
# to true.
# * *create_additions*: If set to false, the Parser doesn't create
# additions even if a matchin class and create_id was found. This option
# additions even if a matching class and create_id was found. This option
# defaults to true.
def parse!(source, opts = {})
opts = {
......
# * *object_nl*: a string that is put at the end of a JSON object (default: ''),
# * *array_nl*: a string that is put at the end of a JSON array (default: ''),
# * *allow_nan*: true if NaN, Infinity, and -Infinity should be
# generated, otherwise an exception is thrown, if these values are
# generated, otherwise an exception is thrown if these values are
# encountered. This options defaults to false.
# * *max_nesting*: The maximum depth of nesting allowed in the data
# structures from which JSON is to be generated. Disable depth checking
......
#
# See also the fast_generate for the fastest creation method with the least
# amount of sanity checks, and the pretty_generate method for some
# defaults for a pretty output.
# defaults for pretty output.
def generate(obj, opts = nil)
state = SAFE_STATE_PROTOTYPE.dup
if opts
......
# This method disables the checks for circles in Ruby objects.
#
# *WARNING*: Be careful not to pass any Ruby data structures with circles as
# _obj_ argument, because this will cause JSON to go into an infinite loop.
# _obj_ argument because this will cause JSON to go into an infinite loop.
def fast_generate(obj, opts = nil)
state = FAST_STATE_PROTOTYPE.dup
if opts
......
# The returned document is a prettier form of the document returned by
# #unparse.
#
# The _opts_ argument can be used to configure the generator, see the
# The _opts_ argument can be used to configure the generator. See the
# generate method for a more detailed explanation.
def pretty_generate(obj, opts = nil)
state = PRETTY_STATE_PROTOTYPE.dup
......
# :startdoc:
# Load a ruby data structure from a JSON _source_ and return it. A source can
# either be a string-like object, an IO like object, or an object responding
# either be a string-like object, an IO-like object, or an object responding
# to the read method. If _proc_ was given, it will be called with any nested
# Ruby object as an argument recursively in depth first order.
#
......
# Dumps _obj_ as a JSON string, i.e. calls generate on the object and returns
# the result.
#
# If anIO (an IO like object or an object that responds to the write method)
# If anIO (an IO-like object or an object that responds to the write method)
# was given, the resulting JSON is written to it.
#
# If the number of nested arrays or objects exceeds _limit_ an ArgumentError
# If the number of nested arrays or objects exceeds _limit_, an ArgumentError
# exception is raised. This argument is similar (but not exactly the
# same!) to the _limit_ argument in Marshal.dump.
#
......
nil
end
# If _object_ is string-like parse the string and return the parsed result as
# a Ruby data structure. Otherwise generate a JSON text from the Ruby data
# If _object_ is string-like, parse the string and return the parsed result as
# a Ruby data structure. Otherwise, generate a JSON text from the Ruby data
# structure object and return it.
#
# The _opts_ argument is passed through to generate/parse respectively, see
# The _opts_ argument is passed through to generate/parse respectively. See
# generate and parse for their documentation.
def JSON(object, *args)
if object.respond_to? :to_str
......
# Extends any Class to include _json_creatable?_ method.
class ::Class
# Returns true, if this class can be used to create an instance
# Returns true if this class can be used to create an instance
# from a serialised JSON string. The class has to implement a class
# method _json_create_ that expects a hash as first parameter, which includes
# the required data.
# method _json_create_ that expects a hash as first parameter. The hash
# should include the required data.
def json_creatable?
respond_to?(:json_create)
end
ext/pathname/lib/pathname.rb
# pn.children(false)
# # -> [ Pathname:English.rb, Pathname:Env.rb, Pathname:abbrev.rb, ... ]
#
# Note that the result never contain the entries <tt>.</tt> and <tt>..</tt> in
# Note that the results never contain the entries <tt>.</tt> and <tt>..</tt> in
# the directory because they are not children.
#
# This method has existed since 1.8.1.
......
# manner. It yields a Pathname for each file under "this" directory.
#
# Since it is implemented by <tt>find.rb</tt>, <tt>Find.prune</tt> can be used
# to control the traverse.
# to control the traversal.
#
# If +self+ is <tt>.</tt>, yielded pathnames begin with a filename in the
# current directory, not <tt>./</tt>.
ext/pty/lib/expect.rb
# Reads ios until pattern matches or the timeout is over. It returns
# an array with the read buffer, followed by the matches. If a block is given,
# the result is yielded to the block and returns nil. The optional timeout parameter defines,
# in seconds, the total time to wait for pattern. If it is over of eof is found, it
# in seconds, the total time to wait for pattern. If it is over or eof is found, it
# returns/yields nil. However, the buffer in a timeout session is kept for the next expect call.
# The default timeout is 9999999 seconds.
def expect(pat,timeout=9999999)
lib/mathn.rb
# 20 / 9 * 3 * 14 / 7 * 3 / 2 # => 20
#
#
# When you require 'mathn' the libraries for Prime, CMath, Matrix and Vector
# When you require 'mathn', the libraries for Prime, CMath, Matrix and Vector
# are also loaded.
#
# == Copyright
......
end
##
# When mathn is required Fixnum's division and exponentiation are enhanced to
# return more precise values in mathematical formulas.
# When mathn is required, Fixnum's division and exponentiation are enhanced to
# return more precise values from mathematical expressions.
#
# 2/3*3 # => 0
# require 'mathn'
......
##
# When mathn is required Bignum's division and exponentiation are enhanced to
# return more precise values in mathematical formulas.
# return more precise values from mathematical expressions.
class Bignum
remove_method :/
......
end
##
# When mathn is required Rational changes to simplfy the usage of Rational
# When mathn is required Rational is changed to simplify the use of Rational
# operations.
#
# Normal behaviour:
......
end
##
# When mathn is requried the Math module changes as follows:
# When mathn is required, the Math module changes as follows:
#
# Standard Math module behaviour:
# Math.sqrt(4/9) # => 0.0
# Math.sqrt(4.0/9.0) # => 0.666666666666667
# Math.sqrt(- 4/9) # => Errno::EDOM: Numerical argument out of domain - sqrt
#
# After require 'mathn' this is changed to:
# After require 'mathn', this is changed to:
#
# require 'mathn'
# Math.sqrt(4/9) # => 2/3
......
end
##
# When mathn is required Float is changed to handle Complex numbers.
# When mathn is required, Float is changed to handle Complex numbers.
class Float
alias power! **
lib/net/http.rb
# Here is HTTP response class hierarchy. All classes are defined in Net
# module and are subclasses of Net::HTTPResponse.
#
# HTTPUnknownResponse:: For unhandled HTTP extenensions
# HTTPUnknownResponse:: For unhandled HTTP extensions
# HTTPInformation:: 1xx
# HTTPContinue:: 100
# HTTPSwitchProtocol:: 101
......
# Creates a new Net::HTTP object, then additionally opens the TCP
# connection and HTTP session.
#
# Argments are following:
# Arguments are the following:
# _address_ :: hostname or IP address of the server
# _port_ :: port of the server
# _p_addr_ :: address of proxy
lib/open-uri.rb
alias open_uri_original_open open # :nodoc:
end
# makes possible to open various resources including URIs.
# If the first argument respond to `open' method,
# the method is called with the rest arguments.
# Allows the opening of various resources including URIs.
# If the first argument responds to the `open' method,
# the first argument calls 'open', passing it the rest of the arguments.
#
# If the first argument is a string which begins with xxx://,
# it is parsed by URI.parse. If the parsed object respond to `open' method,
# the method is called with the rest arguments.
# If the first argument is a string that begins with xxx://,
# it is parsed by URI.parse. If the parsed object respond to the `open' method,
# the first argument calls 'open', passing it the rest of the arguments.
#
# Otherwise original open is called.
# Otherwise, original 'open' is called.
#
# Since open-uri.rb provides URI::HTTP#open, URI::HTTPS#open and
# URI::FTP#open,
# Kernel[#.]open can accepts such URIs and strings which begins with
# Kernel[#.]open can accept URIs and strings that begin with
# http://, https:// and ftp://.
# In these case, the opened file object is extended by OpenURI::Meta.
# In these cases, the opened file object is extended by OpenURI::Meta.
def open(name, *rest, &block) # :doc:
if name.respond_to?(:open)
name.open(*rest, &block)
......
#
#== Example
#
# It is possible to open http/https/ftp URL as usual like opening a file:
# It is possible to open an http/https/ftp URL as though it were a file:
#
# open("http://www.ruby-lang.org/") {|f|
# f.each_line {|line| p line}
# }
#
# The opened file has several methods for meta information as follows since
# it is extended by OpenURI::Meta.
# The opened file has several getter methods for its meta-information, as follows,
# since it is extended by OpenURI::Meta.
#
# open("http://www.ruby-lang.org/en") {|f|
# f.each_line {|line| p line}
......
end
end
# returns an Array which consists status code and message.
# returns an Array that consists of status code and message.
attr_accessor :status
# returns a URI which is base of relative URIs in the data.
# It may differ from the URI supplied by a user because redirection.
# returns a URI that is the base of relative URIs in the data.
# It may differ from the URI supplied by a user due to redirection.
attr_accessor :base_uri
# returns a Hash which represents header fields.
# returns a Hash that represents header fields.
# The Hash keys are downcased for canonicalization.
attr_reader :meta
......
meta_setup_encoding if name == 'content-type'
end
# returns a Time which represents Last-Modified field.
# returns a Time that represents Last-Modified field.
def last_modified
if v = @meta['last-modified']
Time.httpdate(v)
......
#
# `options' must be a hash.
#
# Each pairs which key is a string in the hash specify a extra header
# Each pair whose key is a string in the hash specifies an extra header
# field for HTTP.
# I.e. it is ignored for FTP without HTTP proxy.
#
# The hash may include other options which key is a symbol:
# The hash may include other options, where keys are symbols:
#
# [:proxy]
# Synopsis:
......
#
# If :content_length_proc option is specified, the option value procedure
# is called before actual transfer is started.
# It takes one argument which is expected content length in bytes.
# It takes one argument, which is expected content length in bytes.
#
# If two or more transfer is done by HTTP redirection, the procedure
# is called only one for a last transfer.
#
# When expected content length is unknown, the procedure is called with
# nil.
# It is happen when HTTP response has no Content-Length header.
# This happens when the HTTP response has no Content-Length header.
#
# [:progress_proc]
# Synopsis:
......
#
# :ssl_verify_mode is used to specify openssl verify mode.
#
# OpenURI::OpenRead#open returns an IO like object if block is not given.
# OpenURI::OpenRead#open returns an IO-like object if block is not given.
# Otherwise it yields the IO object and return the value of the block.
# The IO object is extended with OpenURI::Meta.
#
......
# Synopsis:
# :redirect=>bool
#
# :redirect=>false is used to disable HTTP redirects at all.
# :redirect=>false is used to disable all HTTP redirects.
# OpenURI::HTTPRedirect exception raised on redirection.
# It is true by default.
# The true means redirections between http and ftp is permitted.
# The true means redirections between http and ftp are permitted.
#
def open(*rest, &block)
OpenURI.open_uri(self, *rest, &block)
lib/ostruct.rb
#
# An OpenStruct is a data structure, similar to a Hash, that allows the
# definition of arbitrary attributes with their accompanying values. This is
# accomplished by using Ruby's metaporgramming to define methods on the class
# accomplished by using Ruby's metaprogramming to define methods on the class
# itself.
#
# == Examples:
......
# method_missing and define_method.
#
# This should be a consideration if there is a concern about the performance of
# the objects that are created. As there is much more overhead in the setting
# of these properties compard to utilizing a Hash or a Struct.
# the objects that are created, as there is much more overhead in the setting
# of these properties compared to using a Hash or a Struct.
#
class OpenStruct
#
lib/rdoc/markup.rb
# sequences, and to add special processing for text that matches a
# regular expression. Here we make WikiWords significant to the parser,
# and also make the sequences {word} and \<no>text...</no> signify
# strike-through text. When then subclass the HTML output class to deal
# strike-through text. We then subclass the HTML output class to deal
# with these:
#
# require 'rdoc/markup'
......
#
# == Encoding
#
# Where Encoding support is available RDoc will automatically convert all
# Where Encoding support is available, RDoc will automatically convert all
# documents to the same output encoding. The output encoding can be set via
# RDoc::Options#encoding and defaults to Encoding.default_external.
#
......
# === Simple Lists
#
# If a paragraph starts with a "*", "-", "<digit>." or "<letter>.",
# then it is taken to be the start of a list. The margin in increased to be
# then it is taken to be the start of a list. The margin is increased to be
# the first non-space following the list start flag. Subsequent lines
# should be indented to this new margin until the list ends. For example:
#
......
#
# [+:nodoc:+ / <tt>:nodoc: all</tt>]
# This directive prevents documentation for the element from
# being generated. For classes and modules, the methods, aliases,
# being generated. For classes and modules, methods, aliases,
# constants, and attributes directly within the affected class or
# module also will be omitted. By default, though, modules and
# classes within that class of module _will_ be documented. This is
# classes within that class or module _will_ be documented. This is
# turned off by adding the +all+ modifier.
#
# module MyModule # :nodoc:
......
attr_reader :attribute_manager
##
# Take a block of text and use various heuristics to determine it's
# Take a block of text and use various heuristics to determine its
# structure (paragraphs, lists, and so on). Invoke an event handler as we
# identify significant chunks.
lib/rdoc/parser.rb
require 'rdoc/stats'
##
# A parser is simple a class that implements
# A parser is simply a class that implements
#
# #initialize(file_name, body, options)
#
......
#
# The ParseFactory is used to redirect to the correct parser given a
# filename 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
# register themselves with us as they are loaded in. They do this by using the
# following:
#
# require "rdoc/parser"
#
......
class << self
##
# A Hash that maps file extensions regular expressions to parsers that
# will consume them.
# An Array of arrays that maps file extension patterns to parsers that
# will parse them.
#
# Use parse_files_matching to register a parser's file extensions.
lib/tempfile.rb
# that's it's unnecessary to explicitly delete a Tempfile after use, though
# it's good practice to do so: not explicitly deleting unused Tempfiles can
# potentially leave behind large amounts of tempfiles on the filesystem
# until they're garbage collected. The existance of these temp files can make
# until they're garbage collected. The existence of these temp files can make
# it harder to determine a new Tempfile filename.
#
# Therefore, one should always call #unlink or close in an ensure block, like
lib/thread.rb
# Wakes up all threads waiting for this lock.
#
def broadcast
# TODO: imcomplete
# TODO: incomplete
waiters0 = nil
@waiters_mutex.synchronize do
waiters0 = @waiters.dup
......
def initialize
@que = []
@waiting = []
@que.taint # enable tainted comunication
@que.taint # enable tainted communication
@waiting.taint
self.taint
@mutex = Mutex.new
lib/weakref.rb
require "delegate"
require 'thread'
# Weak Reference class that does allows a referenced object to be
# Weak Reference class that allows a referenced object to be
# garbage-collected. A WeakRef may be used exactly like the object it
# references.
#
sample/webrick/httpproxy.rb
require "webrick/httpproxy"
# :ProxyContentHandler will be invoked before sending
# response to User-Agenge. You can inspect the pair of
# request and response messages (or can edit the response
# response to User-Agent. You can inspect the pair of
# request and response messages (or edit the response
# message if necessary).
pch = Proc.new{|req, res|
    (1-1/1)