Class: Cantemo::Portal::Agent::WatchFolderUtility::Foreman
- Inherits:
-
Object
- Object
- Cantemo::Portal::Agent::WatchFolderUtility::Foreman
- Defined in:
- lib/cantemo/portal/agent/watch_folder_utility/foreman.rb
Class Method Summary collapse
- .initialize_watch_folder(watch_folder_def) ⇒ Object
- .poll_watch_folder(watch_folder, &block) ⇒ Object
- .poll_watch_folders(watch_folders, &block) ⇒ Object
- .process_watch_folder_def(watch_folder_def) ⇒ Object
- .process_watch_folder_defs(watch_folder_defs) ⇒ Object
- .run_once(watch_folders, &block) ⇒ Object
Class Method Details
.initialize_watch_folder(watch_folder_def) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cantemo/portal/agent/watch_folder_utility/foreman.rb', line 10 def self.initialize_watch_folder(watch_folder_def) case (watch_folder_def['handler'] || '').downcase.gsub(/[-_ ]/, '') when 'asperawatch' wf_class = Envoi::Aspera::WatchService::WatchFolder end wf_class.new(watch_folder_def) end |
.poll_watch_folder(watch_folder, &block) ⇒ Object
34 35 36 |
# File 'lib/cantemo/portal/agent/watch_folder_utility/foreman.rb', line 34 def self.poll_watch_folder(watch_folder, &block) watch_folder.poll(&block) end |
.poll_watch_folders(watch_folders, &block) ⇒ Object
38 39 40 |
# File 'lib/cantemo/portal/agent/watch_folder_utility/foreman.rb', line 38 def self.poll_watch_folders(watch_folders, &block) watch_folders.each { |watch_folder| poll_watch_folder(watch_folder, &block) } end |
.process_watch_folder_def(watch_folder_def) ⇒ Object
18 19 20 |
# File 'lib/cantemo/portal/agent/watch_folder_utility/foreman.rb', line 18 def self.process_watch_folder_def(watch_folder_def) initialize_watch_folder(watch_folder_def) end |
.process_watch_folder_defs(watch_folder_defs) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cantemo/portal/agent/watch_folder_utility/foreman.rb', line 22 def self.process_watch_folder_defs(watch_folder_defs) if watch_folder_defs.is_a?(Array) watch_folder_defs.map { |watch_folder_def| process_watch_folder_def(watch_folder_def) } elsif watch_folder_defs.is_a?(Hash) watch_folder_defs.map do |name, watch_folder_def| watch_folder_def['path'] ||= name; process_watch_folder_def(watch_folder_def) end else raise "Unhandled format: #{watch_folder_defs.class.name}" end end |
.run_once(watch_folders, &block) ⇒ Object
42 43 44 |
# File 'lib/cantemo/portal/agent/watch_folder_utility/foreman.rb', line 42 def self.run_once(watch_folders, &block) poll_watch_folders(watch_folders, &block) end |