lib/oddb2xml/cli.rb in oddb2xml-1.6.2 vs lib/oddb2xml/cli.rb in oddb2xml-1.6.3
- old
+ new
@@ -3,19 +3,21 @@
require 'thread'
require 'oddb2xml/builder'
require 'oddb2xml/downloader'
require 'oddb2xml/extractor'
require 'oddb2xml/compressor'
+require 'oddb2xml/util'
module Oddb2xml
class Cli
SUBJECTS = %w[product article]
ADDITIONS = %w[substance limitation interaction code]
OPTIONALS = %w[fi fi_product]
LANGUAGES = %w[DE FR] # EN does not exist
def initialize(args)
@options = args
+ Oddb2xml.save_options(@options)
@mutex = Mutex.new
# product
@items = {} # Items from Preparations.xml in BAG
@index = {} # Base index from swissINDEX
@flags = {} # narcotics flag files repo
@@ -86,11 +88,11 @@
end
private
def build
begin
files.each_pair do |sbj, file|
- builder = Builder.new do |builder|
+ builder = Builder.new(@options) do |builder|
if @options[:address]
builder.subject = sbj
builder.companies = @companies
builder.people = @people
else # product
@@ -141,10 +143,10 @@
File.open(file, 'w:utf-8'){ |fh| fh << output }
end
rescue Interrupt
files.values.each do |file|
if File.exist? file
- File.unlink file
+ File.unlink(file) # we don't save it as it might be only partly downloaded
end
end
raise Interrupt
end
end