Class: Synco::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/synco/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*scripts) ⇒ Runner

Returns a new instance of Runner.



27
28
29
# File 'lib/synco/scope.rb', line 27

def initialize(*scripts)
  @scripts = scripts
end

Instance Attribute Details

#scriptsObject (readonly)

Returns the value of attribute scripts.



31
32
33
# File 'lib/synco/scope.rb', line 31

def scripts
  @scripts
end

Instance Method Details

#callObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/synco/scope.rb', line 33

def call
  Console.info(self, "Running scripts...")
  
  Process::Group.wait do |group|
    @scripts.each do |script|
      Fiber.new do
        ScriptScope.new(script, group).call
      end.resume
    end
  end
rescue => error
  Console::Event::Failure.for(error).emit(self)
  raise
ensure
  Console.info(self, "Finished running scripts.")
end