Module: WorkersLoader
- Defined in:
- lib/workers_loader.rb,
lib/workers_loader/path.rb,
lib/workers_loader/version.rb
Overview
Resque workers strategy loading system
Defined Under Namespace
Classes: Path
Constant Summary collapse
- VERSION =
'0.0.3'- @@workers_paths =
[]
- @@workers =
[]
Class Method Summary collapse
Class Method Details
.add_path(path) ⇒ Object
14 15 16 17 |
# File 'lib/workers_loader.rb', line 14 def add_path(path) fail "Directory not found: `#{path}`" unless Dir.exist?(path) @@workers_paths << path end |
.find(path) ⇒ Object
19 20 21 22 23 |
# File 'lib/workers_loader.rb', line 19 def find(path) path = Path.new(path) path.files.map { |file| path.queue_for(file) } .reject(&:blank?) end |
.load_workers! ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/workers_loader.rb', line 25 def load_workers! workers_paths.each do |path| workers_in_path = find(path) next if workers_in_path.empty? duplacates = workers_in_path .select { |worker| workers.include?(worker) } if duplacates.any? fail("Workers already present! #{duplacates.sort.join(', ')}") end self.workers += workers_in_path end end |