Class: CircleCI::CLI::Response::Build
- Inherits:
-
Object
- Object
- CircleCI::CLI::Response::Build
- Defined in:
- lib/circleci/cli/response/build.rb
Instance Attribute Summary collapse
-
#author_name ⇒ Object
readonly
Returns the value of attribute author_name.
-
#build_number ⇒ Object
readonly
Returns the value of attribute build_number.
-
#reponame ⇒ Object
readonly
Returns the value of attribute reponame.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#workflow_job_name ⇒ Object
readonly
Returns the value of attribute workflow_job_name.
-
#workflow_name ⇒ Object
readonly
Returns the value of attribute workflow_name.
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
- #channel_name ⇒ Object
- #finished? ⇒ Boolean
- #information ⇒ Object
-
#initialize(hash) ⇒ Build
constructor
A new instance of Build.
- #project_name ⇒ Object
- #running? ⇒ Boolean
- #steps ⇒ Object
Constructor Details
#initialize(hash) ⇒ Build
Returns a new instance of Build.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/circleci/cli/response/build.rb', line 36 def initialize(hash) @hash = hash @username = hash['username'] @build_number = hash['build_num'] @reponame = hash['reponame'] @status = hash['status'] = hash['author_name'] @start_time = hash['start_time'] @workflow_name = hash.dig('workflows', 'workflow_name') @workflow_job_name = hash.dig('workflows', 'job_name') end |
Instance Attribute Details
#author_name ⇒ Object (readonly)
Returns the value of attribute author_name.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def end |
#build_number ⇒ Object (readonly)
Returns the value of attribute build_number.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def build_number @build_number end |
#reponame ⇒ Object (readonly)
Returns the value of attribute reponame.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def reponame @reponame end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def start_time @start_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def status @status end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def username @username end |
#workflow_job_name ⇒ Object (readonly)
Returns the value of attribute workflow_job_name.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def workflow_job_name @workflow_job_name end |
#workflow_name ⇒ Object (readonly)
Returns the value of attribute workflow_name.
33 34 35 |
# File 'lib/circleci/cli/response/build.rb', line 33 def workflow_name @workflow_name end |
Class Method Details
.all(username, reponame) ⇒ Object
8 9 10 11 12 |
# File 'lib/circleci/cli/response/build.rb', line 8 def all(username, reponame) CircleCi::Project.new(username, reponame, 'github').recent_builds .body .map { |b| Build.new(b) } end |
.branch(username, reponame, branch) ⇒ Object
14 15 16 17 18 |
# File 'lib/circleci/cli/response/build.rb', line 14 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
28 29 30 |
# File 'lib/circleci/cli/response/build.rb', line 28 def cancel(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).cancel.body) end |
.get(username, reponame, number) ⇒ Object
20 21 22 |
# File 'lib/circleci/cli/response/build.rb', line 20 def get(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).get.body) end |
.retry(username, reponame, number) ⇒ Object
24 25 26 |
# File 'lib/circleci/cli/response/build.rb', line 24 def retry(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).retry.body) end |
Instance Method Details
#channel_name ⇒ Object
56 57 58 |
# File 'lib/circleci/cli/response/build.rb', line 56 def channel_name "private-#{username}@#{reponame}@#{build_number}@vcs-github@0" end |
#finished? ⇒ Boolean
52 53 54 |
# File 'lib/circleci/cli/response/build.rb', line 52 def finished? status == 'success' || status == 'canceled' || status == 'failed' || status == 'no_tests' end |
#information ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/circleci/cli/response/build.rb', line 64 def information [ build_number, colorize_by_status(status, status), colorize_by_status(@hash['branch'], status), , (@hash['subject'] || '').slice(0..60), format_time(@hash['build_time_millis']), start_time ] end |
#project_name ⇒ Object
60 61 62 |
# File 'lib/circleci/cli/response/build.rb', line 60 def project_name "#{username}/#{reponame}" end |
#running? ⇒ Boolean
48 49 50 |
# File 'lib/circleci/cli/response/build.rb', line 48 def running? status == 'running' || status || 'queued' end |
#steps ⇒ Object
76 77 78 79 |
# File 'lib/circleci/cli/response/build.rb', line 76 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 |