pact_broker 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +13 -18
- data/Rakefile +1 -20
- data/lib/pact_broker/api/decorators/base_decorator.rb +0 -15
- data/lib/pact_broker/api/decorators/pact_broker_urls.rb +18 -24
- data/lib/pact_broker/api/decorators/pact_collection_decorator.rb +4 -4
- data/lib/pact_broker/api/decorators/pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pact_pacticipant_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pacticipant_collection_decorator.rb +4 -4
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +7 -7
- data/lib/pact_broker/api/decorators/version_decorator.rb +2 -2
- data/lib/pact_broker/api/resources/index.rb +1 -0
- data/lib/pact_broker/api/resources/latest_pact.rb +1 -1
- data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
- data/lib/pact_broker/api/resources/pacticipant.rb +1 -1
- data/lib/pact_broker/api/resources/pacticipants.rb +1 -1
- data/lib/pact_broker/models/pacticipant.rb +1 -1
- data/lib/pact_broker/repositories/pact_repository.rb +1 -1
- data/lib/pact_broker/repositories/pacticipant_repository.rb +1 -1
- data/lib/pact_broker/services/pact_service.rb +1 -1
- data/lib/pact_broker/services/version_service.rb +1 -1
- data/lib/pact_broker/version.rb +1 -1
- data/spec/service_consumers/pact_helper.rb +6 -10
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pact_broker (0.0.
|
4
|
+
pact_broker (0.0.9)
|
5
5
|
httparty
|
6
6
|
json
|
7
7
|
roar
|
@@ -14,44 +14,42 @@ GEM
|
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
16
|
as-notifications (1.0.1)
|
17
|
-
awesome_print (1.
|
17
|
+
awesome_print (1.2.0)
|
18
18
|
blockenspiel (0.4.5)
|
19
19
|
builder (3.2.2)
|
20
20
|
ci_reporter (1.9.0)
|
21
21
|
builder (>= 2.1.2)
|
22
22
|
coderay (1.0.9)
|
23
23
|
columnize (0.3.6)
|
24
|
-
daemons (1.1.9)
|
25
24
|
debugger (1.6.2)
|
26
25
|
columnize (>= 0.3.1)
|
27
26
|
debugger-linecache (~> 1.2.0)
|
28
27
|
debugger-ruby_core_source (~> 1.2.3)
|
29
28
|
debugger-linecache (1.2.0)
|
30
29
|
debugger-ruby_core_source (1.2.3)
|
31
|
-
diff-lcs (1.2.
|
32
|
-
eventmachine (1.0.3)
|
30
|
+
diff-lcs (1.2.5)
|
33
31
|
fakefs (0.4.3)
|
34
32
|
find_a_port (1.0.1)
|
35
33
|
httparty (0.12.0)
|
36
34
|
json (~> 1.8)
|
37
35
|
multi_xml (>= 0.5.2)
|
38
|
-
i18n (0.6.
|
36
|
+
i18n (0.6.9)
|
39
37
|
json (1.8.1)
|
40
38
|
method_source (0.8.2)
|
41
39
|
mini_portile (0.5.2)
|
42
40
|
multi_json (1.8.2)
|
43
41
|
multi_xml (0.5.5)
|
44
|
-
nokogiri (1.6.
|
42
|
+
nokogiri (1.6.1)
|
45
43
|
mini_portile (~> 0.5.0)
|
46
|
-
pact (1.0.
|
47
|
-
awesome_print (~> 1.1
|
44
|
+
pact (1.0.26)
|
45
|
+
awesome_print (~> 1.1)
|
48
46
|
find_a_port (~> 1.0.1)
|
49
47
|
json
|
50
48
|
rack-test (~> 0.6.2)
|
51
49
|
randexp (~> 0.1.7)
|
52
50
|
rspec (~> 2.12)
|
53
|
-
thin
|
54
51
|
thor
|
52
|
+
webrick
|
55
53
|
pry (0.9.12.2)
|
56
54
|
coderay (~> 1.0.5)
|
57
55
|
method_source (~> 0.8)
|
@@ -70,13 +68,13 @@ GEM
|
|
70
68
|
rspec-core (~> 2.14.0)
|
71
69
|
rspec-expectations (~> 2.14.0)
|
72
70
|
rspec-mocks (~> 2.14.0)
|
73
|
-
rspec-core (2.14.
|
74
|
-
rspec-expectations (2.14.
|
71
|
+
rspec-core (2.14.7)
|
72
|
+
rspec-expectations (2.14.4)
|
75
73
|
diff-lcs (>= 1.1.3, < 2.0)
|
76
74
|
rspec-fire (1.2.0)
|
77
75
|
rspec (~> 2.11)
|
78
76
|
rspec-mocks (2.14.4)
|
79
|
-
sequel (4.
|
77
|
+
sequel (4.7.0)
|
80
78
|
shotgun (0.9)
|
81
79
|
rack (>= 1.0)
|
82
80
|
simplecov (0.7.1)
|
@@ -85,17 +83,14 @@ GEM
|
|
85
83
|
simplecov-html (0.7.1)
|
86
84
|
slop (3.4.6)
|
87
85
|
sqlite3 (1.3.8)
|
88
|
-
thin (1.6.1)
|
89
|
-
daemons (>= 1.0.9)
|
90
|
-
eventmachine (>= 1.0.0)
|
91
|
-
rack (>= 1.0.0)
|
92
86
|
thor (0.18.1)
|
93
87
|
versionomy (0.4.4)
|
94
88
|
blockenspiel (>= 0.4.5)
|
95
|
-
webmachine (1.2.
|
89
|
+
webmachine (1.2.2)
|
96
90
|
as-notifications (~> 1.0)
|
97
91
|
i18n (>= 0.4.0)
|
98
92
|
multi_json
|
93
|
+
webrick (1.3.1)
|
99
94
|
|
100
95
|
PLATFORMS
|
101
96
|
ruby
|
data/Rakefile
CHANGED
@@ -1,24 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'bundler/gem_helper'
|
4
|
-
module Bundler
|
5
|
-
class GemHelper
|
6
|
-
def install
|
7
|
-
desc "Build #{name}-#{version}.gem into the pkg directory"
|
8
|
-
task 'build' do
|
9
|
-
build_gem
|
10
|
-
end
|
11
|
-
|
12
|
-
desc "Build and install #{name}-#{version}.gem into system gems"
|
13
|
-
task 'install' do
|
14
|
-
install_gem
|
15
|
-
end
|
16
|
-
|
17
|
-
GemHelper.instance = self
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
Bundler::GemHelper.install_tasks
|
2
|
+
require "bundler/gem_tasks"
|
22
3
|
|
23
4
|
require 'rubygems'
|
24
5
|
require 'bundler'
|
@@ -12,21 +12,6 @@ module PactBroker
|
|
12
12
|
include Roar::Representer::JSON::HAL
|
13
13
|
include Roar::Representer::JSON::HAL::Links
|
14
14
|
include PactBroker::Api::PactBrokerUrls
|
15
|
-
|
16
|
-
def initialize represented, base_url = nil
|
17
|
-
super(represented)
|
18
|
-
@base_url = base_url
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_json
|
22
|
-
json = super()
|
23
|
-
if @base_url
|
24
|
-
json.gsub(base_url_placeholder, @base_url)
|
25
|
-
else
|
26
|
-
json
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
15
|
end
|
31
16
|
end
|
32
17
|
end
|
@@ -2,48 +2,42 @@ module PactBroker
|
|
2
2
|
module Api
|
3
3
|
module PactBrokerUrls
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
def base_url_placeholder
|
8
|
-
BASE_URL_PLACEHOLDER
|
9
|
-
end
|
10
|
-
|
11
|
-
def pacticipants_url
|
12
|
-
"#{base_url_placeholder}/pacticipants"
|
5
|
+
def pacticipants_url base_url
|
6
|
+
"#{base_url}/pacticipants"
|
13
7
|
end
|
14
8
|
|
15
|
-
def pacticipant_url pacticipant
|
16
|
-
"#{pacticipants_url}/#{url_encode(pacticipant.name)}"
|
9
|
+
def pacticipant_url base_url, pacticipant
|
10
|
+
"#{pacticipants_url(base_url)}/#{url_encode(pacticipant.name)}"
|
17
11
|
end
|
18
12
|
|
19
|
-
def
|
20
|
-
"#{pacticipant_url(pacticipant)}/versions/
|
13
|
+
def latest_version_url base_url, pacticipant
|
14
|
+
"#{pacticipant_url(base_url, pacticipant)}/versions/latest"
|
21
15
|
end
|
22
16
|
|
23
|
-
def versions_url pacticipant
|
24
|
-
"#{pacticipant_url(pacticipant)}/versions"
|
17
|
+
def versions_url base_url, pacticipant
|
18
|
+
"#{pacticipant_url(base_url, pacticipant)}/versions"
|
25
19
|
end
|
26
20
|
|
27
|
-
def version_url version
|
28
|
-
"#{pacticipant_url(version.pacticipant)}/versions/#{version.number}"
|
21
|
+
def version_url base_url, version
|
22
|
+
"#{pacticipant_url(base_url, version.pacticipant)}/versions/#{version.number}"
|
29
23
|
end
|
30
24
|
|
31
|
-
def pact_url pact
|
32
|
-
"#{pactigration_base_url(pact)}/version/#{pact.consumer.version.number}"
|
25
|
+
def pact_url base_url, pact
|
26
|
+
"#{pactigration_base_url(base_url, pact)}/version/#{pact.consumer.version.number}"
|
33
27
|
end
|
34
28
|
|
35
|
-
def latest_pact_url pact
|
36
|
-
"#{pactigration_base_url(pact)}/latest"
|
29
|
+
def latest_pact_url base_url, pact
|
30
|
+
"#{pactigration_base_url(base_url, pact)}/latest"
|
37
31
|
end
|
38
32
|
|
39
|
-
def latest_pacts_url
|
40
|
-
"#{
|
33
|
+
def latest_pacts_url base_url
|
34
|
+
"#{base_url}/pacts/latest"
|
41
35
|
end
|
42
36
|
|
43
37
|
private
|
44
38
|
|
45
|
-
def pactigration_base_url pact
|
46
|
-
"#{
|
39
|
+
def pactigration_base_url base_url, pact
|
40
|
+
"#{base_url}/pact/provider/#{url_encode(pact.provider.name)}/consumer/#{url_encode(pact.consumer.name)}"
|
47
41
|
end
|
48
42
|
|
49
43
|
def url_encode param
|
@@ -23,13 +23,13 @@ module PactBroker
|
|
23
23
|
PactBroker::Api::Decorators::RepresentablePact.new(pact)
|
24
24
|
end
|
25
25
|
|
26
|
-
link :self do
|
27
|
-
latest_pacts_url
|
26
|
+
link :self do | options |
|
27
|
+
latest_pacts_url(options[:base_url])
|
28
28
|
end
|
29
29
|
|
30
30
|
# This is the LATEST pact URL
|
31
|
-
links :pacts do
|
32
|
-
represented.collect{ | pact | {:href => latest_pact_url(pact), :title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}" } }
|
31
|
+
links :pacts do | options |
|
32
|
+
represented.collect{ | pact | {:href => latest_pact_url(options[:base_url], pact), :title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}" } }
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -12,8 +12,8 @@ module PactBroker
|
|
12
12
|
property :consumer, :extend => PactBroker::Api::Decorators::PactPacticipantRepresenter, :embedded => true
|
13
13
|
property :provider, :extend => PactBroker::Api::Decorators::PactPacticipantRepresenter, :embedded => true
|
14
14
|
|
15
|
-
link :self do
|
16
|
-
pact_url(represented)
|
15
|
+
link :self do | options |
|
16
|
+
pact_url(options[:base_url], represented)
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
@@ -15,8 +15,8 @@ module PactBroker
|
|
15
15
|
property :repository_url
|
16
16
|
property :version, :class => "PactBroker::Models::Version", :extend => PactBroker::Api::Decorators::VersionRepresenter, :embedded => true
|
17
17
|
|
18
|
-
link :self do
|
19
|
-
pacticipant_url(represented)
|
18
|
+
link :self do | options |
|
19
|
+
pacticipant_url(options[:base_url], represented)
|
20
20
|
end
|
21
21
|
|
22
22
|
end
|
@@ -36,12 +36,12 @@ module PactBroker
|
|
36
36
|
represented
|
37
37
|
end
|
38
38
|
|
39
|
-
link :self do
|
40
|
-
pacticipants_url
|
39
|
+
link :self do | options |
|
40
|
+
pacticipants_url options[:base_url]
|
41
41
|
end
|
42
42
|
|
43
|
-
links :pacticipants do
|
44
|
-
represented.collect{ | pacticipant | {:href => pacticipant_url(pacticipant), :title => pacticipant.name } }
|
43
|
+
links :pacticipants do | options |
|
44
|
+
represented.collect{ | pacticipant | {:href => pacticipant_url(options[:base_url], pacticipant), :title => pacticipant.name } }
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -12,18 +12,18 @@ module PactBroker
|
|
12
12
|
property :name
|
13
13
|
property :repository_url
|
14
14
|
|
15
|
-
property :
|
15
|
+
property :latest_version, :class => PactBroker::Models::Version, :extend => PactBroker::Api::Decorators::VersionRepresenter, :embedded => true
|
16
16
|
|
17
|
-
link :self do
|
18
|
-
pacticipant_url(represented)
|
17
|
+
link :self do | options |
|
18
|
+
pacticipant_url(options[:base_url], represented)
|
19
19
|
end
|
20
20
|
|
21
|
-
link :
|
22
|
-
|
21
|
+
link :latest_version do | options |
|
22
|
+
latest_version_url(options[:base_url], represented)
|
23
23
|
end
|
24
24
|
|
25
|
-
link :versions do
|
26
|
-
versions_url(represented)
|
25
|
+
link :versions do | options |
|
26
|
+
versions_url(options[:base_url], represented)
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -15,7 +15,7 @@ module PactBroker::Api
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def resource_exists?
|
18
|
-
@pact = pact_service.find_pact(identifier_from_path.merge(:consumer_version_number => '
|
18
|
+
@pact = pact_service.find_pact(identifier_from_path.merge(:consumer_version_number => 'latest'))
|
19
19
|
@pact != nil
|
20
20
|
end
|
21
21
|
|
@@ -19,7 +19,7 @@ module PactBroker::Api
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def generate_json pacts
|
22
|
-
PactBroker::Api::Decorators::PactCollectionRepresenter.new(pacts
|
22
|
+
PactBroker::Api::Decorators::PactCollectionRepresenter.new(pacts).to_json(base_url: request_base_url)
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -55,7 +55,7 @@ module PactBroker::Api
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def generate_json pacticipant
|
58
|
-
PactBroker::Api::Decorators::PacticipantRepresenter.new(pacticipant
|
58
|
+
PactBroker::Api::Decorators::PacticipantRepresenter.new(pacticipant).to_json(base_url: request_base_url)
|
59
59
|
end
|
60
60
|
|
61
61
|
def params
|
@@ -19,7 +19,7 @@ module PactBroker::Api
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def generate_json pacticipants
|
22
|
-
PactBroker::Api::Decorators::PacticipantCollectionRepresenter.new(pacticipants
|
22
|
+
PactBroker::Api::Decorators::PacticipantCollectionRepresenter.new(pacticipants).to_json(base_url: request_base_url)
|
23
23
|
end
|
24
24
|
|
25
25
|
end
|
@@ -15,7 +15,7 @@ module PactBroker
|
|
15
15
|
|
16
16
|
# TODO Work out a more elegant and efficient way of executing this query.
|
17
17
|
# Haven't found a max/group by combination that works with Sequel Models
|
18
|
-
latest_versions = PactBroker::Models::Version.new.db.
|
18
|
+
latest_versions = PactBroker::Models::Version.new.db.fetch('select max(id) as id from versions where id in (select distinct(version_id) from pacts) group by pacticipant_id').collect{ | it | it[:id] }.flatten
|
19
19
|
|
20
20
|
PactBroker::Models::Pact.select(:pacts__id, :pacts__json_content, :pacts__version_id, :pacts__provider_id, :versions__number___consumer_version_number).
|
21
21
|
join(:versions, {:id => :version_id}, {implicit_qualifier: :pacts}).
|
@@ -10,7 +10,7 @@ module PactBroker
|
|
10
10
|
extend PactBroker::Repositories
|
11
11
|
|
12
12
|
def find_pact params
|
13
|
-
if params[:consumer_version_number] == '
|
13
|
+
if params[:consumer_version_number] == 'latest'
|
14
14
|
pact_repository.find_latest_pact(params[:consumer_name], params[:provider_name])
|
15
15
|
else
|
16
16
|
pact_repository.find_pact(params[:consumer_name], params[:consumer_version_number], params[:provider_name])
|
data/lib/pact_broker/version.rb
CHANGED
@@ -13,18 +13,14 @@ Pact.configure do | config |
|
|
13
13
|
end
|
14
14
|
|
15
15
|
Pact.service_provider "Pact Broker" do
|
16
|
-
app { PactBroker::API }
|
16
|
+
# app { PactBroker::API }
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
# end
|
21
|
-
|
22
|
-
honours_pact_with "Pact Broker Client", :ref => :head do
|
23
|
-
pact_uri URI.encode("http://rea-pact-broker.biq.vpc.realestate.com.au/pacticipants/Pact Broker Client/versions/last/pacts/Pact Broker")
|
18
|
+
honours_pact_with "Pact Broker Client" do
|
19
|
+
pact_uri "../pact_broker-client/spec/pacts/pact_broker_client-pact_broker.json"
|
24
20
|
end
|
25
21
|
|
26
|
-
honours_pact_with "Pact Broker Client", :ref => :
|
27
|
-
|
28
|
-
end
|
22
|
+
# honours_pact_with "Pact Broker Client", :ref => :head do
|
23
|
+
# pact_uri URI.encode("http://rea-pact-broker.biq.vpc.realestate.com.au/pact/provider/Pact Broker/consumer/Pact Broker Client/latest")
|
24
|
+
# end
|
29
25
|
|
30
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact_broker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -361,7 +361,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
361
361
|
version: '0'
|
362
362
|
segments:
|
363
363
|
- 0
|
364
|
-
hash:
|
364
|
+
hash: 615091496951534936
|
365
365
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
366
366
|
none: false
|
367
367
|
requirements:
|
@@ -370,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
370
370
|
version: '0'
|
371
371
|
segments:
|
372
372
|
- 0
|
373
|
-
hash:
|
373
|
+
hash: 615091496951534936
|
374
374
|
requirements: []
|
375
375
|
rubyforge_project:
|
376
376
|
rubygems_version: 1.8.23
|