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, #initialize_copy, is_riorl?, #length, parse, #rl, split_riorl, subscheme, #to_rl, #to_s, #url

Constructor Details

#initialize(zipfilepath, infilepath = nil) ⇒ RL

Returns a new instance of RL.



39
40
41
42
43
44
45
46
47
48
# File 'lib/rio/ext/zipfile/rl.rb', line 39

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.



38
39
40
# File 'lib/rio/ext/zipfile/rl.rb', line 38

def infilepath
  @infilepath
end

#zipfilepathObject (readonly)

Returns the value of attribute zipfilepath.



38
39
40
# File 'lib/rio/ext/zipfile/rl.rb', line 38

def zipfilepath
  @zipfilepath
end

Class Method Details

.splitrl(s) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/rio/ext/zipfile/rl.rb', line 95

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



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

def base(*args) 
  '' 
end

#closeObject



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

def close()
end

#file_rlObject



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

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

#fspathObject



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

def fspath()
  @infilepath
end

#opaqueObject



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

def opaque()
  @uri.to_s
end

#openObject



55
56
57
# File 'lib/rio/ext/zipfile/rl.rb', line 55

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

#openfs_Object



52
53
54
# File 'lib/rio/ext/zipfile/rl.rb', line 52

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

#pathObject



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

def path()
  @infilepath
end

#path_no_slashObject



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

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

#schemeObject

def path() nil end



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

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

#urlpathObject



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

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

#urlpath=(arg) ⇒ Object



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

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