Class: Oddb2xml::Cli
- Inherits:
-
Object
- Object
- Oddb2xml::Cli
- Defined in:
- lib/oddb2xml/cli.rb
Constant Summary collapse
- SUBJECTS =
%w[product article]
- ADDITIONS =
%w[substance limitation interaction code]
- OPTIONALS =
%w[fi fi_product]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(args) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(args) ⇒ Cli
Returns a new instance of Cli.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/oddb2xml/cli.rb', line 16 def initialize(args) @options = args $stdout.puts "\nStarting cli with from #{caller(2..2).first} using #{@options}" if defined?(RSpec) Oddb2xml.(@options) @mutex = Mutex.new # product @items = {} # Items from Preparations.xml in BAG, using GTINs as key @refdata_types = {} # Base index from refdata @lppvs = {} # lppv.txt from files repo @infos = {} # [option] FI from SwissmedicInfo @packs = {} # [option] Packungen from Swissmedic for dat @infos_zur_rose = {} # [addition] infos_zur_rose and other infos from zurrose transfer.txt @migel = {} # [addition] additional Non Pharma products from files repo @actions = [] # [addition] interactions from epha @orphan = [] # [addition] Orphaned drugs from Swissmedic xls # addresses @companies = [] # betrieb @people = [] # medizinalperson @_message = false end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/oddb2xml/cli.rb', line 12 def @options end |
Instance Method Details
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/oddb2xml/cli.rb', line 37 def run threads = [] start_time = Time.now files2rm = Dir.glob(File.join(DOWNLOADS, "*")) FileUtils.rm_f(files2rm, verbose: true) if (files2rm.size > 0) && !Oddb2xml.skip_download? if @options[:calc] && !(@options[:extended]) threads << download(:package) # swissmedic elsif @options[:address] [:company, :person].each do |type| threads << download(type) # medregbm.admin end else if @options[:format] != :dat if @options[:fi] threads << download(:fachinfo) # swissmedic-info end threads << download(:orphan) # swissmedic threads << download(:interaction) # epha end if @options[:nonpharma] threads << download(:migel) # oddb2xml_files end threads << download(:zurrose) threads << download(:package) # swissmedic threads << download(:lppv) # oddb2xml_files threads << download(:bag) # bag.e-mediat types.each do |type| threads << download(:refdata, type) # refdata end end begin # threads.map(&:join) # TODO rescue SystemExit @mutex.synchronize do if @_message puts "(Aborted)" puts "Please install SSLv3 CA certificates on your machine." puts "You can check with `ruby -ropenssl -e 'p OpenSSL::X509::DEFAULT_CERT_FILE'`." puts "See README." end end exit end build if @options[:artikelstamm] && system("which xmllint") elexis_v5_xsd = File.(File.join(__FILE__, "..", "..", "..", "Elexis_Artikelstamm_v5.xsd")) cmd = "xmllint --noout --schema #{elexis_v5_xsd} #{@the_files[:artikelstamm]}" if system(cmd) puts "Validatied #{@the_files[:artikelstamm]}" else puts "Validating failed using #{cmd}" raise "Validating failed using #{cmd}" end end compress if @options[:compress_ext] res = report nr_secs = (Time.now - start_time).to_i if defined?(RSpec) && nr_secs.to_i > 10 && ENV["TRAVIS"].to_s.empty? puts "Took took long #{nr_secs} seconds" # require "pry"; binding.pry; end res end |