Class: Themigrator::ScriptPool

Inherits:
Object
  • Object
show all
Defined in:
lib/themigrator/script_pool.rb

Instance Method Summary collapse

Constructor Details

#initializeScriptPool

Returns a new instance of ScriptPool.



6
7
8
9
10
# File 'lib/themigrator/script_pool.rb', line 6

def initialize
  @queue = Queue.new
  @lock = Mutex.new
  @scripts = []
end

Instance Method Details

#add_script(script, log_file) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/themigrator/script_pool.rb', line 12

def add_script(script,log_file)
  s = Script.new(script, log_file)
  @lock.synchronize do
	@scripts << s
  end
  s
end

#run_and_waitObject

Run the scripts returns:

* true: All scripts returned 0
* false: Some of the scripts fail


24
25
26
27
28
29
# File 'lib/themigrator/script_pool.rb', line 24

def run_and_wait
  @lock.synchronize do
	start_scripts
	collect_result
  end
end