Class: RIO::ZipFile::RootDir::RL

Inherits:
RL::Base show all
Includes:
RL::PathMethods
Defined in:
lib/rio/ext/zipfile/rl.rb

Constant Summary collapse

RIOSCHEME =
'zipfile'
RIOPATH =
RIO::RL::CHMAP.invert[RIOSCHEME].to_s.freeze
SPLIT_RE =

USAGE EXAMPLES zroot = rio(‘f.zip’).zipfile

rio(zroot,‘tdir’).mkdir rio(zroot,‘tdir’).mkdir rio(zroot).each {} rio(:zipfile,‘t.zip’,‘tdir’).mkdir rio(‘zipfile:t.zip’,‘tdir’).mkdir rio(‘zipfile:t.zip?tdir’).mkdir rio(?z,‘t.zip?tdir’).mkdir rio(?z,‘t.zip’,‘tdir’).mkdir rio(‘zipfile:file:///tmp/t.zip?tdir’).mkdir

%r|(.+)(?:\?(.+))?$|.freeze

Instance Attribute Summary collapse

Attributes inherited from RL::Base

#fs

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RL::PathMethods

#_parts, #calc_abs_uri_, #dirname, #join, #merge, #parse_url, #pathdepth, #route_from, #route_to, #split, #urlroot

Methods inherited from RL::Base

#==, #===, #=~, #callstr, #escape, #fs2url, #initialize_copy, is_riorl?, #length, parse, #rl, split_riorl, subscheme, #to_rl, #to_s, #unescape, #url, #url2fs

Constructor Details

#initialize(zipfilepath, infilepath = nil) ⇒ RL

Returns a new instance of RL.



51
52
53
54
55
56
57
58
59
60
# File 'lib/rio/ext/zipfile/rl.rb', line 51

def initialize(zipfilepath,infilepath=nil)
  @zipfilepath = zipfilepath
  @uri = URI(@zipfilepath)
  if infilepath
    @infilepath = infilepath
    @uri.query = @infilepath
  end
  @zipfile = ::Zip::ZipFile.new(@zipfilepath,::Zip::ZipFile::CREATE)
  super()
end

Instance Attribute Details

#infilepathObject (readonly)

Returns the value of attribute infilepath.



50
51
52
# File 'lib/rio/ext/zipfile/rl.rb', line 50

def infilepath
  @infilepath
end

#zipfilepathObject (readonly)

Returns the value of attribute zipfilepath.



50
51
52
# File 'lib/rio/ext/zipfile/rl.rb', line 50

def zipfilepath
  @zipfilepath
end

Class Method Details

.splitrl(s) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/rio/ext/zipfile/rl.rb', line 109

def self.splitrl(s)
  sub,opq,whole = split_riorl(s)
  if opq.nil? or opq.empty?
    []
  elsif bm = SPLIT_RE.match(opq)
    zpath = bm[1] unless bm[1].nil? or bm[1].empty?
    ipath = bm[2] unless bm[2].nil? or bm[2].empty?
    [zpath,ipath]
  else
    []
  end
end

Instance Method Details

#base(*args) ⇒ Object



79
80
81
82
# File 'lib/rio/ext/zipfile/rl.rb', line 79

def base(*args) 
  #p "base: #{args.inspect}"
  '' 
end

#closeObject



70
71
72
# File 'lib/rio/ext/zipfile/rl.rb', line 70

def close()
  p "CLOSING ZIPFILE RL"
end

#file_rlObject



61
62
63
# File 'lib/rio/ext/zipfile/rl.rb', line 61

def file_rl
  RIO::File::RL.new(infilepath,{:fs => RIO::ZipFile::InFile::FS.new(@zipfile)})
end

#fspathObject



76
77
78
# File 'lib/rio/ext/zipfile/rl.rb', line 76

def fspath()
  @infilepath
end

#opaqueObject



86
87
88
# File 'lib/rio/ext/zipfile/rl.rb', line 86

def opaque()
  @uri.to_s
end

#openObject



67
68
69
# File 'lib/rio/ext/zipfile/rl.rb', line 67

def open()
  IOH::Dir.new(ZipFile::Wrap::Stream::Root.new(@zipfile))
end

#openfs_Object



64
65
66
# File 'lib/rio/ext/zipfile/rl.rb', line 64

def openfs_()
  RIO::ZipFile::RootDir::FS.new(@zipfile)
end

#pathObject



73
74
75
# File 'lib/rio/ext/zipfile/rl.rb', line 73

def path()
  @infilepath
end

#path_no_slashObject



83
# File 'lib/rio/ext/zipfile/rl.rb', line 83

def path_no_slash() self.path.to_s.sub(/\/$/,'') end

#schemeObject

def path() nil end



85
# File 'lib/rio/ext/zipfile/rl.rb', line 85

def scheme() self.class.const_get(:RIOSCHEME) end

#urlpathObject



90
91
92
93
# File 'lib/rio/ext/zipfile/rl.rb', line 90

def urlpath() 
  return '' unless fspath
  RIO::RL.fs2url(fspath) 
end

#urlpath=(arg) ⇒ Object



94
# File 'lib/rio/ext/zipfile/rl.rb', line 94

def urlpath=(arg) @infilepath = RIO::RL.url2fs(arg) end