Class: CobraCommander::Executor::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/cobra_commander/executor/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component, command) ⇒ Context

Returns a new instance of Context.



10
11
12
13
14
# File 'lib/cobra_commander/executor/context.rb', line 10

def initialize(component, command)
  @component = component
  @command = command
  @tty = TTY::Command.new(pty: true, printer: :null, stderr: :stdout)
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



8
9
10
# File 'lib/cobra_commander/executor/context.rb', line 8

def command
  @command
end

#componentObject (readonly)

Returns the value of attribute component.



8
9
10
# File 'lib/cobra_commander/executor/context.rb', line 8

def component
  @component
end

Instance Method Details

#component_nameObject



24
25
26
# File 'lib/cobra_commander/executor/context.rb', line 24

def component_name
  component.name
end

#outputObject



32
33
34
# File 'lib/cobra_commander/executor/context.rb', line 32

def output
  results.join("\n")
end

#resultsObject



16
17
18
19
20
21
22
# File 'lib/cobra_commander/executor/context.rb', line 16

def results
  @results ||= @component.root_paths.map do |path|
    isolate_bundle do
      @tty.run!(command, chdir: path)
    end
  end
end

#success?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/cobra_commander/executor/context.rb', line 28

def success?
  results.all?(&:success?)
end