class PactBroker::Pacts::PactParams
Public Class Methods
from_path_info(path_info)
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 13 def self.from_path_info path_info new( consumer_name: path_info.fetch(:consumer_name), provider_name: path_info.fetch(:provider_name), consumer_version_number: path_info[:consumer_version_number], revision_number: path_info[:revision_number], pact_version_sha: path_info[:pact_version_sha] ) end
from_request(request, path_info)
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 23 def self.from_request request, path_info json_content = request.body.to_s parsed_content = begin parsed = JSON.parse(json_content, PACT_PARSING_OPTIONS) json_content = parsed.to_json # remove whitespace parsed rescue {} end consumer_name_in_pact = parsed_content.is_a?(Hash) ? parsed_content.fetch("consumer",{})["name"] : nil provider_name_in_pact = parsed_content.is_a?(Hash) ? parsed_content.fetch("provider",{})["name"] : nil new( consumer_name: path_info.fetch(:consumer_name), provider_name: path_info.fetch(:provider_name), revision_number: path_info[:revision_number], consumer_version_number: path_info[:consumer_version_number], pact_version_sha: path_info[:pact_version_sha], consumer_name_in_pact: consumer_name_in_pact, provider_name_in_pact: provider_name_in_pact, json_content: json_content ) end
new(attributes)
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 9 def initialize attributes merge!(attributes) end
Public Instance Methods
consumer()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 84 def consumer PacticipantName.new(consumer_name, consumer_name_in_pact, "consumer") end
consumer_name()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 52 def consumer_name self[:consumer_name] end
consumer_name_in_pact()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 76 def consumer_name_in_pact self[:consumer_name_in_pact] end
consumer_version_number()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 60 def consumer_version_number self[:consumer_version_number] end
json_content()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 72 def json_content self[:json_content] end
pact_version_sha()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 64 def pact_version_sha self[:pact_version_sha] end
pacticipant_names()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 48 def pacticipant_names [consumer_name, provider_name] end
provider()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 88 def provider PacticipantName.new(provider_name, provider_name_in_pact, "provider") end
provider_name()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 56 def provider_name self[:provider_name] end
provider_name_in_pact()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 80 def provider_name_in_pact self[:provider_name_in_pact] end
revision_number()
click to toggle source
# File lib/pact_broker/pacts/pact_params.rb, line 68 def revision_number self[:revision_number] end