ruby-changes:3118
From: ko1@a...
Date: 24 Dec 2007 23:10:15 +0900
Subject: [ruby-changes:3118] nahi - Ruby:r14610 (trunk): Mon Dec 24 23:04:57 2007 NAKAMURA, Hiroshi <nahi@r...>
nahi 2007-12-24 23:09:57 +0900 (Mon, 24 Dec 2007) New Revision: 14610 Removed files: trunk/lib/ftools.rb trunk/lib/parsedate.rb Modified files: trunk/ChangeLog trunk/lib/README trunk/lib/rake.rb trunk/lib/rdoc/generators/html_generator.rb trunk/lib/rdoc/generators/ri_generator.rb trunk/lib/rdoc/generators/xml_generator.rb trunk/lib/rdoc/rdoc.rb trunk/lib/shell/command-processor.rb Log: Mon Dec 24 23:04:57 2007 NAKAMURA, Hiroshi <nahi@r...> * lib/ftools.rb: removed obsoleted lib. use fileutils instead (by eban). * lib/rdoc/rdoc.rb, lib/rdoc/generators/*, lib/rake.rb: let it use fileutils instead of ftools. * lib/shell/command-processor.rb: removed unused references to ftools. * lib/parsedate.rb: removed. see [ruby-core:12535], [ruby-dev:31969]. * lib/README: updated. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/generators/xml_generator.rb?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/parsedate.rb http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rake.rb?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/shell/command-processor.rb?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/generators/ri_generator.rb?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/ftools.rb http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/README?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/rdoc.rb?r1=14610&r2=14609 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/rdoc/generators/html_generator.rb?r1=14610&r2=14609 Index: ChangeLog =================================================================== --- ChangeLog (revision 14609) +++ ChangeLog (revision 14610) @@ -1,3 +1,16 @@ +Mon Dec 24 23:04:57 2007 NAKAMURA, Hiroshi <nahi@r...> + + * lib/ftools.rb: removed obsoleted lib. use fileutils instead (by eban). + + * lib/rdoc/rdoc.rb, lib/rdoc/generators/*, lib/rake.rb: let it use + fileutils instead of ftools. + + * lib/shell/command-processor.rb: removed unused references to ftools. + + * lib/parsedate.rb: removed. see [ruby-core:12535], [ruby-dev:31969]. + + * lib/README: updated. + Mon Dec 24 23:01:04 2007 Tanaka Akira <akr@f...> * lib/open-uri.rb (OpenURI::Buffer): use Meta ===. [ruby-core:14295] Index: lib/ftools.rb =================================================================== --- lib/ftools.rb (revision 14609) +++ lib/ftools.rb (revision 14610) @@ -1,261 +0,0 @@ -# -# = ftools.rb: Extra tools for the File class -# -# Author:: WATANABE, Hirofumi -# Documentation:: Zachary Landau -# -# This library can be distributed under the terms of the Ruby license. -# You can freely distribute/modify this library. -# -# It is included in the Ruby standard library. -# -# == Description -# -# ftools adds several (class, not instance) methods to the File class, for -# copying, moving, deleting, installing, and comparing files, as well as -# 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 -# -# When you -# -# require 'ftools' -# -# then the File class aquires some utility methods for copying, moving, and -# deleting files, and more. -# -# See the method descriptions below, and consider using FileUtils as it is -# more comprehensive. -# -class File -end - -class << File - - BUFSIZE = 8 * 1024 - - # - # 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+. - # - def catname(from, to) - if directory? to - join to.sub(%r([/\\]$), ''), basename(from) - else - to - end - end - - # - # Copies a file +from+ to +to+. If +to+ is a directory, copies +from+ - # to <tt>to/from</tt>. - # - def syscopy(from, to) - to = catname(from, to) - - fmode = stat(from).mode - tpath = to - not_exist = !exist?(tpath) - - from = open(from, "rb") - to = open(to, "wb") - - begin - while true - to.syswrite from.sysread(BUFSIZE) - end - rescue EOFError - ret = true - rescue - ret = false - ensure - to.close - from.close - end - chmod(fmode, tpath) if not_exist - ret - end - - # - # Copies a file +from+ to +to+ using #syscopy. If +to+ is a directory, - # copies +from+ to <tt>to/from</tt>. If +verbose+ is true, <tt>from -> to</tt> - # is printed. - # - def copy(from, to, verbose = false) - $stderr.print from, " -> ", catname(from, to), "\n" if verbose - syscopy from, to - end - - alias cp copy - - # - # Moves a file +from+ to +to+ using #syscopy. If +to+ is a directory, - # copies from +from+ to <tt>to/from</tt>. If +verbose+ is true, <tt>from -> - # to</tt> is printed. - # - def move(from, to, verbose = false) - to = catname(from, to) - $stderr.print from, " -> ", to, "\n" if verbose - - if RUBY_PLATFORM =~ /djgpp|(cyg|ms|bcc)win|mingw/ and file? to - unlink to - end - fstat = stat(from) - begin - rename from, to - rescue - begin - symlink readlink(from), to and unlink from - rescue - from_stat = stat(from) - syscopy from, to and unlink from - utime(from_stat.atime, from_stat.mtime, to) - begin - chown(fstat.uid, fstat.gid, to) - rescue - end - end - end - end - - alias mv move - - # - # Returns +true+ if and only if the contents of files +from+ and +to+ are - # identical. If +verbose+ is +true+, <tt>from <=> to</tt> is printed. - # - def compare(from, to, verbose = false) - $stderr.print from, " <=> ", to, "\n" if verbose - - return false if stat(from).size != stat(to).size - - from = open(from, "rb") - to = open(to, "rb") - - ret = false - fr = tr = '' - - begin - while fr == tr - fr = from.read(BUFSIZE) - if fr - tr = to.read(fr.size) - else - ret = to.read(BUFSIZE) - ret = !ret || ret.length == 0 - break - end - end - rescue - ret = false - ensure - to.close - from.close - end - ret - end - - alias cmp compare - - # - # Removes a list of files. Each parameter should be the name of the file to - # delete. If the last parameter isn't a String, verbose mode will be enabled. - # Returns the number of files deleted. - # - def safe_unlink(*files) - verbose = if files[-1].is_a? String then false else files.pop end - files.each do |file| - begin - unlink file - $stderr.print "removing ", file, "\n" if verbose - rescue Errno::EACCES # for Windows - continue if symlink? file - begin - mode = stat(file).mode - o_chmod mode | 0200, file - unlink file - $stderr.print "removing ", file, "\n" if verbose - rescue - o_chmod mode, file rescue nil - end - rescue - end - end - end - - alias rm_f safe_unlink - - # - # Creates a directory and all its parent directories. - # For example, - # - # File.makedirs '/usr/lib/ruby' - # - # causes the following directories to be made, if they do not exist. - # * /usr - # * /usr/lib - # * /usr/lib/ruby - # - # You can pass several directories, each as a parameter. If the last - # parameter isn't a String, verbose mode will be enabled. - # - def makedirs(*dirs) - verbose = if dirs[-1].is_a? String then false else dirs.pop end - mode = 0755 - for dir in dirs - parent = dirname(dir) - next if parent == dir or directory? dir - makedirs parent unless directory? parent - $stderr.print "mkdir ", dir, "\n" if verbose - if basename(dir) != "" - begin - Dir.mkdir dir, mode - rescue SystemCallError - raise unless directory? dir - end - end - end - end - - alias mkpath makedirs - - alias o_chmod chmod - - vsave, $VERBOSE = $VERBOSE, false - - # - # Changes permission bits on +files+ to the bit pattern represented - # by +mode+. If the last parameter isn't a String, verbose mode will - # be enabled. - # - # File.chmod 0755, 'somecommand' - # File.chmod 0644, 'my.rb', 'your.rb', true - # - def chmod(mode, *files) - verbose = if files[-1].is_a? String then false else files.pop end - $stderr.printf "chmod %04o %s\n", mode, files.join(" ") if verbose - o_chmod mode, *files - end - $VERBOSE = vsave - - # - # If +src+ is not the same as +dest+, copies it and changes the permission - # mode to +mode+. If +dest+ is a directory, destination is <tt>dest/src</tt>. - # If +mode+ is not set, default is used. If +verbose+ is set to true, the - # name of each file copied will be printed. - # - def install(from, to, mode = nil, verbose = false) - to = catname(from, to) - unless exist? to and cmp from, to - safe_unlink to if exist? to - cp from, to, verbose - chmod mode, to, verbose if mode - end - end - -end - -# vi:set sw=2: Index: lib/parsedate.rb =================================================================== --- lib/parsedate.rb (revision 14609) +++ lib/parsedate.rb (revision 14610) @@ -1,53 +0,0 @@ -# -# = parsedate.rb: Parses dates -# -# Author:: Tadayoshi Funaba -# Documentation:: Konrad Meyer -# -# ParseDate munches on a date and turns it into an array of values. -# - -# -# ParseDate converts a date into an array of values. -# For example: -# -# require 'parsedate' -# -# ParseDate.parsedate "Tuesday, July 6th, 2007, 18:35:20 UTC" -# # => [2007, 7, 6, 18, 35, 20, "UTC", 2] -# -# The order is of the form [year, month, day of month, hour, minute, second, -# timezone, day of the week]. - -require 'date/format' - -module ParseDate - # - # Parse a string representation of a date into values. - # For example: - # - # require 'parsedate' - # - # ParseDate.parsedate "Tuesday, July 5th, 2007, 18:35:20 UTC" - # # => [2007, 7, 5, 18, 35, 20, "UTC", 2] - # - # The order is of the form [year, month, day of month, hour, minute, - # second, timezone, day of week]. - # - # ParseDate.parsedate can also take a second argument, +comp+, which - # is a boolean telling the method to compensate for dates with years - # expressed as two digits. Example: - # - # require 'parsedate' - # - # ParseDate.parsedate "Mon Dec 25 00 06:53:24 UTC", true - # # => [2000, 12, 25, 6, 53, 24, "UTC", 1] - # - def parsedate(str, hints={}) - Date._parse(str, hints). - values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday) - end - - module_function :parsedate - -end Index: lib/rdoc/generators/ri_generator.rb =================================================================== --- lib/rdoc/generators/ri_generator.rb (revision 14609) +++ lib/rdoc/generators/ri_generator.rb (revision 14610) @@ -34,8 +34,6 @@ # HTML is generated using the Template class. # -require 'ftools' - require 'rdoc/options' require 'rdoc/template' require 'rdoc/markup/simple_markup' Index: lib/rdoc/generators/xml_generator.rb =================================================================== --- lib/rdoc/generators/xml_generator.rb (revision 14609) +++ lib/rdoc/generators/xml_generator.rb (revision 14610) @@ -1,6 +1,4 @@ -require 'ftools' - require 'rdoc/options' require 'rdoc/markup/simple_markup' require 'rdoc/markup/simple_markup/to_html' Index: lib/rdoc/generators/html_generator.rb =================================================================== --- lib/rdoc/generators/html_generator.rb (revision 14609) +++ lib/rdoc/generators/html_generator.rb (revision 14610) @@ -34,7 +34,7 @@ # HTML is generated using the Template class. # -require 'ftools' +require 'fileutils' require 'rdoc/options' require 'rdoc/template' @@ -1025,7 +1025,7 @@ def create_source_code_file(code_body) meth_path = @html_class.path.sub(/\.html$/, '.src') - File.makedirs(meth_path) + FileUtils.mkdir_p(meth_path) file_path = File.join(meth_path, @seq) + ".html" template = TemplatePage.new(RDoc::Page::SRC_PAGE) @@ -1235,7 +1235,8 @@ # directory structure def gen_sub_directories - File.makedirs(FILE_DIR, CLASS_DIR) + FileUtils.mkdir_p(FILE_DIR) + FileUtils.mkdir_p(CLASS_DIR) rescue $stderr.puts $!.message exit 1 @@ -1289,7 +1290,7 @@ list.each do |item| if item.document_self op_file = item.path - File.makedirs(File.dirname(op_file)) + FileUtils.mkdir_p(File.dirname(op_file)) File.open(op_file, "w") { |file| item.write_on(file) } end end Index: lib/rdoc/rdoc.rb =================================================================== --- lib/rdoc/rdoc.rb (revision 14609) +++ lib/rdoc/rdoc.rb (revision 14610) @@ -15,7 +15,7 @@ require 'rdoc/diagram' require 'find' -require 'ftools' +require 'fileutils' require 'time' # We put rdoc stuff in the RDoc module to avoid namespace @@ -125,7 +125,7 @@ last = (Time.parse(created) unless force rescue nil) end else - File.makedirs(op_dir) + FileUtils.mkdir_p(op_dir) end last end Index: lib/shell/command-processor.rb =================================================================== --- lib/shell/command-processor.rb (revision 14609) +++ lib/shell/command-processor.rb (revision 14610) @@ -11,7 +11,6 @@ # require "e2mmap" -require "ftools" require "thread" require "shell/error" @@ -589,24 +588,6 @@ def_builtin_commands(FileTest, FileTest.singleton_methods(false).collect{|m| [m, ["FILENAME"]]}) -# # method related ftools -# normal_delegation_ftools_methods = [ -# ["syscopy", ["FILENAME_FROM", "FILENAME_TO"]], -# ["copy", ["FILENAME_FROM", "FILENAME_TO"]], -# ["move", ["FILENAME_FROM", "FILENAME_TO"]], -# ["compare", ["FILENAME_FROM", "FILENAME_TO"]], -# ["safe_unlink", ["*FILENAMES"]], -# ["makedirs", ["*FILENAMES"]], -# # ["chmod", ["mode", "*FILENAMES"]], -# ["install", ["FILENAME_FROM", "FILENAME_TO", "mode"]], -# ] -# def_builtin_commands(File, -# normal_delegation_ftools_methods) -# alias_method :cmp, :compare -# alias_method :mv, :move -# alias_method :cp, :copy -# alias_method :rm_f, :safe_unlink -# alias_method :mkpath, :makedirs end end Index: lib/rake.rb =================================================================== --- lib/rake.rb (revision 14609) +++ lib/rake.rb (revision 14610) @@ -32,7 +32,6 @@ RAKEVERSION = '0.8.0' require 'rbconfig' -require 'ftools' require 'getoptlong' require 'fileutils' require 'singleton' Index: lib/README =================================================================== --- lib/README (revision 14609) +++ lib/README (revision 14610) @@ -16,14 +16,11 @@ finalize.rb adds finalizer to the object find.rb traverses directory tree forwardable.rb explicit delegation library -ftools.rb file tools getoptlong.rb GNU getoptlong compatible -getopts.rb parses command line options (use getoptlong) gserver.rb general TCP server ipaddr.rb defines the IPAddr class irb.rb interactive ruby logger.rb simple logging utility -mailread.rb reads mail headers mathn.rb extended math operation matrix.rb matrix calculation library mkmf.rb Makefile maker @@ -41,7 +38,6 @@ open3.rb opens subprocess connection stdin/stdout/stderr optparse.rb command line option analysis ostruct.rb python style object -parsearg.rb argument parser using getopts parsedate.rb parses date string (obsolete) pathname.rb Object-Oriented Pathname Class pp.rb pretty print objects @@ -55,13 +51,11 @@ resolv-replace.rb replace Socket DNS by resolve.rb resolv.rb DNS resolver in Ruby rexml an XML parser for Ruby, in Ruby -rubyunit.rb original Ruby Unit testing framework scanf.rb scanf for Ruby set.rb defines the Set class shell.rb runs commands and does pipeline operations like shell shellwords.rb split into words like shell singleton.rb singleton design pattern library -soap SOAP 1.1 implementation sync.rb 2 phase lock tempfile.rb temporary file with automatic removal test/unit Ruby Unit Testing Framework @@ -81,7 +75,5 @@ uri/mailto.rb mailto scheme support weakref.rb weak reference class webrick.rb WEB server toolkit -wsdl WSDL 1.1 implementation xmlrpc XML-RPC implementation -xsd XML Schema Datatypes implementation yaml.rb YAML implementation -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml