lib/oddb2xml/cli.rb in oddb2xml-1.0.9 vs lib/oddb2xml/cli.rb in oddb2xml-1.0.10
- old
+ new
@@ -13,17 +13,27 @@
def initialize(args)
@options = args
@mutex = Mutex.new
@items = {} # Items from Preparations.xml in BAG
@index = {} # Base index from swissINDEX
+ @orphans = [] # Orphaned drugs from Swissmedic xls
+ @fridges = [] # ReFridge drugs from Swissmedic xls
LANGUAGES.each do |lang|
@index[lang] = {}
end
end
def run
threads = []
- # bag_xml
+ # swissmedic
+ [:orphans, :fridges].each do |type|
+ threads << Thread.new do
+ downloader = SwissmedicDownloader.new
+ io = downloader.download_by(type)
+ self.instance_variable_set("@#{type.to_s}", SwissmedicExtractor.new(io, type).to_arry)
+ end
+ end
+ # bag
threads << Thread.new do
downloader = BagXmlDownloader.new
xml = downloader.download
@items = BagXmlExtractor.new(xml).to_hash
end
@@ -60,9 +70,11 @@
end
end
builder.subject = sbj
builder.index = index
builder.items = @items
+ builder.orphans = @orphans
+ builder.fridges = @fridges
builder.tag_suffix = @options[:tag_suffix]
end
if file =~ /(product)/
xml = builder.to_xml('substance')
File.open(file.gsub($1, 'substance'), 'w:utf-8'){ |fh| fh << xml }