class ASF::EmeritusFiles
Public Class Methods
Source
# File lib/whimsy/asf/documents.rb, line 235 def self.extractfilename(fileurl) return nil unless fileurl root_url = ASF::SVN.svnurl(@base) + '/' extractfilenamefrom(root_url, fileurl) end
Extract the file name if it is in emeritus directory nil if it is not in this directory
Source
# File lib/whimsy/asf/documents.rb, line 222 def self.extractfilenamefrom(rooturl, fileurl) return nil unless fileurl # does the root match the file url? index = fileurl.index(rooturl) return nil unless index.zero? # root matches, return file name (end of fileurl) fileurl[rooturl.length..-1] end
Extract the file name from an svn url param rooturl the svn url of the directory param fileurl the svn url of the complete file return the file name or nil if the file is not in the directory
Source
# File lib/whimsy/asf/documents.rb, line 181 def self.find(person, getDate=false) # TODO use common stem name method name = (person.attrs['cn'].first rescue person.member_name).force_encoding('utf-8'). downcase.gsub(' ', '-').gsub(/[^a-z0-9-]+/, '') rescue nil id = person.id files = self.listnames(getDate).find_all do |file| if file.is_a?(Array) # we have [epoch, file] file = file[1] end stem = file.split('.')[0] # directories don't have a trailing / stem == id or stem == name end # Only valid if we match a single file or directory if files.length == 1 files.first else nil end end
Find the file name that matches a person return nil if not exactly one match TODO: should it raise an error on multiple matches?
Source
# File lib/whimsy/asf/documents.rb, line 211 def self.findpath(person) path = nil file = find(person) path = svnpath!(file) if file [path, file] end
Find the svnpath to the file for a person Returns svnpath, filename or nil, nil if not found
Source
# File lib/whimsy/asf/documents.rb, line 173 def self.listnames(getDates=false) _, list = ASF::SVN.getlisting(@base, nil, true, getDates) list end
Source
# File lib/whimsy/asf/documents.rb, line 202 def self.svnpath!(file) ASF::SVN.svnpath!(@base, file) end
return the svn path to an arbitrary file