# File lib/davclient/dav-put.rb, line 9 def self.put(args) options = read_options(args) url = args[0] if(options[:string])then # Put string if(!url.match(/^http.*\/\/([^\/]*)/) and !WebDAV.CWURL) raise "Error: No current working url set. Use '#{$0} cd url' to set url." end begin WebDAV.put_string(url,options[:string]) rescue puts $0 + ": " + $! end puts "Published content to: " + url else # Put files(s) # puts "DEBUG: size:" + args.size.to_s if(args.size == 1 ) local_file = args[0] if(not(File.exists?(local_file))) raise "File not found: #{local_file}" end if(!WebDAV.CWURL) raise "Error: No current working url set. Use '#{$0} cd url' to set url." end WebDAV.put(WebDAV.CWURL, local_file) elsif(args.size == 2 and args[1].match(/^http.*\/\/([^\/]*)/) ) local_file = args[0] url = args[1] if(not(File.exists?(local_file))) raise "File not found: #{local_file}" end if(WebDAV.isCollection?(url)) url += File.basename(local_file) end WebDAV.put(url, local_file) else # Put more than one file if(args.last.match(/^http.*\/\/([^\/]*)/) ) url = args.last if(!WebDAV.isCollection?(url)) raise "Destination collection not found: " + url end args = args[0..(args.size-2)] else url = WebDAV.CWURL end count = 0 args.each do | arg| # puts "arg:" + arg if(File.ftype(arg) == 'directory') raise "Upload directories not implemented" end if(File.exists?(arg)) basename = File.basename(arg) WebDAV.put(url + basename, arg) count = count + 1 else raise "Error: File not found " + arg end end puts "Published #{count} files to #{url}" end end end
Generated with the Darkfish Rdoc Generator 2.