trailing spaces removed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2008-09-14 15:18:53 +00:00
parent 83453ab1ca
commit f3d95cce97
6 changed files with 89 additions and 89 deletions

View File

@ -542,7 +542,7 @@ module OpenURI
# :proxy => true # :proxy => true
# :proxy => false # :proxy => false
# :proxy => nil # :proxy => nil
# #
# If :proxy option is specified, the value should be String, URI, # If :proxy option is specified, the value should be String, URI,
# boolean or nil. # boolean or nil.
# When String or URI is given, it is treated as proxy URI. # When String or URI is given, it is treated as proxy URI.
@ -556,7 +556,7 @@ module OpenURI
# Synopsis: # Synopsis:
# :proxy_http_basic_authentication => ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"] # :proxy_http_basic_authentication => ["http://proxy.foo.com:8000/", "proxy-user", "proxy-password"]
# :proxy_http_basic_authentication => [URI.parse("http://proxy.foo.com:8000/"), "proxy-user", "proxy-password"] # :proxy_http_basic_authentication => [URI.parse("http://proxy.foo.com:8000/"), "proxy-user", "proxy-password"]
# #
# If :proxy option is specified, the value should be an Array with 3 elements. # If :proxy option is specified, the value should be an Array with 3 elements.
# It should contain a proxy URI, a proxy user name and a proxy password. # It should contain a proxy URI, a proxy user name and a proxy password.
# The proxy URI should be a String, an URI or nil. # The proxy URI should be a String, an URI or nil.
@ -564,7 +564,7 @@ module OpenURI
# #
# If nil is given for the proxy URI, this option is just ignored. # If nil is given for the proxy URI, this option is just ignored.
# #
# If :proxy and :proxy_http_basic_authentication is specified, # If :proxy and :proxy_http_basic_authentication is specified,
# ArgumentError is raised. # ArgumentError is raised.
# #
# [:http_basic_authentication] # [:http_basic_authentication]
@ -579,14 +579,14 @@ module OpenURI
# [:content_length_proc] # [:content_length_proc]
# Synopsis: # Synopsis:
# :content_length_proc => lambda {|content_length| ... } # :content_length_proc => lambda {|content_length| ... }
# #
# If :content_length_proc option is specified, the option value procedure # If :content_length_proc option is specified, the option value procedure
# is called before actual transfer is started. # 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 # If two or more transfer is done by HTTP redirection, the procedure
# is called only one for a last transfer. # is called only one for a last transfer.
# #
# When expected content length is unknown, the procedure is called with # When expected content length is unknown, the procedure is called with
# nil. # nil.
# It is happen when HTTP response has no Content-Length header. # It is happen when HTTP response has no Content-Length header.

View File

