class Circler::Build
Public Class Methods
all(username, reponame)
click to toggle source
# File lib/circler/response/build.rb, line 6 def all(username, reponame) CircleCi::Project.new(username, reponame, 'github').recent_builds .body .map { |b| Build.new(b) } end
branch(username, reponame, branch)
click to toggle source
# File lib/circler/response/build.rb, line 12 def branch(username, reponame, branch) CircleCi::Project.new(username, reponame, 'github').recent_builds_branch(branch) .body .map { |b| Build.new(b) } end
cancel(username, reponame, number)
click to toggle source
# File lib/circler/response/build.rb, line 26 def cancel(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).cancel.body) end
get(username, reponame, number)
click to toggle source
# File lib/circler/response/build.rb, line 18 def get(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).get.body) end
new(hash)
click to toggle source
# File lib/circler/response/build.rb, line 31 def initialize(hash) @hash = hash end
retry(username, reponame, number)
click to toggle source
# File lib/circler/response/build.rb, line 22 def retry(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).retry.body) end
Public Instance Methods
build_number()
click to toggle source
# File lib/circler/response/build.rb, line 47 def build_number @hash['build_num'] end
channel_name()
click to toggle source
# File lib/circler/response/build.rb, line 55 def channel_name "private-#{username}@#{reponame}@#{build_number}@vcs-github@0" end
information()
click to toggle source
# File lib/circler/response/build.rb, line 63 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
project_name()
click to toggle source
# File lib/circler/response/build.rb, line 59 def project_name "#{username}/#{reponame}" end
reponame()
click to toggle source
# File lib/circler/response/build.rb, line 39 def reponame @hash['reponame'] end
running?()
click to toggle source
# File lib/circler/response/build.rb, line 51 def running? status == 'running' end
status()
click to toggle source
# File lib/circler/response/build.rb, line 43 def status @hash['status'] end
steps()
click to toggle source
# File lib/circler/response/build.rb, line 75 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
username()
click to toggle source
# File lib/circler/response/build.rb, line 35 def username @hash['username'] end
Private Instance Methods
colorize_by_status(string, status)
click to toggle source
# File lib/circler/response/build.rb, line 82 def colorize_by_status(string, status) case status when 'success', 'fixed' then string.green when 'canceled' then string.yellow when 'failed' then string.red when 'no_tests', 'not_run' then string.light_black else string end end
format_time(time)
click to toggle source
# File lib/circler/response/build.rb, line 92 def format_time(time) return '' unless time minute = format('%02d', time / 1000 / 60) second = format('%02d', (time / 1000) % 60) "#{minute}:#{second}" end