lib/rio/rl/builder.rb in rio-0.3.7 vs lib/rio/rl/builder.rb in rio-0.3.8
- old
+ new
@@ -1,8 +1,8 @@
#--
# ===============================================================================
-# Copyright (c) 2005, Christopher Kleckner
+# Copyright (c) 2005, 2006 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
@@ -20,11 +20,11 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ===============================================================================
#++
#
# To create the documentation for Rio run the command
-# rake rdoc
+# ruby build_doc.rb
# from the distribution directory. Then point your browser at the 'doc/rdoc' directory.
#
# Suggested Reading
# * RIO::Doc::SYNOPSIS
# * RIO::Doc::INTRO
@@ -45,10 +45,11 @@
class Builder
def self.build(*a)
#puts "build: #{a.inspect}"
a.flatten!
+ a.push('') if a.empty?
case a[0]
when ::String
case a[0]
when /^[a-zA-Z]:/
a[0] = 'rio:file:///'+a[0]
@@ -63,20 +64,31 @@
return Factory.instance.riorl_class('path').new(*a)
end
when RIO::Rio
a[0] = a[0].to_rl
when RL::Base
- a0 = a.shift
+ a0 = a.shift.clone
+ return (a.empty? ? a0 : a0.join(*a))
#p 'THERE',a0,a0.clone
- return a0.clone
+ #return a0.clone.join(*a)
#return a0.class.new(a0.clone,*a)
when ::URI
a0 = a.shift
cl = Factory.instance.riorl_class(a0.scheme)
o = cl.new(a0,*a) unless cl.nil?
return o
when ::Symbol
- a[0] = 'rio:' + a[0].to_s + ':'
+ case a[0]
+ when :zpath
+ a0 = a.shift
+ cl = Factory.instance.riorl_class(a0.to_s)
+ o = cl.new(*a) unless cl.nil?
+ return o
+ else
+ a[0] = 'rio:' + a[0].to_s + ':'
+ end
+ when ::NilClass
+ a[0] = 'rio:null:'
when ?? , ?= , ?_ , ?", ?[, ?#, ?`, ?|
a[0] = 'rio:'+CHMAP[a[0]]+':'
when ?-
a[0] = ( a.size == 1 ? 'rio:'+CHMAP[a[0]]+':' : 'rio:cmdio:' )
when ?$