lib/rio/rl/builder.rb in rio-0.4.2 vs lib/rio/rl/builder.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,29 +16,19 @@ # 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 'uri' +require 'rio/alturi' require 'rio/local' require 'rio/rl/base' +require 'rio/rrl/base' require 'stringio' module RIO module RL class Builder @@ -48,36 +38,52 @@ def self.build(*a) #puts "build: #{a.inspect}" a.flatten! a.push('') if a.empty? case a[0] + 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:' when ::String case a[0] when /^[a-zA-Z]:/ a[0] = 'rio:file:///'+a[0] when /^[a-z][a-z]+:/ a[0] = 'rio:'+a[0] unless a[0] =~ /^rio:/ when %r|^//| a[0] = 'rio:file:'+a[0] when %r|^/| - a[0] = 'file://'+a[0] + #a[0] = 'file://'+a[0] + #p "IN BUILDER #{a.inspect}" return Factory.instance.riorl_class('file').new(*a) else return Factory.instance.riorl_class('path').new(*a) end when RIO::Rio + #p "BUILD: a[0]=#{a[0].inspect} a[0].rl=#{a[0].rl.inspect}" a[0] = a[0].rl return build(*a) when RL::Base - #p "HERE a=#{a.inspect}" + #p "BUILD: RL::Base a=#{a.inspect}" a0 = a.shift.clone 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 + when ::RIO::RRL::Base + #p "BUILD: RRL::Base a=#{a.inspect}" + a0 = a.shift.uri + 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 ::Alt::URI::Base a0 = a.shift + #p "SCHEME is #{a0.scheme}" cl = Factory.instance.riorl_class(a0.scheme) o = cl.new(a0,*a) unless cl.nil? return o when ::Symbol case a[0] @@ -89,16 +95,10 @@ else a[0] = 'rio:' + a[0].to_s + ':' end when ::NilClass a[0] = 'rio:null:' - 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:' when ::IO a.unshift('rio:sysio:') when ::StringIO a.unshift('rio:strio:') else @@ -106,9 +106,10 @@ return build(*a) end a0 = a.shift sch = Base.subscheme(a0) cl = Factory.instance.riorl_class(sch) + #p "cl=#{cl}" cl.parse(a0,*a) unless cl.nil? end end