class Travis::Client::Artifact

Constants

CHUNKED
TEXT

Public Instance Methods

body(stream = block_given?) { |current_body| ... } click to toggle source
# File lib/travis/client/artifact.rb, line 48
def body(stream = block_given?)
  return current_body unless block_given? or stream
  return yield(current_body) unless stream and job.pending?
  number = 0

  session.listen(self) do |listener|
    listener.on 'job:log' do |event|
      next unless event.payload['number'] > number
      number = event.payload['number']
      yield event.payload['_log']
      listener.disconnect if event.payload['final']
    end

    listener.on 'job:finished' do |event|
      listener.disconnect
    end

    listener.on_connect do
      data = session.get_raw("/logs/#{id}", nil, "Accept" => CHUNKED)['log']
      if data['parts']
        data['parts'].each { |p| yield p['content'] }
        number = data['parts'].last['number'] if data['parts'].any?
      else
        yield data['body']
        listener.disconnect
      end
    end
  end
end
clean_body() click to toggle source
# File lib/travis/client/artifact.rb, line 33
def clean_body
  attributes['clean_body'] ||= Tools::SafeString.clean(body)
end
colorized_body() click to toggle source
# File lib/travis/client/artifact.rb, line 29
def colorized_body
  attributes['colorized_body'] ||= Tools::SafeString.colorized(body)
end
current_body() click to toggle source
# File lib/travis/client/artifact.rb, line 37
def current_body
  attributes['current_body'] ||= begin
    body = load_attribute('body')
    if body.to_s.empty?
      log  = session.get_raw("jobs/#{job_id}/log", nil, "Accept" => TEXT)
      body = String === log ? log : log['log']['body']
    end
    body
  end
end
delete_body(reason = {}) click to toggle source
# File lib/travis/client/artifact.rb, line 16
def delete_body(reason = {})
  reason = { :reason => reason } unless reason.is_a? Hash
  session.patch_raw("jobs/#{job_id}/log", reason)
  reload
rescue Travis::Client::Error => error
  raise unless error.message == '409'
  self
end
encoded_body() click to toggle source
# File lib/travis/client/artifact.rb, line 25
def encoded_body
  Tools::SafeString.encoded(body)
end
pusher_entity() click to toggle source
# File lib/travis/client/artifact.rb, line 78
def pusher_entity
  job
end