summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby/base/kpsetrees.rb
blob: 8e3fb20f8547f033998c64953fc225b70203b671 (plain)
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
require 'monitor'
require 'base/kpsefast'

class KpseTrees < Monitor

    def initialize
        @trees = Hash.new
        @monitor = Monitor.new
    end

    def choose(filenames,environment)
        current = filenames.join('|')
        # @monitor do
            unless @trees[current] then
                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
            puts "enabling tree #{current}"
        # end
        current
    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 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