lib/rio/rl/builder.rb in rio-0.3.8 vs lib/rio/rl/builder.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,31 +21,32 @@
# ===============================================================================
#++
#
# 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 'uri'
require 'rio/local'
require 'rio/rl/base'
require 'stringio'
module RIO
module RL
class Builder
-
+ def self.build_path_rl(rl)
+ return rl
+ end
def self.build(*a)
#puts "build: #{a.inspect}"
a.flatten!
a.push('') if a.empty?
case a[0]
@@ -62,17 +63,19 @@
return Factory.instance.riorl_class('file').new(*a)
else
return Factory.instance.riorl_class('path').new(*a)
end
when RIO::Rio
- a[0] = a[0].to_rl
+ a[0] = a[0].rl
+ return build(*a)
when RL::Base
+ #p "HERE a=#{a.inspect}"
a0 = a.shift.clone
- return (a.empty? ? a0 : a0.join(*a))
- #p 'THERE',a0,a0.clone
- #return a0.clone.join(*a)
- #return a0.class.new(a0.clone,*a)
+ cl = Factory.instance.riorl_class(a0.scheme)
+ o = cl.new(a0,*a) unless cl.nil?
+ return o
+ # return (a.empty? ? a0 : a0.join(*a))
when ::URI
a0 = a.shift
cl = Factory.instance.riorl_class(a0.scheme)
o = cl.new(a0,*a) unless cl.nil?
return o
@@ -86,11 +89,11 @@
else
a[0] = 'rio:' + a[0].to_s + ':'
end
when ::NilClass
a[0] = 'rio:null:'
- when ?? , ?= , ?_ , ?", ?[, ?#, ?`, ?|
+ when ?? , ?= , ?_ , ?", ?[, ?#, ?`, ?|, ?z
a[0] = 'rio:'+CHMAP[a[0]]+':'
when ?-
a[0] = ( a.size == 1 ? 'rio:'+CHMAP[a[0]]+':' : 'rio:cmdio:' )
when ?$
a[0] = 'rio:strio:'
@@ -105,36 +108,9 @@
a0 = a.shift
sch = Base.subscheme(a0)
cl = Factory.instance.riorl_class(sch)
cl.parse(a0,*a) unless cl.nil?
- end
-
-
- def self.build0(*args)
- #p "build(#{args.inspect})"
-
- # aryio is a special case -- must not flatten
- if args[0] == 'rio:aryio'
- args.shift
- ary = args[0] unless args.empty?
- require 'rio/scheme/aryio'
- return RIO::AryIO::RL.new(ary)
- end
-
- args = canon(args.flatten)
- a0 = args.shift
- case a0
- when RL::Base
- a0.class.new(a0.uri.dup,*args)
- when ::URI
- cl = Factory.instance.riorl_class(a0.scheme)
- cl.new(a0,*args) unless cl.nil?
- else
- sch = Base.subscheme(a0)
- cl = Factory.instance.riorl_class(sch)
- cl.parse(a0,*args) unless cl.nil?
- end
end
end
end
end