class NeverBounce::CLI::Script::JobsStatus

Public Instance Methods

manifest() click to toggle source

@!attribute manifest @return [Manifest]

# File lib/never_bounce/cli/script/jobs_status.rb, line 26
def manifest
  @manifest ||= Manifest.new(
    name: "nb-jobs-status",
    function: "Get job status",
    cmdline: "[options] [VAR1=value] [VAR2=value] ...",
  )
end
request() click to toggle source

An API::Request::JobsStatus. @!attribute request @return [Object]

# File lib/never_bounce/cli/script/jobs_status.rb, line 15
def request
  @request ||= API::Request::JobsStatus.new({
    api_key: api_key,
    job_id: job_id,
  })
end
slim_main() click to toggle source

@return [Integer]

# File lib/never_bounce/cli/script/jobs_status.rb, line 37
def slim_main
  "Response".tap do |label|
    headings = [
      ["ID", :id, :right],

      ["JStatus", :job_status, :center],
      ["BncEst", ->(r) { r.bounce_estimate.round(2) }, :right],
      ["Complete%", :percent_complete, :right],

      [
        "At",
        ->(r) { [
          "Created:#{inil(r.created_at)}",
          "Started:#{inil(r.started_at)}",
          "Finished:#{inil(r.finished_at)}",
        ].join("\n") },
        :right,
      ],

      ["Filename", :filename],

      ["ExecTime", :execution_time, :right],
    ]

    table = Table.new(
      headings: headings.map { |ar| ar[0] },
      rows: [headings.map { |ar| get_table_value(response, ar) }],
    ).align!(headings)

    stdout.puts "\n#{label}:"
    stdout.puts table
  end

  "Total".tap do |label|
    headings = [
      ["BadSyntax", :bad_syntax, :right],
      ["Billable", :billable, :right],
      ["Catchall", :catchall, :right],
      ["Disposable", :disposable, :right],
      ["Duplicates", :duplicates, :right],
      ["Invalid", :invalid, :right],
      ["Processed", :processed, :right],
      ["Records", :records, :right],
      ["Unknown", :unknown, :right],
      ["Valid", :valid, :right],
    ]

    table = Table.new(
      headings: headings.map { |ar| ar[0] },
      rows: [headings.map { |ar| get_table_value(response.total, ar) }],
    ).align!(headings)

    stdout.puts "\n#{label}:"
    stdout.puts table
  end

  0
end