lib/rio/rl/base.rb in rio-0.3.8 vs lib/rio/rl/base.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,104 +21,47 @@ # =============================================================================== #++ # # 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/uri/file' -#require 'extensions/class' +require 'rio/rl/chmap' +require 'rio/rl/fs2url' module RIO module RL - CHMAP = { - '_' => 'sysio', - '-' => 'stdio', - '=' => 'stderr', - '"' => 'strio', - '?' => 'temp', - '[' => 'aryio', - '`' => 'cmdio', - '|' => 'cmdpipe', - '#' => 'fd', - ?_ => 'sysio', - ?- => 'stdio', - ?= => 'stderr', - ?" => 'strio', - ?? => 'temp', - ?[ => 'aryio', - ?` => 'cmdio', - ?| => 'cmdpipe', - ?# => 'fd', - }.freeze - end -end -module RIO - module RL #:nodoc: all - PESCAPE = Regexp.new("[^-_.!~*'()a-zA-Z0-9;?:@&=+$,]",false, 'N').freeze - ESCAPE = Regexp.new("[^-_.!~*'()a-zA-Z0-9;\/?:@&=+$,]",false, 'N').freeze - def escape(pth,esc=ESCAPE) - ::URI.escape(pth,esc) - end - def unescape(pth) - ::URI.unescape(pth) - end - def fs2url(pth) - #pth.sub!(/^[a-zA-Z]:/,'') - pth = URI.escape(pth,ESCAPE) - pth = '/' + pth if pth =~ /^[a-zA-Z]:/ - pth - # (Local::SEPARATOR == '/' ? pth : pth.gsub(Local::SEPARATOR,%r|/|)) - end - - def url2fs(pth) -# pth = pth.chop if pth.length > 1 and pth[-1] == ?/ cwd = RIO::RL.fs2url(::Dir.getwd) - - #pth = pth.chop if pth != '/' and pth[-1] == ?/ - pth = ::URI.unescape(pth) - if pth =~ %r#^/[a-zA-Z]:# - pth = pth[1..-1] - end - pth -# (Local::SEPARATOR == '/' ? pth : pth.gsub(%r|/|,Local::SEPARATOR)) - end - - def getwd() - #::URI::FILE.build({:path => fs2url(::Dir.getwd)+'/'}) - ::URI::FILE.build({:path => fs2url(::Dir.getwd)}) - end - - module_function :url2fs,:fs2url,:getwd,:escape,:unescape - end -end -module RIO - module RL - SCHEME = 'rio' SCHC = SCHEME+':' SPLIT_RIORL_RE = %r{\A([a-z][a-z]+)(?:(:)(.*))?\Z}.freeze SUBSEPAR = ':' class Base - attr :fs + attr_accessor :fs def initialize(*args) + #p callstr('Base#initialize',*args) @fs = openfs_ end - def openfs_() nil end + def initialize_copy(cp) + super + end + def openfs_() + nil + end def self.subscheme(s) /^rio:([^:]+):/.match(s)[1] end def self.split_riorl(s) @@ -151,10 +94,13 @@ def path() nil end def to_rl() self.rl end def url() self.scheme+SUBSEPAR+self.opaque end - def close() nil end + def close() + #p "Closing RL #{self}" + nil + end def fs2url(pth) RL.fs2url(pth) end def url2fs(pth) RL.url2fs(pth) end def escape(pth,esc=RL::ESCAPE) RL.escape(pth,esc)