Class: Yarr::EvaluatorService::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/yarr/evaluator_service.rb

Overview

response of the web request

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Response


56
57
58
# File 'lib/yarr/evaluator_service.rb', line 56

def initialize(data)
  @data = JSON.parse(data)
end

Instance Method Details

#outputObject

unified stdout / stderr with appropriate rocket / stderr prefix


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

def output
  out = stdout.chomp # truncator outputs max one line
  out.prepend('# => ') unless out.empty?
  err = stderr
  err.prepend('stderr: ') unless err.empty?

  Message::Truncator.truncate(
    out << ' ' << err,
    omission: '... check link for more',
    suffix: " (#{url})"
  )
end

#urlObject

url that points to the evaluation


61
62
63
# File 'lib/yarr/evaluator_service.rb', line 61

def url
  @data['run_request']['run']['html_url']
end