class Sleet::BuildSelector
Attributes
job_name[R]
repo[R]
Public Class Methods
new(repo:, job_name:)
click to toggle source
# File lib/sleet/build_selector.rb, line 5 def initialize(repo:, job_name:) @repo = repo @job_name = job_name end
Public Instance Methods
build()
click to toggle source
# File lib/sleet/build_selector.rb, line 10 def build @build ||= repo.build_for(chosen_build_num) end
validate!()
click to toggle source
# File lib/sleet/build_selector.rb, line 14 def validate! must_find_a_build_with_artifacts! chosen_build_must_have_input_file! end
Private Instance Methods
branch()
click to toggle source
# File lib/sleet/build_selector.rb, line 23 def branch repo.branch end
chosen_build_json()
click to toggle source
# File lib/sleet/build_selector.rb, line 31 def chosen_build_json branch.builds_with_artifacts.find do |b| b.fetch('workflows', nil)&.fetch('job_name', nil) == job_name end end
chosen_build_must_have_input_file!()
click to toggle source
# File lib/sleet/build_selector.rb, line 42 def chosen_build_must_have_input_file! build.artifacts.any? || raise(Error, "No Rspec example file found in the latest build (##{chosen_build_num}) with artifacts") end
chosen_build_num()
click to toggle source
# File lib/sleet/build_selector.rb, line 27 def chosen_build_num chosen_build_json['build_num'] end
must_find_a_build_with_artifacts!()
click to toggle source
# File lib/sleet/build_selector.rb, line 37 def must_find_a_build_with_artifacts! !chosen_build_json.nil? || raise(Error, "No builds with artifacts found#{" for job name [#{job_name}]" if job_name}") end