Module: PactBroker::Api::Paths

Extended by:
Paths
Included in:
Authorization::ResourceAccessPolicy, Paths
Defined in:
lib/pact_broker/api/paths.rb

Constant Summary collapse

PACT_BADGE_PATH =
%r{^/pacts/provider/[^/]+/consumer/.*/badge(?:\.[A-Za-z]+)?$}.freeze
MATRIX_BADGE_PATH =
%r{^/matrix/provider/[^/]+/latest/[^/]+/consumer/[^/]+/latest/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze
CAN_I_DEPLOY_BADGE_PATH =
%r{^/pacticipants/[^/]+/latest-version/[^/]+/can-i-deploy/to/[^/]+/badge(?:\.[A-Za-z]+)?$}.freeze
VERIFICATION_RESULTS =
%r{^/pacts/provider/[^/]+/consumer/[^/]+/pact-version/[^/]+/verification-results/[^/]+}

Instance Method Summary collapse

Instance Method Details

#is_badge_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/pact_broker/api/paths.rb', line 15

def is_badge_path?(path)
  # Optimise by checking include? first - regexp slow
  path.include?("/badge") && (path =~ PACT_BADGE_PATH || path =~ MATRIX_BADGE_PATH || path =~ CAN_I_DEPLOY_BADGE_PATH)
end

#is_verification_results_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/pact_broker/api/paths.rb', line 11

def is_verification_results_path?(path)
  path.start_with?("/pacts") && (path =~ VERIFICATION_RESULTS)
end