lib/data_loader.rb
# Read the files containing in a directory and save information about them to load in the hash
Read the files containing in a directory and save information about them to load in the hash
Read the files containing in a directory and save information about them to load in the hash
def read_dir(name)
    puts "read_dir(#{name})" if ENV['DEBUG']
    dir=Dir.new(File.join(@data_root,name))
    dir.map do |m|                                    
      [  File.basename(m, '.*'), File.extname(m) ]
    end.select do |sbase, sext|                       
      SORT_ORDER.include?(sext) && sbase != 'datasets'
    end.sort do |(a1,b1),(a2,b2)|                     
      SORT_ORDER.index(b1) <=> SORT_ORDER.index(b2)
    end.each do |base,ext|                            
      self[base.to_sym] = {
        :path  => File.join( dir.path , base+ext),
        :type  => ext,
        :state => :untouched
      }
    end
  end
def read_dir ( name ) puts "read_dir(#{name})" if ENV [ 'DEBUG' ] dir = Dir . new ( File . join ( @data_root , name ) ) dir . map do | m | [ File . basename ( m , '.*' ) , File . extname ( m ) ] end . select do | sbase , sext | SORT_ORDER . include? ( sext ) && sbase != 'datasets' end . sort do | ( a1 , b1 ) , ( a2 , b2 ) | SORT_ORDER . index ( b1 ) <=> SORT_ORDER . index ( b2 ) end . each do | base , ext | self [ base . to_sym ] = { :path => File . join ( dir . path , base + ext ) , :type => ext , :state => :untouched } end end
Read the files containing in a directory and save information about them to load in the hash
Read the files containing in a directory and save information about them to load in the hash
# First convert to basename, extension pairs # Select supported extensions that are not control files # Sort based on precedence # Insert into hash
name