Module: WDav

Defined in:
lib/webdavtools/wdav_cd.rb,
lib/webdavtools/wdav_ls.rb

Class Method Summary collapse

Class Method Details

.cd(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/webdavtools/wdav_cd.rb', line 11

def self.cd(args)
  url = args[0]
  if(url =~ /^http/)then
    set_cwurl(url)
  else
    if(url)then
       if(url == "..")then
        # TODO: Standard-lib 'File' class can handle
        # proabably handle cd ../.. etc. better
        url = WebDAV.CWURL.sub(/[^\/]*\/$/, "")
         set_cwurl(url)
      else
        url = WebDAV.CWURL + url
        set_cwurl(url)
      end
    else
      puts "usage: "
    end
  end
end

.ls(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/webdavtools/wdav_ls.rb', line 11

def self.ls(args)
  options = read_options(args)
  url = args[0]
  if(not url)then
    url = WebDAV.CWURL
    if(not url)then
      puts "wdav ls: no current working url"
      puts "Usage: Use 'wdav open url' or 'wdav cd [url|dir] to set current working url"
      exit
    end
  else
    WebDAV.CWURL = url
  end

  WebDAV.find(url, :recursive => false ) do |item|
    if(options[:showUrl])then
      puts item.href
    elsif(options[:longFormat])

    else
      print item.basename
      print "/" if item.isCollection?
      puts
    end
  end
end