Class: Oddb2xml::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/oddb2xml/cli.rb

Constant Summary collapse

SUBJECTS =
%w[product article]
LANGUAGES =

EN does not exist

%w[DE FR]

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Cli

Returns a new instance of Cli.



13
14
15
16
17
18
19
20
21
# File 'lib/oddb2xml/cli.rb', line 13

def initialize(args)
  @options = args
  #@mutex = Mutex.new
  @items = {} # Items from Preparations.xml in BAG
  @index = {} # Base index from swissINDEX
  LANGUAGES.each do |lang|
    @index[lang] = {}
  end
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/oddb2xml/cli.rb', line 22

def run
  # Sometimes nokogiri crashes with ruby in Threads.
  #threads = []
  # bag_xml
  #threads << Thread.new do
    downloader = BagXmlDownloader.new
    xml = downloader.download
    @items = BagXmlExtractor.new(xml).to_hash
  #end
  LANGUAGES.each do |lang|
    # swissindex
    types.each do |type|
      #threads << Thread.new do
        downloader = SwissIndexDownloader.new(type)
        xml = downloader.download_by(lang)
        hsh = SwissIndexExtractor.new(xml, type).to_hash
        #@mutex.synchronize do
          @index[lang][type] = hsh
        #end
      #end
    end
  end
  #threads.map(&:join)
  build
  report
end