Method: OMF::Web::Rack::MultiFile#initialize

Defined in:
lib/omf-web/rack/multi_file.rb

#initialize(roots, opts = {}) ⇒ MultiFile

Returns a new instance of MultiFile.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/omf-web/rack/multi_file.rb', line 13

def initialize(roots, opts = {})
  super nil, opts[:cache_control]
  @roots = roots
  if opts[:sub_path]
    @sub_path = opts[:sub_path].split SEPS
  end
  if @version = opts[:version]
    # read VERSION_MAP.yaml files
    @version_map = {}
    require 'yaml'
    yml = File.join((@sub_path || []), 'VERSION_MAP.yaml')
    @roots.reverse.each do |dir|
      fn = File.join(dir, yml)
      #puts "Checking for #{fn}"
      if File.readable?(fn)
        mh = YAML.load_file(fn)
        #puts "VERSIONS: #{mh.inspect}"
        @version_map.merge!(mh)
      end
    end
  end
end