Class: XmlConv::Util::PollingManager
- Inherits:
-
Object
- Object
- XmlConv::Util::PollingManager
- Defined in:
- lib/xmlconv/util/polling_manager.rb
Instance Method Summary collapse
-
#initialize(system) ⇒ PollingManager
constructor
A new instance of PollingManager.
- #load_sources(&block) ⇒ Object
- #poll_sources ⇒ Object
Constructor Details
#initialize(system) ⇒ PollingManager
Returns a new instance of PollingManager.
173 174 175 |
# File 'lib/xmlconv/util/polling_manager.rb', line 173 def initialize(system) @system = system end |
Instance Method Details
#load_sources(&block) ⇒ Object
176 177 178 179 180 181 182 183 |
# File 'lib/xmlconv/util/polling_manager.rb', line 176 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_sources ⇒ Object
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/xmlconv/util/polling_manager.rb', line 184 def poll_sources load_sources do |source| begin source.poll { |transaction| @system.execute(transaction) } rescue Exception => e subject = 'XmlConv2 - Polling-Error' body = [e.class, e., defined?(source.user) ? 'user '+ source.user : nil, defined?(source.host) ? 'host '+ source.host : nil, defined?(source.port) ? 'port '+ source.port.to_s : nil ].compact.concat(e.backtrace).join("\n") Util::Mail.notify source.error_recipients, subject, body end end end |