Class: DerivedImages::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/derived_images/processor.rb

Overview

The Processor manages a Manifest, watches the filesystem for changes, and manages a pool of Worker instances which perform the image tasks.

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



7
8
9
10
11
12
# File 'lib/derived_images/processor.rb', line 7

def initialize
  @cache = Cache.new
  @manifest = Manifest.new.tap(&:draw)
  @queue = Thread::Queue.new
  @workers = ThreadGroup.new
end

Instance Method Details

#run_onceObject



25
26
27
28
29
# File 'lib/derived_images/processor.rb', line 25

def run_once
  process_all
  queue.close
  @workers.list.each(&:join)
end

#unwatchObject



20
21
22
23
# File 'lib/derived_images/processor.rb', line 20

def unwatch
  manifest_listener&.stop
  image_listener&.stop
end

#watchObject



14
15
16
17
18
# File 'lib/derived_images/processor.rb', line 14

def watch
  watch_manifest
  watch_images
  process_all
end