forked from pact-foundation/pact_broker-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
877 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,10 @@ def body | |
end | ||
end | ||
|
||
def headers | ||
__getobj__().to_hash | ||
end | ||
|
||
def raw_body | ||
__getobj__().body | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
require 'uri' | ||
require 'delegate' | ||
|
||
module PactBroker | ||
module Client | ||
module Hal | ||
class Links | ||
def initialize(href, key, links) | ||
@href = href | ||
@key = key | ||
@links = links | ||
end | ||
|
||
def find(name, not_found_message = nil) | ||
link = links.find{ | link | link.name == name } | ||
if link | ||
link | ||
else | ||
names = links.collect(&:name).compact.uniq | ||
message = not_found_message || "Could not find relation '#{key}' with name '#{name}' in resource at #{href}." | ||
available_options = names.any? ? names.join(", ") : "<none found>" | ||
raise RelationNotFoundError.new(message.chomp(".") + ". Available options: #{available_options}") | ||
end | ||
end | ||
|
||
private | ||
|
||
attr_reader :links, :key, :href | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.