class Jobly::Commands::SendCmd

Public Instance Methods

run() click to toggle source
# File lib/jobly/commands/send.rb, line 16
def run
  job = args['JOB']
  params = args['PARAMS'].to_params
  url = "#{Jobly.api_url}/#{job}"

  args = [url]
  args << { params: params } unless params.empty?

  response = client.get(*args)

  raise HTTPError, "#{response.code} #{response.reason}" unless response.status.ok?

  say "!txtgrn!#{response.code} #{response.reason}"
  puts response.parse.to_yaml
end

Private Instance Methods

client() click to toggle source
# File lib/jobly/commands/send.rb, line 34
def client
  @client ||= client!
end
client!() click to toggle source
# File lib/jobly/commands/send.rb, line 38
def client!
  if Jobly.auth
    user, pass = Jobly.auth.split ':'
    HTTP.basic_auth user: user, pass: pass
  else
    HTTP
  end
end