class ASF::ICLAFiles

Common class for access to documents/iclas/ directory Only intended for use by secretary team

Constants

STEM

Public Class Methods

Dir?(name) click to toggle source

is the name a directory?

# File lib/whimsy/asf/documents.rb, line 136
def self.Dir?(name)
  listnames.include? name + '/'
end
listnames() click to toggle source

This returns the list of names in the top-level directory directory names are terminated by ‘/’

# File lib/whimsy/asf/documents.rb, line 155
def self.listnames
  # iclas.txt no longer updated by cronjob
  cache_dir = ASF::DocumentUtils.check_cache(STEM).first
  @@tag, list = ASF::SVN.getlisting(STEM, @@tag, false, false, cache_dir)
  if list # we have a new list
    # update the list cache
    @@list = list
    # clear the hash caches
    @@h_claRef = nil
    @@h_stem = nil
  end
  @@list
end
matchStem(stem) click to toggle source

return a list of names matching stem.* Does not return directories

# File lib/whimsy/asf/documents.rb, line 142
def self.matchStem(stem)
  unless @@h_stem
    h_stem = Hash.new {|h, k| h[k] = []}
    listnames.map do |l|
      h_stem[l.split('.')[0]] << l unless l.end_with?('/')
    end
    @@h_stem = h_stem
  end
  @@h_stem[stem]
end
match_claRef(claRef) click to toggle source

search icla files to find match with claRef matches if the input matches the full name of a file or directory or it matches with an extension Returns the basename or nil if no match

# File lib/whimsy/asf/documents.rb, line 117
def self.match_claRef(claRef)
  unless @@h_claRef
    h_claRef = {}
    listnames.map do |l|
      # Match either full name (e.g. directory) or stem (e.g. name.pdf)
      if l.end_with? '/'
        h_claRef[l.chomp('/')] = l.chomp('/')
      elsif l.include?('.')
        h_claRef[l.split('.')[0]] = l
      else
        h_claRef[l] = l
      end
    end
    @@h_claRef = h_claRef
  end
  @@h_claRef[claRef]
end
update_cache(env) click to toggle source
# File lib/whimsy/asf/documents.rb, line 109
def self.update_cache(env)
  ASF::DocumentUtils.update_cache(STEM, env)
end