class PactBroker::Api::Resources::CanIMergeBadge

Public Instance Methods

badge_url() click to toggle source
# File lib/pact_broker/api/resources/can_i_merge_badge.rb, line 10
def badge_url 
  if pacticipant.nil? # pacticipant method is defined in BaseResource
    # if the pacticipant is nil, we return an error badge url
    badge_service.error_badge_url("pacticipant", "not found")
  elsif version.nil?
    # when there is no main branch version, we return an error badge url
    badge_service.error_badge_url("main branch version", "not found")
  else
    # when badge is available, set cache based on configuration
    set_cache_control(default_cache_for_succesful_badge)
    # we call badge_service to build the badge url
    badge_service.can_i_merge_badge_url(deployable: results)
  end
end

Private Instance Methods

default_cache_for_succesful_badge() click to toggle source
# File lib/pact_broker/api/resources/can_i_merge_badge.rb, line 27
def default_cache_for_succesful_badge
  PactBroker.configuration.badge_default_cache_setting
end
results() click to toggle source
# File lib/pact_broker/api/resources/can_i_merge_badge.rb, line 31
def results
  # can_i_merge returns true or false if the main branch version is compatible with all the integrations
  @results ||= matrix_service.can_i_merge(pacticipant: pacticipant, latest_main_branch_version: version)
end
version() click to toggle source
# File lib/pact_broker/api/resources/can_i_merge_badge.rb, line 36
def version
  @version ||= version_service.find_latest_version_from_main_branch(pacticipant) 
end