Class: XmlConv::Util::PollingManager

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlconv/util/polling_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(system) ⇒ PollingManager

Returns a new instance of PollingManager.



172
173
174
# File 'lib/xmlconv/util/polling_manager.rb', line 172

def initialize(system)
  @system = system
end

Instance Method Details

#load_sources(&block) ⇒ Object



175
176
177
178
179
180
181
182
# File 'lib/xmlconv/util/polling_manager.rb', line 175

def load_sources(&block)
  file = File.open(CONFIG.polling_file)
  YAML.load_documents(file) { |mission|
    block.call(mission)
  }
ensure
  file.close if(file)
end

#poll_sourcesObject



183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/xmlconv/util/polling_manager.rb', line 183

def poll_sources
  load_sources { |source|
       begin
         source.poll { |transaction|
           @system.execute(transaction)
         }
       rescue Exception => e
         subject = 'XmlConv2 - Polling-Error'
         body = [e.class, e.message].concat(e.backtrace).join("\n")
         Util::Mail.notify source.error_recipients, subject, body
       end
  }
end