lib/exlibris/aleph/config/tab37.rb in exlibris-aleph-0.1.0 vs lib/exlibris/aleph/config/tab37.rb in exlibris-aleph-0.1.1
- old
+ new
@@ -20,28 +20,41 @@
protected
def parse_file
config_array = []
config_hash = {}
File.open(@aleph_file).each do |line|
- line.chomp!
- config_match = line.match(@pattern)
- if (config_match)
- config_match_hash = {}
- @pattern_key.each do |column, key|
- config_match_hash[key] = config_match[column].strip
- end
- pickup_locations = []
- (6..15).each do |column|
- pickup_locations.push(config_match[column].strip) unless config_match[column].nil?
- end
- config_match_hash[:pickup_locations] = pickup_locations
- config_array.push(config_match_hash) unless config_match_hash.empty?
- config_hash[config_match_hash[:sub_library]]={} if config_hash[config_match_hash[:sub_library]].nil?
- config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]]={} if config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]].nil?
- config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]]={} if config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]].nil?
- config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]][config_match_hash[:patron_status]]={} if config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]][config_match_hash[:patron_status]].nil?
- config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]][config_match_hash[:patron_status]][config_match_hash[:availability_status]] = config_match_hash unless config_match_hash.empty? or hash_key.nil?
- end
+ line.chomp!
+ config_match = line.match(@pattern)
+ if(config_match)
+ config_match_hash = {}
+ @pattern_key.each do |column, key|
+ config_match_hash[key] = config_match[column].strip
+ end
+ pickup_locations = []
+ (6..15).each do |column|
+ pickup_locations.push(config_match[column].strip) unless config_match[column].nil?
+ end
+ config_match_hash[:pickup_locations] = pickup_locations
+ config_array.push(config_match_hash) unless config_match_hash.empty?
+ config_hash[config_match_hash[:sub_library]]={} if config_hash[config_match_hash[:sub_library]].nil?
+ config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]]={} if config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]].nil?
+ config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]]={} if config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]].nil?
+ config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]][config_match_hash[:patron_status]]={} if config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]][config_match_hash[:patron_status]].nil?
+ config_hash[config_match_hash[:sub_library]][config_match_hash[:item_status]][config_match_hash[:item_process_status]][config_match_hash[:patron_status]][config_match_hash[:availability_status]] = config_match_hash unless config_match_hash.empty? or hash_key.nil?
+ else
+ continuation_pattern = /^(\s{17})(.{2}.?.?.?)\s?(.{5})?\s?(.{5})?\s?(.{5})?\s?(.{5})?\s?(.{5})?\s?(.{5})?\s?(.{5})?\s?(.{5})?\s?(.{5})?/
+ continuation_match = line.match(continuation_pattern)
+ if(continuation_match)
+ continuation_match_hash = config_array.pop
+ pickup_locations = continuation_match_hash[:pickup_locations]
+ (2..11).each do |column|
+ pickup_locations.push(continuation_match[column].strip) unless continuation_match[column].nil?
+ end
+ continuation_match_hash[:pickup_locations] = pickup_locations
+ config_array.push(continuation_match_hash) unless continuation_match_hash.empty?
+ config_hash[continuation_match_hash[:sub_library]][continuation_match_hash[:item_status]][continuation_match_hash[:item_process_status]][continuation_match_hash[:patron_status]][continuation_match_hash[:availability_status]] = continuation_match_hash unless continuation_match_hash.empty? or hash_key.nil?
+ end
+ end
end
return [config_array, config_hash]
end
end
end
\ No newline at end of file