1 2 3 4 5 6 7 8 9 10 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
require 'monitor'
require 'base/kpsefast'
class KpseTrees < Monitor
def initialize
@trees = Hash.new
end
def pattern(filenames)
filenames.join('|').gsub(/\\+/o,'/').downcase
end
def choose(filenames,environment)
current = pattern(filenames)
load(filenames,environment) unless @trees[current]
puts "enabling tree #{current}"
current
end
def fetch(filenames,environment) # will send whole object !
current = pattern(filenames)
load(filenames,environment) unless @trees[current]
puts "fetching tree #{current}"
@trees[current]
end
def load(filenames,environment)
current = pattern(filenames)
puts "loading tree #{current}"
@trees[current] = KpseFast.new
@trees[current].push_environment(environment)
@trees[current].load_cnf(filenames)
@trees[current].expand_variables
@trees[current].load_lsr
end
def set(tree,key,value)
case key
when 'progname' then @trees[tree].progname = value
when 'engine' then @trees[tree].engine = value
when 'format' then @trees[tree].format = value
end
end
def get(tree,key)
case key
when 'progname' then @trees[tree].progname
when 'engine' then @trees[tree].engine
when 'format' then @trees[tree].format
end
end
def load_cnf(tree)
@trees[tree].load_cnf
end
def load_lsr(tree)
@trees[tree].load_lsr
end
def expand_variables(tree)
@trees[tree].expand_variables
end
def expand_braces(tree,str)
@trees[tree].expand_braces(str)
end
def expand_path(tree,str)
@trees[tree].expand_path(str)
end
def expand_var(tree,str)
@trees[tree].expand_var(str)
end
def show_path(tree,str)
@trees[tree].show_path(str)
end
def var_value(tree,str)
@trees[tree].var_value(str)
end
def find_file(tree,filename)
@trees[tree].find_file(filename)
end
def find_files(tree,filename,first)
@trees[tree].find_files(filename,first)
end
end
|