lib/marcspec/map.rb in marcspec-1.5.0 vs lib/marcspec/map.rb in marcspec-1.6.1

- old
+ new

@@ -8,18 +8,19 @@ # in several different contexts. # # NOTE: THIS IS AN ABSTRACT SUPERCLASS. DO NOT INSTANTIATE IT DIRECTLY class Map + include Logback::Simple + attr_accessor :mapname, :map - # Create a new map. The passed map is either - # a standard hash or a list of duples + # Create a new map. The passed map is either a standard hash (KVMap) or a list of duples + # (for a MultiValueMap) # # @param [String] mapname The name of this map; can be used to find it later on. - # @param [Hash, Array<2-value-arrays>] map Either a normal key-value hash (for a KV Map) or an - # array of duples (2-value arrays) for a MultiValueMap. + # @param [Hash, Array] map Either a normal key-value hash (for a KV Map) or an array of duples (2-value arrays) for a MultiValueMap. def initialize(mapname, map) @mapname = mapname @map = map end @@ -32,18 +33,18 @@ def self.fromFile filename begin str = File.open(filename).read rescue Exception => e - $LOG.error "Problem opening #{filename}: #{e.message}" + log.fatal "Problem opening #{filename}: #{e.message}" raise e end begin rawmap = eval(str) rescue Exception => e - $LOG.error "Problem evaluating (with 'eval') file #{filename}: #{e.message}" + log.fatal "Problem evaluating (with 'eval') file #{filename}: #{e.message}" raise e end # Derive a name if there isn't one unless rawmap[:mapname] @@ -56,10 +57,10 @@ when :kv return KVMap.new(rawmap[:mapname], rawmap[:map]) when :multi return MultiValueMap.new(rawmap[:mapname], rawmap[:map]) else - $LOG.error "Map file #{filename} doesn't seem to be either a KV map or a MuliValueMap according to :maptype (#{rawmap[:maptype]})" + log.fatal "Map file #{filename} doesn't seem to be either a KV map or a MuliValueMap according to :maptype (#{rawmap[:maptype]})" raise ArgumentError, "File #{filename} doesn't evaluate to a valid map" end end \ No newline at end of file