@ -1,10 +1,10 @@
# == Pretty-printer for Ruby objects. # == Pretty-printer for Ruby objects.
# #
# = Which seems better? # = Which seems better?
# #
# non-pretty-printed output by #p is: # 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>> # #<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: # pretty-printed output by #pp is:
# #<PP:0x81fedf0 # #<PP:0x81fedf0
# @buffer=[], # @buffer=[],
@ -22,17 +22,17 @@
# @newline="\n", # @newline="\n",
# @output=#<IO:0x8114ee4>, # @output=#<IO:0x8114ee4>,
# @output_width=2> # @output_width=2>
# #
# I like the latter. If you do too, this library is for you. # I like the latter. If you do too, this library is for you.
# #
# = Usage # = Usage
# #
# pp(obj) # pp(obj)
# #
# output +obj+ to +$>+ in pretty printed format. # output +obj+ to +$>+ in pretty printed format.
# #
# It returns +nil+. # It returns +nil+.
# #
# = Output Customization # = Output Customization
# To define your customized pretty printing function for your classes, # To define your customized pretty printing function for your classes,
# redefine a method #pretty_print(+pp+) in the class. # redefine a method #pretty_print(+pp+) in the class.
@ -67,10 +67,10 @@ end
class PP < PrettyPrint class PP < PrettyPrint
# Outputs +obj+ to +out+ in pretty printed format of # Outputs +obj+ to +out+ in pretty printed format of
# +width+ columns in width. # +width+ columns in width.
# #
# If +out+ is omitted, +$>+ is assumed. # If +out+ is omitted, +$>+ is assumed.
# If +width+ is omitted, 79 is assumed. # If +width+ is omitted, 79 is assumed.
# #
# PP.pp returns +out+. # PP.pp returns +out+.
def PP.pp(obj, out=$>, width=79) def PP.pp(obj, out=$>, width=79)
q = PP.new(out, width) q = PP.new(out, width)
@ -82,7 +82,7 @@ class PP < PrettyPrint
# Outputs +obj+ to +out+ like PP.pp but with no indent and # Outputs +obj+ to +out+ like PP.pp but with no indent and
# newline. # newline.
# #
# PP.singleline_pp returns +out+. # PP.singleline_pp returns +out+.
def PP.singleline_pp(obj, out=$>) def PP.singleline_pp(obj, out=$>)
q = SingleLine.new(out) q = SingleLine.new(out)
@ -138,12 +138,12 @@ class PP < PrettyPrint
# Adds +obj+ to the pretty printing buffer # Adds +obj+ to the pretty printing buffer
# using Object#pretty_print or Object#pretty_print_cycle. # using Object#pretty_print or Object#pretty_print_cycle.
# #
# Object#pretty_print_cycle is used when +obj+ is already # Object#pretty_print_cycle is used when +obj+ is already
# printed, a.k.a the object reference chain has a cycle. # printed, a.k.a the object reference chain has a cycle.
def pp(obj) def pp(obj)
id = obj.object_id id = obj.object_id
if check_inspect_key(id) if check_inspect_key(id)
group {obj.pretty_print_cycle self} group {obj.pretty_print_cycle self}
return return
@ -158,7 +158,7 @@ class PP < PrettyPrint
end end
# A convenience method which is same as follows: # A convenience method which is same as follows:
# #
# group(1, '#<' + obj.class.name, '>') { ... } # group(1, '#<' + obj.class.name, '>') { ... }
def object_group(obj, &block) # :yield: def object_group(obj, &block) # :yield:
group(1, '#<' + obj.class.name, '>', &block) group(1, '#<' + obj.class.name, '>', &block)
@ -185,7 +185,7 @@ class PP < PrettyPrint
end end
# A convenience method which is same as follows: # A convenience method which is same as follows:
# #
# text ',' # text ','
# breakable # breakable
def comma_breakable def comma_breakable
@ -195,23 +195,23 @@ class PP < PrettyPrint
# Adds a separated list. # Adds a separated list.
# The list is separated by comma with breakable space, by default. # The list is separated by comma with breakable space, by default.
# #
# #seplist iterates the +list+ using +iter_method+. # #seplist iterates the +list+ using +iter_method+.
# It yields each object to the block given for #seplist. # It yields each object to the block given for #seplist.
# The procedure +separator_proc+ is called between each yields. # The procedure +separator_proc+ is called between each yields.
# #
# If the iteration is zero times, +separator_proc+ is not called at all. # If the iteration is zero times, +separator_proc+ is not called at all.
# #
# If +separator_proc+ is nil or not given, # If +separator_proc+ is nil or not given,
# +lambda { comma_breakable }+ is used. # +lambda { comma_breakable }+ is used.
# If +iter_method+ is not given, :each is used. # If +iter_method+ is not given, :each is used.
# #
# For example, following 3 code fragments has similar effect. # For example, following 3 code fragments has similar effect.
# #
# q.seplist([1,2,3]) {|v| xxx v } # q.seplist([1,2,3]) {|v| xxx v }
# #
# q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v } # q.seplist([1,2,3], lambda { q.comma_breakable }, :each) {|v| xxx v }
# #
# xxx 1 # xxx 1
# q.comma_breakable # q.comma_breakable
# xxx 2 # xxx 2
@ -275,11 +275,11 @@ class PP < PrettyPrint
# A default pretty printing method for general objects. # A default pretty printing method for general objects.
# It calls #pretty_print_instance_variables to list instance variables. # It calls #pretty_print_instance_variables to list instance variables.
# #
# If +self+ has a customized (redefined) #inspect method, # If +self+ has a customized (redefined) #inspect method,
# the result of self.inspect is used but it obviously has no # the result of self.inspect is used but it obviously has no
# line break hints. # line break hints.
# #
# This module provides predefined #pretty_print methods for some of # This module provides predefined #pretty_print methods for some of
# the most commonly used built-in classes for convenience. # the most commonly used built-in classes for convenience.
def pretty_print(q) def pretty_print(q)
@ -302,7 +302,7 @@ class PP < PrettyPrint
end end
# Returns a sorted array of instance variable names. # Returns a sorted array of instance variable names.
# #
# This method should return an array of names of instance variables as symbols or strings as: # This method should return an array of names of instance variables as symbols or strings as:
# +[:@a, :@b]+. # +[:@a, :@b]+.
def pretty_print_instance_variables def pretty_print_instance_variables
@ -311,7 +311,7 @@ class PP < PrettyPrint
# Is #inspect implementation using #pretty_print. # Is #inspect implementation using #pretty_print.
# If you implement #pretty_print, it can be used as follows. # If you implement #pretty_print, it can be used as follows.
# #
# alias inspect pretty_print_inspect # alias inspect pretty_print_inspect
# #
# However, doing this requires that every class that #inspect is called on # However, doing this requires that every class that #inspect is called on
@ -629,7 +629,7 @@ if __FILE__ == $0
result = PP.pp(a, '') result = PP.pp(a, '')
assert_equal("#{a.inspect}\n", result) assert_equal("#{a.inspect}\n", result)
end end
def test_to_s_without_iv def test_to_s_without_iv
a = Object.new a = Object.new
def a.to_s() "aaa" end def a.to_s() "aaa" end

