Class: CircleCI::CLI::Command::BuildRepository
- Inherits:
-
Object
- Object
- CircleCI::CLI::Command::BuildRepository
- Defined in:
- lib/circleci/cli/command/watch_command/build_repository.rb
Instance Method Summary collapse
- #build_for(build_number) ⇒ Object
- #builds_to_show ⇒ Object
-
#initialize(username, reponame, branch: nil, user: nil) ⇒ BuildRepository
constructor
A new instance of BuildRepository.
- #mark_as_shown(build_number) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(username, reponame, branch: nil, user: nil) ⇒ BuildRepository
Returns a new instance of BuildRepository.
7 8 9 10 11 12 13 14 |
# File 'lib/circleci/cli/command/watch_command/build_repository.rb', line 7 def initialize(username, reponame, branch: nil, user: nil) @username = username @user = user @reponame = reponame @branch = branch @builds = Response::Build.all(@username, @reponame) @build_numbers_shown = @builds.select(&:finished?).map(&:build_number) end |
Instance Method Details
#build_for(build_number) ⇒ Object
38 39 40 |
# File 'lib/circleci/cli/command/watch_command/build_repository.rb', line 38 def build_for(build_number) @builds.find { |build| build.build_number == build_number } end |
#builds_to_show ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/circleci/cli/command/watch_command/build_repository.rb', line 30 def builds_to_show @builds .reject { |build| @build_numbers_shown.include?(build.build_number) } .select { |build| @branch.nil? || build.branch == @branch } .select { |build| @user.nil? || build.user == @user } .sort_by(&:build_number) end |
#mark_as_shown(build_number) ⇒ Object
26 27 28 |
# File 'lib/circleci/cli/command/watch_command/build_repository.rb', line 26 def mark_as_shown(build_number) @build_numbers_shown = (@build_numbers_shown + [build_number]).uniq end |
#update ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/circleci/cli/command/watch_command/build_repository.rb', line 16 def update response = if @branch Response::Build.branch(@username, @reponame, @branch) else Response::Build.all(@username, @reponame) end @builds = (response + @builds).uniq(&:build_number) end |