Module: Pult::Panel::Runner::Injector

Defined in:
lib/init/struct.rb,
lib/pult/panel/runner/injector.rb

Class Method Summary collapse

Class Method Details

.inject!(hash, action, runner) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/pult/panel/runner/injector.rb', line 15

def self.inject! hash, action, runner
  #
  # TODO runner meths and sys maybe need list
  # for safe using with ! and other
  #
  hash.instance_eval do
    def runner?
      true
    end
  end

  hash.instance_eval <<-STR
    def #{action}_runner
      ->{ ObjectSpace._id2ref(#{runner.object_id}) }.call
    end

    def #{action}_out
      #{action}_runner.stdout
    end

    def #{action}_err
      #{action}_runner.stderr
    end

    def #{action}_inf
      #{action}_runner.info
    end

    def #{action}_suc
      #{action}_inf.success?
    end

    def #{action}_pid
      #{action}_inf.pid
    end

    def #{action}_act

    end

    def #{action}_kill
      Pult::Executor::Terminator.kill! #{action}_pid
    end
  STR
end

.injectionsObject



3
4
5
# File 'lib/pult/panel/runner/injector.rb', line 3

def self.injections
  read_injections + run_injections
end

.read_injectionsObject



7
8
9
# File 'lib/pult/panel/runner/injector.rb', line 7

def self.read_injections
  %w{ _out _in _err _suc _inf _act _pid }
end

.run_injectionsObject



11
12
13
# File 'lib/pult/panel/runner/injector.rb', line 11

def self.run_injections
  %w{ _kill }
end