Class: NeverBounce::CLI::Script::JobsStatus

Inherits:
RequestMaker show all
Defined in:
lib/never_bounce/cli/script/jobs_status.rb

Constant Summary

Constants inherited from RequestMaker

RequestMaker::SHARED_ENVARS

Instance Attribute Summary collapse

Attributes inherited from RequestMaker

#api_key, #api_url, #request_curl, #response, #server_raw, #session, #user_config

Attributes inherited from Meaningful

#banner_text, #envar_text, #help_text, #options_text

Attributes inherited from Base

#argv, #env, #stderr, #stdout

Instance Method Summary collapse

Methods inherited from RequestMaker

#get_table_value, #inil, #print_curl_request, #print_error_response, #print_server_raw, #slim_main1

Methods inherited from Meaningful

#call_slim_main, error_klasses, format_envar_examples, #handle_help_and_options, #help?, #main, #option_parser, #options

Methods inherited from Base

#env_falsey?, #env_truthy?, env_value_truthy?, #main, #system, #verbose?

Instance Attribute Details

#manifestManifest

Returns:


26
27
28
29
30
31
32
# 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

#requestObject

An API::Request::JobsStatus.

Returns:

  • (Object)

15
16
17
18
19
20
# 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

Instance Method Details

#slim_mainInteger

Returns:

  • (Integer)

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# 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