config: Make code more readable.

This commit is contained in:
Glenn Y. Rolland 2014-10-29 23:46:02 +01:00
parent 3e29c275b8
commit eabc2c8dcf

View file

@ -4,7 +4,6 @@ require 'ostruct'
require 'pp'
require 'find'
#require 'rdebug/base'
require 'qasim'
module Qasim
@ -15,8 +14,6 @@ module Qasim
attr_reader :mnt_dir
def initialize
@mnt_dir = File.join ENV['HOME'], "mnt"
@config_dir = APP_CONFIG_DIR
@ -30,27 +27,26 @@ module Qasim
end
def parse_maps &blk
#rdebug "Config: #{@config_dir}/config"
@maps = []
map_dirs = [@config_dir, APP_SYSCONFIG_DIR].select{ |d|
File.exist? d and File.directory? d
}
Find.find( *map_dirs ) do |path|
if File.file? path
if File.basename( path ) =~ /.map$/
begin
map = Map.new self, path
yield map if block_given?
maps.push map
rescue
# error while parsing map
end
end
#total_size += FileTest.size(path)
# Skip unwanted files fast
next unless File.file? path
next unless File.basename( path ) =~ /.map$/
begin
map = Map.new self, path
yield map if block_given?
maps.push map
rescue
raise RuntimeError, "Error while parsing map file"
end
end
end
end
end