View File

@ -2,7 +2,7 @@
# This class implements a pretty printing algorithm. It finds line breaks and # This class implements a pretty printing algorithm. It finds line breaks and
# nice indentations for grouped structure. # nice indentations for grouped structure.
# #
# By default, the class assumes that primitive elements are strings and each # 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 # byte in the strings have single column in width. But it can be used for
# other situations by giving suitable arguments for some methods: # other situations by giving suitable arguments for some methods:
@ -18,28 +18,28 @@
# == Bugs # == Bugs
# * Box based formatting? # * Box based formatting?
# * Other (better) model/algorithm? # * Other (better) model/algorithm?
# #
# == References # == References
# Christian Lindig, Strictly Pretty, March 2000, # Christian Lindig, Strictly Pretty, March 2000,
# http://www.st.cs.uni-sb.de/~lindig/papers/#pretty # http://www.st.cs.uni-sb.de/~lindig/papers/#pretty
# #
# Philip Wadler, A prettier printer, March 1998, # Philip Wadler, A prettier printer, March 1998,
# http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier # http://homepages.inf.ed.ac.uk/wadler/topics/language-design.html#prettier
# #
# == Author # == Author
# Tanaka Akira <akr@m17n.org> # Tanaka Akira <akr@m17n.org>
# #
class PrettyPrint class PrettyPrint
# This is a convenience method which is same as follows: # This is a convenience method which is same as follows:
# #
# begin # begin
# q = PrettyPrint.new(output, maxwidth, newline, &genspace) # q = PrettyPrint.new(output, maxwidth, newline, &genspace)
# ... # ...
# q.flush # q.flush
# output # output
# end # end
# #
def PrettyPrint.format(output='', maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n}) def PrettyPrint.format(output='', maxwidth=79, newline="\n", genspace=lambda {|n| ' ' * n})
q = PrettyPrint.new(output, maxwidth, newline, &genspace) q = PrettyPrint.new(output, maxwidth, newline, &genspace)
yield q yield q

View File

