class Eco::API::Session::Batch::JobsGroups

def [](name)

def [](name)
  @groups[name]
end

def counter(seconds)

def counter(seconds)
  puts "\n"
  while seconds + 1 > 0 do
    print "  Waiting #{seconds}\r"
    $stdout.flush
    seconds -= 1
    sleep 1
  end
  print "#{" " * 40}"
  $stdout.flush
  puts ""
end

def delay_between_groups

def delay_between_groups
  config.delay_between_job_groups || DELAY_BETWEEN_GROUPS
end

def each(&block)

def each(&block)
  return to_enum(:each) unless block
  items.each(&block)
end

def empty?

def empty?
  count == 0
end

def errors?

def errors?
  any? {|group| group.errors?}
end

def exists?(name)

def exists?(name)
  @groups.key?(name)
end

def find_jobs(type:)

def find_jobs(type:)
  each_with_object([]) do |group, jbs|
    jbs.concat(group.find_jobs(type: type))
  end
end

def initialize(e)

def initialize(e)
  super(e)
  reset
end

def items

def items
  @groups.values
end

def launch(simulate: false)

Returns:
  • (Hash>) -

Other tags:
    Note: -
def launch(simulate: false)
  @order.each_with_index do |group, idx|
    if group.pending?
      status[group] = group_status = group.launch(simulate: simulate)
      callback = @callbacks[group]
      callback.call(group, group_status) if callback
      self.class.counter(delay_between_groups) if !simulate && idx < @order.length - 1
    end
  end
  launch(simulate: simulate) if pending?
  return status
end

def length

def length
  count
end

def new(name, order: :last, &block)

Returns:
  • (Eco::API::Session::Batch::Jobs) - the group of jobs.

Other tags:
    Yieldparam: group_status - the status of the launched batch jobs.
    Yieldparam: group - the group of jobs we have launched against the server.

Other tags:
    Yield: - callback after launching the batch job request against the server.
def new(name, order: :last, &block)
  fatal "Can't create job group named '#{name}' because it already exists." if exists?(name)
  Batch::Jobs.new(enviro, name: name).tap do |group|
    @groups[name] = group
    if order == :last
      @order.push(group)
    else
      @order.unshift(group)
    end
    @callbacks[group] = block if block_given?
  end
end

def pending?

def pending?
  any? {|group| group.pending?}
end

def reset

def reset
  @order  = []
  @groups = {}
  @callbacks = {}
end

def status

def status
  if block_given?
    status.each do |group, group_status|
      yield(group, group_status)
    end
    self
  else
    @groups_status ||= {}
  end
end

def summary

def summary
  [].tap do |msg|
    map {|group| msg << group.summary}
  end.join("\n")
end