Class: Travis::CLI::Show

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

Constant Summary

Constants inherited from RepoCommand

RepoCommand::GIT_REGEX, 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, #org?, #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, #repo, #repos, #restart, #user

Methods inherited from Command

abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, subcommands, #terminal, #time, #usage, #usage_for, #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

#run(number = last_build.number) ⇒ Object



8
9
10
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
46
47
48
49
50
51
52
53
54
55
# File 'lib/travis/cli/show.rb', line 8

def run(number = last_build.number)
  number = repository.branch(number).number if number !~ /^\d+(\.\d+)?$/ and repository.branch(number)
  entity = job(number) || build(number)

  error "could not find job or build #{repository.slug}##{number}" unless entity

  say template(__FILE__) % [
    entity.class.one.capitalize,
    entity.number,
    entity.commit.subject,
    entity.state,
    entity.color,
    entity.pull_request? ? "pull request" : "push",
    entity.branch_info,
    entity.commit.compare_url,
    formatter.duration(entity.duration),
    formatter.time(entity.started_at),
    formatter.time(entity.finished_at)
  ]

  if entity.respond_to? :jobs
    empty_line
    entity.jobs.each do |job|
      say [
        color("##{job.number} #{job.state}:".ljust(16), [job.color, :bold]),
        formatter.duration(job.duration).ljust(14),
        formatter.job_config(job.config),
        (color("(failure allowed)", :info) if job.allow_failures?)
      ].compact.join(" ").rstrip
    end
  else
    config = formatter.job_config(entity.config)
    say color("Allow Failure: ", :info) + entity.allow_failures?.inspect
    say color("Config:        ", :info) + config unless config.empty?
  end

  if entity.respond_to? :annotations and entity.annotations.any?
    empty_line
    say color("Annotations:", :bold)
    entity.annotations.each do |annotation|
      say [
        color("#{annotation.provider_name} #{annotation.status}:", [annotation.color, :bold]),
        color(annotation.description, annotation.color),
        color("(%s)" % annotation.url, :info)
      ].compact.join(" ").rstrip
    end
  end
end