Class: Circler::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/circler/response/build.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Build



29
30
31
# File 'lib/circler/response/build.rb', line 29

def initialize(hash)
  @hash = hash
end

Class Method Details

.all(username, reponame) ⇒ Object



4
5
6
7
8
# File 'lib/circler/response/build.rb', line 4

def all(username, reponame)
  CircleCi::Project.recent_builds(username, reponame)
    .body
    .map { |b| Build.new(b) }
end

.branch(username, reponame, branch) ⇒ Object



10
11
12
13
14
# File 'lib/circler/response/build.rb', line 10

def branch(username, reponame, branch)
  CircleCi::Project.recent_builds_branch(username, reponame, branch)
    .body
    .map { |b| Build.new(b) }
end

.cancel(username, reponame, number) ⇒ Object



24
25
26
# File 'lib/circler/response/build.rb', line 24

def cancel(username, reponame, number)
   Build.new(CircleCi::Build.cancel(username, reponame, number).body)
end

.get(username, reponame, number) ⇒ Object



16
17
18
# File 'lib/circler/response/build.rb', line 16

def get(username, reponame, number)
  Build.new(CircleCi::Build.get(username, reponame, number).body)
end

.retry(username, reponame, number) ⇒ Object



20
21
22
# File 'lib/circler/response/build.rb', line 20

def retry(username, reponame, number)
  Build.new(CircleCi::Build.retry(username, reponame, number).body)
end

Instance Method Details

#build_numberObject



45
46
47
# File 'lib/circler/response/build.rb', line 45

def build_number
  @hash['build_num']
end

#channel_nameObject



53
54
55
# File 'lib/circler/response/build.rb', line 53

def channel_name
  "private-#{username}@#{reponame}@#{build_number}@vcs-github@0"
end

#informationObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/circler/response/build.rb', line 57

def information
  [
    @hash['build_num'],
    colorize_by_status(@hash['status'], @hash['status']),
    colorize_by_status(@hash['branch'], @hash['status']),
    @hash['author_name'],
    (@hash['subject'] || '').slice(0..60),
    format_time(@hash['build_time_millis']),
    @hash['start_time'],
  ]
end

#reponameObject



37
38
39
# File 'lib/circler/response/build.rb', line 37

def reponame
  @hash['reponame']
end

#running?Boolean



49
50
51
# File 'lib/circler/response/build.rb', line 49

def running?
  status == 'running'
end

#statusObject



41
42
43
# File 'lib/circler/response/build.rb', line 41

def status
  @hash['status']
end

#stepsObject



69
70
71
72
# File 'lib/circler/response/build.rb', line 69

def steps
  hash = @hash['steps'].group_by { |s| s['actions'].first['type'] }
  hash.flat_map { |type, value| value.map{ |v| Step.new(type, v) }}
end

#usernameObject



33
34
35
# File 'lib/circler/response/build.rb', line 33

def username
  @hash['username']
end