@ -13,24 +13,24 @@ end
# interpreter. # interpreter.
# #
# See also resolv-replace.rb to replace the libc resolver with # Resolv. # See also resolv-replace.rb to replace the libc resolver with # Resolv.
# #
# Resolv can look up various DNS resources using the DNS module directly. # Resolv can look up various DNS resources using the DNS module directly.
# #
# Examples: # Examples:
# #
# p Resolv.getaddress "www.ruby-lang.org" # p Resolv.getaddress "www.ruby-lang.org"
# p Resolv.getname "210.251.121.214" # p Resolv.getname "210.251.121.214"
# #
# Resolv::DNS.open do |dns| # Resolv::DNS.open do |dns|
# ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A # ress = dns.getresources "www.ruby-lang.org", Resolv::DNS::Resource::IN::A
# p ress.map { |r| r.address } # p ress.map { |r| r.address }
# ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX # ress = dns.getresources "ruby-lang.org", Resolv::DNS::Resource::IN::MX
# p ress.map { |r| [r.exchange.to_s, r.preference] } # p ress.map { |r| [r.exchange.to_s, r.preference] }
# end # end
# #
# #
# == Bugs # == Bugs
# #
# * NIS is not supported. # * NIS is not supported.
# * /etc/nsswitch.conf is not supported. # * /etc/nsswitch.conf is not supported.
@ -38,14 +38,14 @@ class Resolv
## ##
# Looks up the first IP address for +name+. # Looks up the first IP address for +name+.
def self.getaddress(name) def self.getaddress(name)
DefaultResolver.getaddress(name) DefaultResolver.getaddress(name)
end end
## ##
# Looks up all IP address for +name+. # Looks up all IP address for +name+.
def self.getaddresses(name) def self.getaddresses(name)
DefaultResolver.getaddresses(name) DefaultResolver.getaddresses(name)
end end
@ -87,7 +87,7 @@ class Resolv
## ##
# Looks up the first IP address for +name+. # Looks up the first IP address for +name+.
def getaddress(name) def getaddress(name)
each_address(name) {|address| return address} each_address(name) {|address| return address}
raise ResolvError.new("no address for #{name}") raise ResolvError.new("no address for #{name}")
@ -95,7 +95,7 @@ class Resolv
## ##
# Looks up all IP address for +name+. # Looks up all IP address for +name+.
def getaddresses(name) def getaddresses(name)
ret = [] ret = []
each_address(name) {|address| ret << address} each_address(name) {|address| ret << address}
@ -309,7 +309,7 @@ class Resolv
# Creates a new DNS resolver. # Creates a new DNS resolver.
# #
# +config_info+ can be: # +config_info+ can be:
# #
# nil:: Uses /etc/resolv.conf. # nil:: Uses /etc/resolv.conf.
# String:: Path to a file using /etc/resolv.conf's format. # String:: Path to a file using /etc/resolv.conf's format.
# Hash:: Must contain :nameserver, :search and :ndots keys. # Hash:: Must contain :nameserver, :search and :ndots keys.
@ -457,7 +457,7 @@ class Resolv
## ##
# Looks up all +typeclass+ DNS resources for +name+. See #getresource for # Looks up all +typeclass+ DNS resources for +name+. See #getresource for
# argument details. # argument details.
def getresources(name, typeclass) def getresources(name, typeclass)
ret = [] ret = []
each_resource(name, typeclass) {|resource| ret << resource} each_resource(name, typeclass) {|resource| ret << resource}
@ -467,7 +467,7 @@ class Resolv
## ##
# Iterates over all +typeclass+ DNS resources for +name+. See # Iterates over all +typeclass+ DNS resources for +name+. See
# #getresource for argument details. # #getresource for argument details.
def each_resource(name, typeclass, &proc) def each_resource(name, typeclass, &proc)
lazy_initialize lazy_initialize
requester = make_requester requester = make_requester
@ -569,7 +569,7 @@ class Resolv
h = (RequestID[[host, port]] ||= {}) h = (RequestID[[host, port]] ||= {})
begin begin
id = rangerand(0x0000..0xffff) id = rangerand(0x0000..0xffff)
end while h[id] end while h[id]
h[id] = true h[id] = true
} }
id id
@ -1037,7 +1037,7 @@ class Resolv
# A representation of a DNS name. # A representation of a DNS name.
class Name class Name
## ##
# Creates a new DNS name from +arg+. +arg+ can be: # Creates a new DNS name from +arg+. +arg+ can be:
# #
@ -1460,11 +1460,11 @@ class Resolv
class Query class Query
def encode_rdata(msg) # :nodoc: def encode_rdata(msg) # :nodoc:
raise EncodeError.new("#{self.class} is query.") raise EncodeError.new("#{self.class} is query.")
end end
def self.decode_rdata(msg) # :nodoc: def self.decode_rdata(msg) # :nodoc:
raise DecodeError.new("#{self.class} is query.") raise DecodeError.new("#{self.class} is query.")
end end
end end
@ -1939,7 +1939,7 @@ class Resolv
def initialize(address) def initialize(address)
@address = IPv6.create(address) @address = IPv6.create(address)
end end
## ##
# The Resolv::IPv6 address for this AAAA. # The Resolv::IPv6 address for this AAAA.
@ -1956,7 +1956,7 @@ class Resolv
## ##
# SRV resource record defined in RFC 2782 # SRV resource record defined in RFC 2782
# #
# These records identify the hostname and port that a service is # These records identify the hostname and port that a service is
# available at. # available at.

