Class: Travis::CLI::Requests

Inherits:
RepoCommand show all
Defined in:
lib/travis/cli/requests.rb

Constant Summary

Constants inherited from RepoCommand

Travis::CLI::RepoCommand::GIT_REGEX, Travis::CLI::RepoCommand::TRAVIS

Constants inherited from Command

Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK

Constants included from Tools::Assets

Tools::Assets::BASE

Instance Attribute Summary

Attributes inherited from RepoCommand

#slug

Attributes inherited from ApiCommand

#enterprise_name, #session

Attributes inherited from Command

#arguments, #config, #debug, #force_interactive, #formatter, #input, #output

Instance Method Summary collapse

Methods inherited from RepoCommand

#repository, #setup

Methods inherited from ApiCommand

#authenticate, #detected_endpoint?, #endpoint_config, #enterprise?, #initialize, #pro?, #setup, #sync

Methods included from Travis::Client::Methods

#access_token, #access_token=, #account, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #hooks, #job, #lint, #listen, #logout, #regenerate_token, #remove_token, #repo, #repos, #restart, #user

Methods inherited from Command

abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #error, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, subcommands, #terminal, #time, #usage, #usage_for, #warn, #write_to

Methods included from Tools::Assets

asset, asset_path

Methods included from Parser

#new, #on, #on_initialize

Constructor Details

This class inherits a constructor from Travis::CLI::ApiCommand

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/travis/cli/requests.rb', line 11

def run
  requests = repository.requests
  requests = requests[0, Integer(limit)] if limit
  requests.each do |request|
    style ||= :success if request.accepted?
    style ||= :error   if request.rejected?
    style ||= :info

    case request.event_type
    when 'push'
      result      = request.result || 'received'
      message     = request.message
      message   ||= 'validation pending'  unless request.rejected? || request.accepted?
      message   ||= 'unknown reason'      unless request.accepted?
      message   ||= 'triggered new build' unless request.rejected?
      description = "push to #{request.branch || request.tag || '???'}"
    when 'pull_request'
      result      = request.result || 'received'
      message     = request.message
      message   ||= 'HEAD commit not updated' unless request.accepted?
      message   ||= 'triggered new build'     unless request.rejected?
      description = "PR ##{request.pull_request_number}"
    end

    say [
      color(description, [:bold, style]),
      color(result, style),
      color("(#{message})", style)
    ].join(' ').strip + "\n"

    say "  #{color(request.commit.short_sha, :bold)} - #{request.commit.subject}" if request.commit
    say "  received at: #{formatter.time(request.created_at)}"
    empty_line
  end
end