Class: Circle::CLI::Build

Inherits:
Model
  • Object
show all
Defined in:
lib/circle/cli/build.rb

Constant Summary

Constants inherited from Model

Model::STATUS_COLORS, Model::TIME_FORMAT

Instance Attribute Summary collapse

Attributes inherited from Model

#attributes

Instance Method Summary collapse

Methods inherited from Model

#[]

Constructor Details

#initialize(project, build = {}) ⇒ Build

Returns a new instance of Build.



9
10
11
12
# File 'lib/circle/cli/build.rb', line 9

def initialize(project, build = {})
  @project = project
  super(build)
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



7
8
9
# File 'lib/circle/cli/build.rb', line 7

def project
  @project
end

Instance Method Details

#build_numObject



20
21
22
# File 'lib/circle/cli/build.rb', line 20

def build_num
  self[:build_num]
end

#cancel!Object



52
53
54
# File 'lib/circle/cli/build.rb', line 52

def cancel!
  project.request CircleCi::Build, :cancel, build_num
end

#colorObject



40
41
42
# File 'lib/circle/cli/build.rb', line 40

def color
  color_for self[:status]
end

#detailsObject



56
57
58
# File 'lib/circle/cli/build.rb', line 56

def details
  @details ||= project.request CircleCi::Build, :get, build_num
end

#failed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/circle/cli/build.rb', line 28

def failed?
  self[:outcome] == 'failed'
end

#failing_testsObject



72
73
74
# File 'lib/circle/cli/build.rb', line 72

def failing_tests
  tests.select(&failure_filter)
end

#finished?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/circle/cli/build.rb', line 24

def finished?
  !self[:outcome].nil?
end

#formatted_start_timeObject



44
45
46
# File 'lib/circle/cli/build.rb', line 44

def formatted_start_time
  format_time(self[:start_time]) || 'Not started'
end

#formatted_stop_timeObject



48
49
50
# File 'lib/circle/cli/build.rb', line 48

def formatted_stop_time
  format_time(self[:start_time]) || 'Not finished'
end

#passing_testsObject



68
69
70
# File 'lib/circle/cli/build.rb', line 68

def passing_tests
  tests.reject(&failure_filter)
end

#preloadObject



14
15
16
17
18
# File 'lib/circle/cli/build.rb', line 14

def preload
  tests
  details
  self
end

#statusObject



32
33
34
# File 'lib/circle/cli/build.rb', line 32

def status
  self[:status].tr('_', ' ').capitalize
end

#stepsObject



60
61
62
# File 'lib/circle/cli/build.rb', line 60

def steps
  details['steps'].map { |step| Step.new(step) }
end

#subjectObject



36
37
38
# File 'lib/circle/cli/build.rb', line 36

def subject
  truncate self[:subject]
end

#testsObject



64
65
66
# File 'lib/circle/cli/build.rb', line 64

def tests
  @tests ||= project.request(CircleCi::Build, :tests, build_num)['tests']
end