Class: Travis::CLI::Show

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

Constant Summary

Constants inherited from RepoCommand

RepoCommand::GIT_REGEX

Instance Attribute Summary

Attributes inherited from RepoCommand

#slug

Attributes inherited from ApiCommand

#session

Attributes inherited from Command

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

Instance Method Summary collapse

Methods inherited from RepoCommand

#repository, #setup

Methods inherited from ApiCommand

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

Methods included from Travis::Client::Methods

#access_token, #access_token=, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #job, #listen, #repo, #repos, #restart, #user, #worker, #workers

Methods inherited from Command

abstract, abstract?, #check_ruby, #check_version, command_name, #command_name, #debug, description, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, #terminal, #usage, #write_to

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
# 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
end