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

Returns a new instance of Build.



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

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

.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

Instance Method Details

#informationObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/circler/response/build.rb', line 33

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



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

def reponame
  @hash['reponame']
end

#stepsObject



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

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



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

def username
  @hash['username']
end