Class: HammerCLIForemanRemoteExecution::JobInvocation::OutputCommand

Inherits:
HammerCLIForeman::Command
  • Object
show all
Defined in:
lib/hammer_cli_foreman_remote_execution/job_invocation.rb

Instance Method Summary collapse

Instance Method Details

#execute ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
# File 'lib/hammer_cli_foreman_remote_execution/job_invocation.rb', line 103

def execute
  data = get_output
  if data['delayed']
    puts _('The job is scheduled to start at %{timestamp}') % { :timestamp => data['start_at'] }
    return HammerCLI::EX_OK if option_async?
  end
  since = print_data(data)

  output_loop(data, since)
  return HammerCLI::EX_OK
end


92
93
94
95
96
97
98
99
100
101
# File 'lib/hammer_cli_foreman_remote_execution/job_invocation.rb', line 92

def print_data(output)
  line_set = output['output'].sort_by { |lines| lines['timestamp'].to_f }
  since = nil

  line_set.each do |line|
    puts line['output']
    since = line['timestamp']
  end
  since
end