config: Make code more readable.
This commit is contained in:
parent
3e29c275b8
commit
eabc2c8dcf
1 changed files with 12 additions and 16 deletions
|
@ -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$/
|
||||
# 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
|
||||
# error while parsing map
|
||||
end
|
||||
end
|
||||
#total_size += FileTest.size(path)
|
||||
raise RuntimeError, "Error while parsing map file"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue