Class: Circler::Build
- Inherits:
-
Object
- Object
- Circler::Build
- Defined in:
- lib/circler/response/build.rb
Class Method Summary collapse
- .all(username, reponame) ⇒ Object
- .branch(username, reponame, branch) ⇒ Object
- .cancel(username, reponame, number) ⇒ Object
- .get(username, reponame, number) ⇒ Object
- .retry(username, reponame, number) ⇒ Object
Instance Method Summary collapse
- #build_number ⇒ Object
- #channel_name ⇒ Object
- #information ⇒ Object
-
#initialize(hash) ⇒ Build
constructor
A new instance of Build.
- #project_name ⇒ Object
- #reponame ⇒ Object
- #running? ⇒ Boolean
- #status ⇒ Object
- #steps ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(hash) ⇒ Build
Returns a new instance of Build.
31 32 33 |
# File 'lib/circler/response/build.rb', line 31 def initialize(hash) @hash = hash end |
Class Method Details
.all(username, reponame) ⇒ Object
6 7 8 9 10 |
# 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) ⇒ Object
12 13 14 15 16 |
# 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) ⇒ Object
26 27 28 |
# 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 |
Instance Method Details
#build_number ⇒ Object
47 48 49 |
# File 'lib/circler/response/build.rb', line 47 def build_number @hash['build_num'] end |
#channel_name ⇒ Object
55 56 57 |
# File 'lib/circler/response/build.rb', line 55 def channel_name "private-#{username}@#{reponame}@#{build_number}@vcs-github@0" end |
#information ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# 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 ⇒ Object
59 60 61 |
# File 'lib/circler/response/build.rb', line 59 def project_name "#{username}/#{reponame}" end |
#reponame ⇒ Object
39 40 41 |
# File 'lib/circler/response/build.rb', line 39 def reponame @hash['reponame'] end |
#running? ⇒ Boolean
51 52 53 |
# File 'lib/circler/response/build.rb', line 51 def running? status == 'running' end |
#status ⇒ Object
43 44 45 |
# File 'lib/circler/response/build.rb', line 43 def status @hash['status'] end |
#steps ⇒ Object
75 76 77 78 |
# 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 ⇒ Object
35 36 37 |
# File 'lib/circler/response/build.rb', line 35 def username @hash['username'] end |