lib/rio/ops/either.rb in rio-0.4.2 vs lib/rio/ops/either.rb in rio-0.5.1

- old
+ new

@@ -1,8 +1,8 @@ #-- -# =============================================================================== -# Copyright (c) 2005,2006,2007,2008 Christopher Kleckner +# =========================================================================== +# Copyright (c) 2005-2012 Christopher Kleckner # All rights reserved # # This file is part of the Rio library for ruby. # # Rio is free software; you can redistribute it and/or modify @@ -16,27 +16,16 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Rio; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# =============================================================================== +# =========================================================================== #++ # -# To create the documentation for Rio run the command -# ruby build_doc.rb -# from the distribution directory. -# -# Suggested Reading -# * RIO::Doc::SYNOPSIS -# * RIO::Doc::INTRO -# * RIO::Doc::HOWTO -# * RIO::Doc::EXAMPLES -# * RIO::Rio -# -require 'rio/exception' +#require 'rio/exception' require 'fileutils' module RIO module Impl module U def self.mv(s,d) @@ -69,42 +58,50 @@ def rename(*args,&block) if args.empty? softreset.rename(*args,&block) else rtn_reset { - dst = ensure_rio(args.shift) + dst = args.shift.to_s #p "rename: #{self} => #{dst}" - fs.mv(self,dst,*args) - dst.reset + fs.mv(uri.path,dst,*args) unless uri.path == dst } end end def rename!(*args,&block) if args.empty? softreset.rename(*args,&block) else rtn_reset { - dst = ensure_rio(args.shift) - #p "rename!: #{self} => #{dst}" - fs.mv(self,dst,*args) unless self == dst - dst.reset - self.rl = dst.rl.clone + cpath = uri.path + uri.path = args.shift.to_s + #p "rename!: #{cpath} => #{uri.path}" + fs.mv(cpath,uri.path,*args) unless uri.path == cpath } end end alias :mv :rename - def basename=(arg) - rename!(_path_with_basename(arg)) + def dirname=(arg) + dst = ::Alt::URI.create(path: uri.path) + dst.dirname = arg.to_s + rename!(dst.path) end def filename=(arg) - rename!(_path_with_filename(arg)) + dst = ::Alt::URI.create(path: uri.path) + dst.filename = arg.to_s + rename!(dst.path) end - def extname=(ex) - rename!(_path_with_ext(ex)) - cx['ext'] = ex + def basename=(arg) + dst = ::Alt::URI.create(path: uri.path) + dst.ext = cx['ext'] if cx.has_key?('ext') + dst.basename = arg.to_s + rename!(dst.path) end - def dirname=(arg) - rename!(_path_with_dirname(arg)) + def extname=(arg) + dst = ::Alt::URI.create(path: uri.path) + dst.ext = cx['ext'] if cx.has_key?('ext') + dst.extname = arg.to_s + rename!(dst.path) + cx['ext'] = arg end def ss_type? case cx['ss_type'] when nil