View File

@ -1,37 +1,37 @@
# #
# == Introduction # == Introduction
# #
# This library extends the Time class: # This library extends the Time class:
# * conversion between date string and time object. # * conversion between date string and time object.
# * date-time defined by RFC 2822 # * date-time defined by RFC 2822
# * HTTP-date defined by RFC 2616 # * HTTP-date defined by RFC 2616
# * dateTime defined by XML Schema Part 2: Datatypes (ISO 8601) # * dateTime defined by XML Schema Part 2: Datatypes (ISO 8601)
# * various formats handled by Date._parse (string to time only) # * various formats handled by Date._parse (string to time only)
# #
# == Design Issues # == Design Issues
# #
# === Specialized interface # === Specialized interface
# #
# This library provides methods dedicated to special purposes: # This library provides methods dedicated to special purposes:
# * RFC 2822, RFC 2616 and XML Schema. # * RFC 2822, RFC 2616 and XML Schema.
# * They makes usual life easier. # * They makes usual life easier.
# #
# === Doesn't depend on strftime # === Doesn't depend on strftime
# #
# This library doesn't use +strftime+. Especially #rfc2822 doesn't depend # This library doesn't use +strftime+. Especially #rfc2822 doesn't depend
# on +strftime+ because: # on +strftime+ because:
# #
# * %a and %b are locale sensitive # * %a and %b are locale sensitive
# #
# Since they are locale sensitive, they may be replaced to # Since they are locale sensitive, they may be replaced to
# invalid weekday/month name in some locales. # invalid weekday/month name in some locales.
# Since ruby-1.6 doesn't invoke setlocale by default, # Since ruby-1.6 doesn't invoke setlocale by default,
# the problem doesn't arise until some external library invokes setlocale. # the problem doesn't arise until some external library invokes setlocale.
# Ruby/GTK is the example of such library. # Ruby/GTK is the example of such library.
# #
# * %z is not portable # * %z is not portable
# #
# %z is required to generate zone in date-time of RFC 2822 # %z is required to generate zone in date-time of RFC 2822
# but it is not portable. # but it is not portable.
# #
@ -61,9 +61,9 @@ class Time
'PST' => -8, 'PDT' => -7, 'PST' => -8, 'PDT' => -7,
# Following definition of military zones is original one. # Following definition of military zones is original one.
# See RFC 1123 and RFC 2822 for the error in RFC 822. # 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, '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, 'T' => -7, 'U' => -8, 'V' => -9, 'W' => -10, 'X' => -11, 'Y' => -12,
} }
def zone_offset(zone, year=self.now.year) def zone_offset(zone, year=self.now.year)
@ -436,8 +436,8 @@ class Time
# #
# Returns a string which represents the time as rfc1123-date of HTTP-date # 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 # day-of-week, DD month-name CCYY hh:mm:ss GMT
# #
# Note that the result is always UTC (GMT). # Note that the result is always UTC (GMT).
@ -768,21 +768,21 @@ if __FILE__ == $0
def test_rfc2822_leap_second def test_rfc2822_leap_second
t = Time.utc(1998,12,31,23,59,59) t = Time.utc(1998,12,31,23,59,59)
assert_equal(t, Time.rfc2822("Thu, 31 Dec 1998 23:59:59 UTC")) assert_equal(t, Time.rfc2822("Thu, 31 Dec 1998 23:59:59 UTC"))
assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:59 -0000"));t.localtime assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:59 -0000"));t.localtime
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 08:59:59 +0900")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 08:59:59 +0900"))
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:59:59 +0100")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:59:59 +0100"))
assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:59 +0000")) assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:59 +0000"))
assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 22:59:59 -0100"));t.utc assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 22:59:59 -0100"));t.utc
t += 1 t += 1
assert_equal(t, Time.rfc2822("Thu, 31 Dec 1998 23:59:60 UTC")) assert_equal(t, Time.rfc2822("Thu, 31 Dec 1998 23:59:60 UTC"))
assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:60 -0000"));t.localtime assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:60 -0000"));t.localtime
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 08:59:60 +0900")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 08:59:60 +0900"))
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:59:60 +0100")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:59:60 +0100"))
assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:60 +0000")) assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 23:59:60 +0000"))
assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 22:59:60 -0100"));t.utc assert_equal(t, Time.rfc2822("Fri, 31 Dec 1998 22:59:60 -0100"));t.utc
t += 1 if t.sec == 60 t += 1 if t.sec == 60
assert_equal(t, Time.rfc2822("Thu, 1 Jan 1999 00:00:00 UTC")) assert_equal(t, Time.rfc2822("Thu, 1 Jan 1999 00:00:00 UTC"))
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:00:00 -0000"));t.localtime assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:00:00 -0000"));t.localtime
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 09:00:00 +0900")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 09:00:00 +0900"))
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 01:00:00 +0100")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 01:00:00 +0100"))
assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:00:00 +0000")) assert_equal(t, Time.rfc2822("Fri, 1 Jan 1999 00:00:00 +0000"))

