class ASF::ICLAFiles::EmeritusFiles

Public Class Methods

extractfilename(fileurl) click to toggle source

Extract the file name if it is in emeritus directory nil if it is not in this directory

# File lib/whimsy/asf/documents.rb, line 187
def self.extractfilename(fileurl)
  return nil unless fileurl

  root_url = ASF::SVN.svnurl(@base) + '/'
  extractfilenamefrom(root_url, fileurl)
end
extractfilenamefrom(rooturl, fileurl) click to toggle source

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

# File lib/whimsy/asf/documents.rb, line 174
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
find(person, getDate=false) click to toggle source

Find the file name that matches a person return nil if not exactly one match TODO: should it raise an error on multiple matches?

# File lib/whimsy/asf/documents.rb, line 133
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
findpath(person) click to toggle source

Find the svnpath to the file for a person Returns svnpath, filename or nil, nil if not found

# File lib/whimsy/asf/documents.rb, line 163
def self.findpath(person)
  path = nil
  file = find(person)
  path = svnpath!(file) if file
  [path, file]
end
listnames(getDates=false) click to toggle source
# File lib/whimsy/asf/documents.rb, line 125
def self.listnames(getDates=false)
  _, list = ASF::SVN.getlisting(@base, nil, true, getDates)
  list
end
svnpath!(file) click to toggle source

return the svn path to an arbitrary file

# File lib/whimsy/asf/documents.rb, line 154
def self.svnpath!(file)
  ASF::SVN.svnpath!(@base, file)
end