Skip to content

Commit

Permalink
creating tag hash in constructor and checking for nil tag
Browse files Browse the repository at this point in the history
  • Loading branch information
rashiagarwal committed Jun 22, 2018
1 parent 3b49f03 commit 7d90e13
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/pact/pact_broker/fetch_pacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ class FetchPacts

def initialize(provider, tags, broker_base_url, basic_auth_options)
@provider = provider
@tags = tags
@tags = []
if tags
tags.collect do |tag|
if tag.is_a?(String)
@tags.push({name: tag, all: false})
else
@tags.push(tag)
end
end
end
@broker_base_url = broker_base_url
@http_client = Pact::Hal::HttpClient.new(basic_auth_options)
end
Expand All @@ -33,27 +42,18 @@ def call
def get_tagged_pacts_for_provider
tags.collect do |tag|
link = get_link(tag)
tag_name = get_tag_name(tag)
get_pact_urls(link.expand(provider: provider, tag: tag_name).get)
get_pact_urls(link.expand(provider: provider, tag: tag[:name]).get)
end.flatten
end

def get_link(tag)
if tag.is_a?(String) || tag[:all] == false
if !tag[:all]
index_entity._link(LATEST_PROVIDER_TAG_RELATION)
else
index_entity._link(ALL_PROVIDER_TAG_RELATION)
end
end

def get_tag_name(tag)
if tag.is_a?(String)
tag
else
tag[:name]
end
end

def get_index
response = http_client.get(broker_base_url)
@index_entity = Pact::Hal::Entity.new(response.body, http_client)
Expand Down

0 comments on commit 7d90e13

Please sign in to comment.