View File

@ -32,7 +32,7 @@
# array using the user-supplied block. # array using the user-supplied block.
# #
# require 'tsort' # require 'tsort'
# #
# class Hash # class Hash
# include TSort # include TSort
# alias tsort_each_node each_key # alias tsort_each_node each_key
@ -40,10 +40,10 @@
# fetch(node).each(&block) # fetch(node).each(&block)
# end # end
# end # end
# #
# {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort # {1=>[2, 3], 2=>[3], 3=>[], 4=>[]}.tsort
# #=> [3, 2, 1, 4] # #=> [3, 2, 1, 4]
# #
# {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components # {1=>[2], 2=>[3, 4], 3=>[2], 4=>[]}.strongly_connected_components
# #=> [[4], [2, 3], [1]] # #=> [[4], [2, 3], [1]]
# #
@ -52,19 +52,19 @@
# A very simple `make' like tool can be implemented as follows: # A very simple `make' like tool can be implemented as follows:
# #
# require 'tsort' # require 'tsort'
# #
# class Make # class Make
# def initialize # def initialize
# @dep = {} # @dep = {}
# @dep.default = [] # @dep.default = []
# end # end
# #
# def rule(outputs, inputs=[], &block) # def rule(outputs, inputs=[], &block)
# triple = [outputs, inputs, block] # triple = [outputs, inputs, block]
# outputs.each {|f| @dep[f] = [triple]} # outputs.each {|f| @dep[f] = [triple]}
# @dep[triple] = inputs # @dep[triple] = inputs
# end # end
# #
# def build(target) # def build(target)
# each_strongly_connected_component_from(target) {|ns| # each_strongly_connected_component_from(target) {|ns|
# if ns.length != 1 # if ns.length != 1
@ -88,18 +88,18 @@
# end # end
# } # }
# end # end
# #
# def tsort_each_child(node, &block) # def tsort_each_child(node, &block)
# @dep[node].each(&block) # @dep[node].each(&block)
# end # end
# include TSort # include TSort
# end # end
# #
# def command(arg) # def command(arg)
# print arg, "\n" # print arg, "\n"
# system arg # system arg
# end # end
# #
# m = Make.new # m = Make.new
# m.rule(%w[t1]) { command 'date > t1' } # m.rule(%w[t1]) { command 'date > t1' }
# m.rule(%w[t2]) { command 'date > t2' } # m.rule(%w[t2]) { command 'date > t2' }
@ -189,7 +189,7 @@ module TSort
end end
# #
# Iterates over strongly connected component in the subgraph reachable from # Iterates over strongly connected component in the subgraph reachable from
# _node_. # _node_.
# #
# Return value is unspecified. # Return value is unspecified.