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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pact_broker (0.0.8)
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.1.0)
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.4)
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.5)
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.0)
42
+ nokogiri (1.6.1)
45
43
  mini_portile (~> 0.5.0)
46
- pact (1.0.20)
47
- awesome_print (~> 1.1.0)
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.6)
74
- rspec-expectations (2.14.3)
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.4.0)
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.1)
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
- BASE_URL_PLACEHOLDER = "http://_______PACT_BROKER_BASE_URL_PLACEHOLDER_TO_BE_REPLACED_AFTER_TO_JSON_______"
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 last_version_url pacticipant
20
- "#{pacticipant_url(pacticipant)}/versions/last"
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
- "#{base_url_placeholder}/pacts/latest"
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
- "#{base_url_placeholder}/pact/provider/#{url_encode(pact.provider.name)}/consumer/#{url_encode(pact.consumer.name)}"
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 :last_version, :class => PactBroker::Models::Version, :extend => PactBroker::Api::Decorators::VersionRepresenter, :embedded => true
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 :last_version do
22
- last_version_url(represented)
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
@@ -7,8 +7,8 @@ module PactBroker
7
7
 
8
8
  property :number
9
9
 
10
- link :self do
11
- version_url(represented)
10
+ link :self do | options |
11
+ version_url(options[:base_url], represented)
12
12
  end
13
13
  end
14
14
  end
@@ -15,6 +15,7 @@ module PactBroker::Api
15
15
  ["GET"]
16
16
  end
17
17
 
18
+ # TODO change to use request.base_url to avoid params getting included!!!
18
19
  def to_json
19
20
  {
20
21
  _links: {
@@ -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 => 'last'))
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, request_base_url).to_json
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, request_base_url).to_json
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, request_base_url).to_json
22
+ PactBroker::Api::Decorators::PacticipantCollectionRepresenter.new(pacticipants).to_json(base_url: request_base_url)
23
23
  end
24
24
 
25
25
  end
@@ -11,7 +11,7 @@ module PactBroker
11
11
  one_to_many :versions, :order => :order, :reciprocal => :pacticipant
12
12
  one_to_many :pacts
13
13
 
14
- def last_version
14
+ def latest_version
15
15
  versions.last
16
16
  end
17
17
 
@@ -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.execute('select max(id) as id from versions where id in (select distinct(version_id) from pacts) group by pacticipant_id').collect{ | it | it }.flatten
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}).
@@ -25,7 +25,7 @@ module PactBroker
25
25
  PactBroker::Models::Pacticipant.new(name: args[:name], repository_url: args[:repository_url]).save(raise_on_save_failure: true)
26
26
  end
27
27
 
28
- def find_last_version name
28
+ def find_latest_version name
29
29
 
30
30
  end
31
31
 
@@ -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] == 'last'
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])
@@ -7,7 +7,7 @@ module PactBroker
7
7
 
8
8
  extend PactBroker::Repositories
9
9
 
10
- def self.find_last_version name
10
+ def self.find_latest_version name
11
11
 
12
12
  end
13
13
  end
@@ -1,3 +1,3 @@
1
1
  module PactBroker
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
@@ -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
- # honours_pact_with "Pact Broker Client" do
19
- # pact_uri "../pact_broker-client/spec/pacts/pact_broker_client-pact_broker.json"
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 => :prod do
27
- pact_uri URI.encode("http://rea-pact-broker.biq.vpc.realestate.com.au/pacticipants/Pact Broker Client/versions/last/pacts/Pact Broker?tag=prod")
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.8
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: 2013-11-18 00:00:00.000000000 Z
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: -3477467796967438675
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: -3477467796967438675
373
+ hash: 615091496951534936
374
374
  requirements: []
375
375
  rubyforge_project:
376
376
  rubygems_version: 1.8.23