ruby-changes:2792
From: ko1@a...
Date: 18 Dec 2007 06:05:42 +0900
Subject: [ruby-changes:2792] matz - Ruby:r14283 (trunk): * lib/ping.rb, lib/readbytes.rb: removed
matz 2007-12-18 06:05:25 +0900 (Tue, 18 Dec 2007) New Revision: 14283 Removed files: trunk/lib/ping.rb trunk/lib/readbytes.rb Modified files: trunk/ChangeLog trunk/lib/README Log: * lib/ping.rb, lib/readbytes.rb: removed http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/ping.rb http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14283&r2=14282 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/readbytes.rb http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/README?r1=14283&r2=14282 Index: ChangeLog =================================================================== --- ChangeLog (revision 14282) +++ ChangeLog (revision 14283) @@ -2,6 +2,8 @@ * lib/Env.rb, lib/base64.rb, lib/importenv.rb, lib/eregex.rb: removed. + * lib/ping.rb, lib/readbytes.rb: removed + Tue Dec 18 02:30:56 2007 Nobuyoshi Nakada <nobu@r...> * configure.in (BUILTIN_ENCS): removed. Index: lib/ping.rb =================================================================== --- lib/ping.rb (revision 14282) +++ lib/ping.rb (revision 14283) @@ -1,64 +0,0 @@ -# -# = ping.rb: Check a host for upness -# -# Author:: Yukihiro Matsumoto -# Documentation:: Konrad Meyer -# -# Performs the function of the basic network testing tool, ping. -# See: Ping. -# - -require 'timeout' -require "socket" - -# -# Ping contains routines to test for the reachability of remote hosts. -# Currently the only routine implemented is pingecho(). -# -# Ping.pingecho uses a TCP echo (not an ICMP echo) to determine if the -# remote host is reachable. This is usually adequate to tell that a remote -# host is available to telnet, ftp, or ssh to. -# -# Warning: Ping.pingecho may block for a long time if DNS resolution is -# 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. - # - # Example: - # - # require 'ping' - # - # Ping.pingecho "google.com", 10, 80 - # - def pingecho(host, timeout=5, service="echo") - begin - timeout(timeout) do - s = TCPSocket.new(host, service) - s.close - end - rescue Errno::ECONNREFUSED - return true - rescue Timeout::Error, StandardError - return false - end - return true - end - module_function :pingecho -end - -if $0 == __FILE__ - host = ARGV[0] - host ||= "localhost" - printf("%s alive? - %s\n", host, Ping::pingecho(host, 5)) -end Index: lib/readbytes.rb =================================================================== --- lib/readbytes.rb (revision 14282) +++ lib/readbytes.rb (revision 14283) @@ -1,41 +0,0 @@ -# TruncatedDataError is raised when IO#readbytes fails to read enough data. - -class TruncatedDataError<IOError - def initialize(mesg, data) # :nodoc: - @data = data - super(mesg) - end - - # The read portion of an IO#readbytes attempt. - attr_reader :data -end - -class IO - # Reads exactly +n+ bytes. - # - # If the data read is nil an EOFError is raised. - # - # If the data read is too short a TruncatedDataError is raised and the read - # data is obtainable via its #data method. - def readbytes(n) - str = read(n) - if str == nil - raise EOFError, "End of file reached" - end - if str.size < n - raise TruncatedDataError.new("data truncated", str) - end - str - end -end - -if __FILE__ == $0 - begin - loop do - print STDIN.readbytes(6) - end - rescue TruncatedDataError - p $!.data - raise - end -end Index: lib/README =================================================================== --- lib/README (revision 14282) +++ lib/README (revision 14283) @@ -1,7 +1,6 @@ English.rb lets Perl'ish global variables have English names README this file benchmark.rb a benchmark utility -cgi-lib.rb simple CGI support library (old style) cgi.rb CGI support library cgi/session.rb CGI session class complex.rb complex number support @@ -45,7 +44,6 @@ parsearg.rb argument parser using getopts parsedate.rb parses date string (obsolete) pathname.rb Object-Oriented Pathname Class -ping.rb checks whether host is up, using TCP echo. pp.rb pretty print objects prettyprint.rb pretty printing algorithm profile.rb runs ruby profiler @@ -54,7 +52,6 @@ racc/parser.rb racc (Ruby yACC) runtime rational.rb rational number support rdoc source-code documentation tool -readbytes.rb define IO#readbytes resolv-replace.rb replace Socket DNS by resolve.rb resolv.rb DNS resolver in Ruby rexml an XML parser for Ruby, in Ruby -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml