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



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/hammer_cli_foreman_remote_execution/job_invocation.rb', line 67

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


56
57
58
59
60
61
62
63
64
65
# File 'lib/hammer_cli_foreman_remote_execution/job_invocation.rb', line 56

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