Class: Envoi::Mam::Agent::WatchFolderUtility::Foreman
- Inherits:
-
Object
- Object
- Envoi::Mam::Agent::WatchFolderUtility::Foreman
- Defined in:
- lib/envoi/mam/agent/watch_folder_utility/foreman.rb
Constant Summary collapse
- AWF =
Envoi::Aspera::WatchService::WatchFolder
- LWF =
Envoi::WatchFolderUtility::WatchFolder::Listen
Instance Attribute Summary collapse
-
#agent ⇒ Object
Returns the value of attribute agent.
-
#config ⇒ Object
Returns the value of attribute config.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#watch_folders ⇒ Object
Returns the value of attribute watch_folders.
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
Instance Method Summary collapse
-
#initialize(args = { }) ⇒ Foreman
constructor
A new instance of Foreman.
Constructor Details
#initialize(args = { }) ⇒ Foreman
Returns a new instance of Foreman.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 12 def initialize(args = { }) initialize_logger(args) @agent = Envoi::Mam::Cantemo::Agent.load_from_config_file(args) @config = agent.config cantemo_config = config[:cantemo] || config['cantemo'] watch_folder_defs = cantemo_config[:watch_folders] || cantemo_config['watch_folders'] @ignored_file_paths_by_watch_folder = Hash.new { |h, k| h[k] = [] } @watch_folders = AWF.process_watch_folder_defs(watch_folder_defs) end |
Instance Attribute Details
#agent ⇒ Object
Returns the value of attribute agent.
10 11 12 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 10 def agent @agent end |
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 10 def config @config end |
#logger ⇒ Object
Returns the value of attribute logger.
10 11 12 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 10 def logger @logger end |
#watch_folders ⇒ Object
Returns the value of attribute watch_folders.
10 11 12 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 10 def watch_folders @watch_folders end |
Class Method Details
.initialize_watch_folder(watch_folder_def) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 27 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
51 52 53 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 51 def self.poll_watch_folder(watch_folder, &block) watch_folder.poll(&block) end |
.poll_watch_folders(watch_folders, &block) ⇒ Object
55 56 57 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 55 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
35 36 37 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 35 def self.process_watch_folder_def(watch_folder_def) initialize_watch_folder(watch_folder_def) end |
.process_watch_folder_defs(watch_folder_defs) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 39 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
59 60 61 |
# File 'lib/envoi/mam/agent/watch_folder_utility/foreman.rb', line 59 def self.run_once(watch_folders, &block) poll_watch_folders(watch_folders, &block) end |