Class: XmlConv::Util::PollingMission
- Defined in:
- lib/xmlconv/util/polling_manager.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
Returns the value of attribute directory.
-
#glob_pattern ⇒ Object
Returns the value of attribute glob_pattern.
Attributes inherited from Mission
#arguments, #backup_dir, #debug_recipients, #destination, #error_recipients, #filter, #partner, #postprocs, #reader, #tmp_destination, #writer
Instance Method Summary collapse
Methods inherited from Mission
#create_transaction, #filtered_transaction
Instance Attribute Details
#directory ⇒ Object
Returns the value of attribute directory.
41 42 43 |
# File 'lib/xmlconv/util/polling_manager.rb', line 41 def directory @directory end |
#glob_pattern ⇒ Object
Returns the value of attribute glob_pattern.
41 42 43 |
# File 'lib/xmlconv/util/polling_manager.rb', line 41 def glob_pattern @glob_pattern end |
Instance Method Details
#file_paths ⇒ Object
42 43 44 45 46 47 |
# File 'lib/xmlconv/util/polling_manager.rb', line 42 def file_paths path = File.(@glob_pattern || '*', @directory) Dir.glob(path).collect { |entry| File.(entry, @directory) }.compact end |
#poll ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/xmlconv/util/polling_manager.rb', line 48 def poll @directory = File.(@directory, CONFIG.project_root) file_paths.each { |path| begin filtered_transaction(File.read(path), 'file:' << path) { |transaction| yield transaction } rescue Exception => e puts e puts e.backtrace ensure FileUtils.mkdir_p(@backup_dir) FileUtils.mv(path, @backup_dir) end } end |