qasim/qasim/config.rb

57 lines
984 B
Ruby

#!/usr/bin/ruby
# vim: set ts=4 sw=4:
require 'optparse'
require 'ostruct'
require 'pp'
require 'find'
require 'rubygems'
#require 'rdebug/base'
require 'qasim/constants'
require 'qasim/map'
module Qasim
class Config
attr_reader :maps_active
attr_reader :maps
attr_reader :mnt_dir
def initialize
@mnt_dir = File.join ENV['HOME'], "mnt"
@config_dir = APP_CONFIG_DIR
@config_file = nil
@maps = []
@initialize_enable = false
@umount_enable = false
@target = nil
@verbose_enable = false
@debug = false
end
def parse_maps &blk
#rdebug "Config: #{@config_dir}/config"
@maps = []
Find.find( @config_dir, APP_SYSCONFIG_DIR ) 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)
end
end
end
end
end