lib/rio/ops/path.rb in rio-0.3.8 vs lib/rio/ops/path.rb in rio-0.3.9
- old
+ new
@@ -1,8 +1,8 @@
#--
# ===============================================================================
-# Copyright (c) 2005, 2006 Christopher Kleckner
+# Copyright (c) 2005,2006,2007 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
@@ -21,20 +21,19 @@
# ===============================================================================
#++
#
# To create the documentation for Rio run the command
# ruby build_doc.rb
-# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
+# from the distribution directory.
#
# Suggested Reading
# * RIO::Doc::SYNOPSIS
# * RIO::Doc::INTRO
# * RIO::Doc::HOWTO
+# * RIO::Doc::EXAMPLES
# * RIO::Rio
#
-# <b>Rio is pre-alpha software.
-# The documented interface and behavior is subject to change without notice.</b>
#require 'rio/impl/path'
module RIO
module Ops #:nodoc: all
@@ -84,11 +83,13 @@
def abs(base=nil)
if base.nil?
nrio = new_rio(rl.abs)
nrio
else
- new_rio(rl,ensure_rio(base).abs.to_uri).abs
+ #new_rio(rl,{:base => ensure_rio(base).abs.to_uri}).abs
+ brio = ensure_rio(base)
+ new_rio(rl.abs(ensure_rio(base).to_s))
end
end
def abs?
rl.abs?
end
@@ -104,25 +105,18 @@
end
base = other.nil? ? self.abs : ensure_rio(other).dup
base += '/' if base.directory? and base.to_s[-1] != '/'
route_from(base)
end
-# def rel(other=nil)
-# if other.nil?
-# route_from(other)
-# else
-# route_from(base.to_url + '/')
-# end
-# end
def route_to(other)
new_rio(rl.abs.route_to(ensure_rio(other).rl.abs))
end
def merge(other)
new_rio(rl.merge(ensure_rio(other).rl))
end
- def base(b=nil)
- new_rio(rl.base(b))
+ def base()
+ new_rio(rl.base())
end
def setbase(b)
rl.base(b)
self
end
@@ -137,42 +131,27 @@
end
def extname(*args)
en = fs.extname(rl.path_no_slash,*args)
(en.empty? ? nil : en)
end
- def split()
+ def splitpath()
require 'rio/to_rio'
parts = self.rl.split
# map to rios and extend the array with to_array
parts.map { |arl| new_rio(arl) }.extend(ToRio::Array)
end
def basename(*args)
unless args.empty?
ex = args[0] || self.extname
self.ext(ex)
end
- #p self.ext?.inspect
- fn = fs.basename(rl.path_no_slash,self.ext?)
- new_rio(fn,{:base => _calc_base()})
+ new_rio(rl.basename(self.ext?))
end
def filename()
- fn = fs.basename(rl.path_no_slash)
- new_rio(fn,{:base => _calc_base()})
+ new_rio(rl.filename)
end
- def _calc_base()
- dn = fs.dirname(rl.path_no_slash)
- dn[0] == ?/ ? dn : self.base.to_url + dn + '/' #'
-# if dn[0] == ?/
-# dn
-# else
-# self.base.to_url + dn + '/'
-# end
- end
- private :_calc_base
-
def dirname(*args)
- #new_rio(fs.dirname(rl.path_no_slash,*args))
new_rio(rl.dirname)
end
def sub(re,arg)
new_rio(softreset.to_s.sub(re,arg.to_s))
@@ -224,30 +203,30 @@
def filename=(arg)
if cx['rename']
must_exist.filename = arg
else
- rl.path = _path_with_filename(arg)
+ rl.urlpath = _path_with_filename(arg)
softreset
end
end
def basename=(arg)
if cx['rename']
must_exist.basename = arg
else
- rl.path = _path_with_basename(arg)
+ rl.urlpath = _path_with_basename(arg)
softreset
end
end
def extname=(arg)
#p callstr('extname=',arg)
if cx['rename']
must_exist.extname = arg
else
- rl.path = _path_with_ext(arg)
+ rl.urlpath = _path_with_ext(arg)
softreset
end
end
def dirname=(arg)