pact_broker 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +5 -13
  2. data/.gitignore +0 -1
  3. data/.rspec +1 -0
  4. data/CHANGELOG.md +47 -0
  5. data/README.md +4 -2
  6. data/config.ru +3 -5
  7. data/db/migrations/09_add_timestamps.rb +12 -0
  8. data/db/migrations/10_populate_timestamps.rb +15 -0
  9. data/db/migrations/11_made_timestamps_mandatory.rb +20 -0
  10. data/db/migrations/12_create_webhooks_table.rb +21 -0
  11. data/db/migrations/13_add_columns_to_webhooks.rb +8 -0
  12. data/lib/pact_broker/api.rb +14 -0
  13. data/lib/pact_broker/api/decorators.rb +2 -2
  14. data/lib/pact_broker/api/decorators/base_decorator.rb +2 -1
  15. data/lib/pact_broker/api/decorators/basic_pacticipant_decorator.rb +21 -0
  16. data/lib/pact_broker/api/decorators/decorator_context.rb +20 -0
  17. data/lib/pact_broker/api/decorators/latest_pact_decorator.rb +2 -2
  18. data/lib/pact_broker/api/decorators/pact_decorator.rb +12 -5
  19. data/lib/pact_broker/api/decorators/pact_details_decorator.rb +22 -0
  20. data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +6 -4
  21. data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +25 -3
  22. data/lib/pact_broker/api/decorators/representable_pact.rb +3 -1
  23. data/lib/pact_broker/api/decorators/tag_decorator.rb +3 -0
  24. data/lib/pact_broker/api/decorators/webhook_decorator.rb +52 -0
  25. data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +58 -0
  26. data/lib/pact_broker/api/decorators/webhook_request_decorator.rb +18 -0
  27. data/lib/pact_broker/api/decorators/webhooks_decorator.rb +37 -0
  28. data/lib/pact_broker/api/pact_broker_urls.rb +16 -0
  29. data/lib/pact_broker/api/renderers/html_pact_renderer.rb +2 -1
  30. data/lib/pact_broker/api/resources/base_resource.rb +12 -1
  31. data/lib/pact_broker/api/resources/group.rb +38 -0
  32. data/lib/pact_broker/api/resources/index.rb +30 -21
  33. data/lib/pact_broker/api/resources/latest_pact.rb +1 -1
  34. data/lib/pact_broker/api/resources/latest_pacts.rb +1 -1
  35. data/lib/pact_broker/api/resources/pact.rb +18 -2
  36. data/lib/pact_broker/api/resources/pact_webhooks.rb +87 -0
  37. data/lib/pact_broker/api/resources/pacticipant.rb +15 -6
  38. data/lib/pact_broker/api/resources/pacticipants.rb +1 -1
  39. data/lib/pact_broker/api/resources/tag.rb +2 -2
  40. data/lib/pact_broker/api/resources/webhook.rb +44 -0
  41. data/lib/pact_broker/api/resources/webhook_execution.rb +43 -0
  42. data/lib/pact_broker/api/resources/webhooks.rb +29 -0
  43. data/lib/pact_broker/app.rb +46 -8
  44. data/lib/pact_broker/db.rb +10 -0
  45. data/lib/pact_broker/doc/controllers/app.rb +32 -0
  46. data/lib/pact_broker/doc/views/latest-pacts.markdown +3 -0
  47. data/lib/pact_broker/doc/views/layouts/main.haml +5 -0
  48. data/lib/pact_broker/doc/views/pacticipants.markdown +10 -0
  49. data/lib/pact_broker/doc/views/self.markdown +8 -0
  50. data/lib/pact_broker/doc/views/webhooks.markdown +48 -0
  51. data/lib/pact_broker/functions/groupify.rb +39 -0
  52. data/lib/pact_broker/jobs/after_pact_save.rb +13 -0
  53. data/lib/pact_broker/json.rb +4 -0
  54. data/lib/pact_broker/locale/en.yml +23 -0
  55. data/lib/pact_broker/messages.rb +18 -0
  56. data/lib/pact_broker/models/group.rb +21 -0
  57. data/lib/pact_broker/models/pact.rb +4 -2
  58. data/lib/pact_broker/models/pacticipant.rb +3 -1
  59. data/lib/pact_broker/models/relationship.rb +34 -0
  60. data/lib/pact_broker/models/tag.rb +3 -1
  61. data/lib/pact_broker/models/version.rb +3 -1
  62. data/lib/pact_broker/models/webhook.rb +53 -0
  63. data/lib/pact_broker/models/webhook_execution_result.rb +26 -0
  64. data/lib/pact_broker/models/webhook_request.rb +107 -0
  65. data/lib/pact_broker/models/webhook_request_header.rb +13 -0
  66. data/lib/pact_broker/repositories.rb +6 -0
  67. data/lib/pact_broker/repositories/pact_repository.rb +25 -7
  68. data/lib/pact_broker/repositories/pacticipant_repository.rb +4 -0
  69. data/lib/pact_broker/repositories/webhook_repository.rb +134 -0
  70. data/lib/pact_broker/services.rb +10 -0
  71. data/lib/pact_broker/services/group_service.rb +24 -0
  72. data/lib/pact_broker/services/pact_service.rb +37 -7
  73. data/lib/pact_broker/services/pacticipant_service.rb +12 -1
  74. data/lib/pact_broker/services/webhook_service.rb +63 -0
  75. data/lib/pact_broker/tasks.rb +0 -1
  76. data/lib/pact_broker/ui/controllers/base_controller.rb +1 -0
  77. data/lib/pact_broker/ui/controllers/groups.rb +25 -0
  78. data/lib/pact_broker/ui/controllers/relationships.rb +0 -2
  79. data/lib/pact_broker/ui/helpers/url_helper.rb +17 -0
  80. data/lib/pact_broker/ui/view_models/relationship.rb +13 -4
  81. data/lib/pact_broker/ui/view_models/relationships.rb +1 -1
  82. data/lib/pact_broker/ui/views/groups/show.html.erb +409 -0
  83. data/lib/pact_broker/ui/views/relationships/show.haml +4 -2
  84. data/lib/pact_broker/version.rb +1 -1
  85. data/pact_broker.gemspec +7 -6
  86. data/public/{d3.v3.js.pagespeed.ce.dFNRrGTALe.js → javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js} +0 -0
  87. data/public/stylesheets/relationships.css +4 -0
  88. data/spec/integration/endpoints/group.rb +22 -0
  89. data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +49 -0
  90. data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +25 -0
  91. data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +7 -4
  92. data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +121 -0
  93. data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +69 -0
  94. data/spec/lib/pact_broker/api/decorators/webhook_request_decorator_spec.rb +78 -0
  95. data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +46 -0
  96. data/spec/lib/pact_broker/api/resources/group_spec.rb +80 -0
  97. data/spec/lib/pact_broker/api/resources/pact_spec.rb +41 -0
  98. data/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb +184 -0
  99. data/spec/lib/pact_broker/api/resources/pacticipant_spec.rb +71 -0
  100. data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +77 -0
  101. data/spec/lib/pact_broker/api/resources/webhook_spec.rb +60 -0
  102. data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +44 -0
  103. data/spec/lib/pact_broker/doc/controllers/app_spec.rb +51 -0
  104. data/spec/lib/pact_broker/functions/groupify_spec.rb +50 -0
  105. data/spec/lib/pact_broker/models/group_spec.rb +26 -0
  106. data/spec/lib/pact_broker/models/webhook_request_spec.rb +175 -0
  107. data/spec/lib/pact_broker/models/webhook_spec.rb +59 -0
  108. data/spec/lib/pact_broker/repositories/pact_repository_spec.rb +40 -0
  109. data/spec/lib/pact_broker/repositories/webhook_repository_spec.rb +257 -0
  110. data/spec/lib/pact_broker/services/group_service_spec.rb +52 -0
  111. data/spec/lib/pact_broker/services/pact_service_spec.rb +49 -0
  112. data/spec/lib/pact_broker/services/pacticipant_service_spec.rb +50 -0
  113. data/spec/lib/pact_broker/services/webhook_service_spec.rb +51 -0
  114. data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +20 -6
  115. data/spec/lib/pact_broker/ui/view_models/relationships_spec.rb +33 -0
  116. data/spec/service_consumers/provider_states_for_pact_broker_client.rb +1 -1
  117. data/spec/spec_helper.rb +11 -4
  118. data/spec/support/provider_state_builder.rb +11 -0
  119. data/spec/support/shared_examples_for_responses.rb +25 -0
  120. data/vendor/hal-browser/js/hal/views/embedded_resource.js +3 -3
  121. data/vendor/hal-browser/js/hal/views/resource.js +3 -3
  122. metadata +174 -80
  123. data/assets/d3.v3.js +0 -9263
  124. data/assets/force.csv +0 -29
  125. data/assets/index.html +0 -186
  126. data/assets/index2.html +0 -224
  127. data/assets/relationships +0 -4
  128. data/assets/stylesheets/github.css +0 -387
  129. data/lib/pact_broker/tasks/delete.rake +0 -20
  130. data/public/Network Graph REA.html +0 -48
  131. data/public/rea.csv +0 -10
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NmJjZTUwYWI2YzdiZmM0OTc5ODQ4NWI5MWVjYTBlNTU5N2ZiNTUyNA==
5
- data.tar.gz: !binary |-
6
- NDQ0NzY2ZGJiODViN2ZkZTZlNjBkNTJiNGRkNzJkODQ5MzU0MWFiMA==
2
+ SHA1:
3
+ metadata.gz: cedb84e67d02ce7d28e31fdc09aca4c39fa19e98
4
+ data.tar.gz: 4fa9e9b2022aa04df878b8cd6769a9d9ad36e1a6
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDAzMWI0ZGM2ZTQxZTZmOGQ1ZmE3MjczMWU1NTE1OTE5NmExOGNjMjc2YzI4
10
- NGRlZThkNjBlY2M2ZDdhM2M4YWI3N2E2MGQ0MTgzNjhiOGIxY2NmN2NkN2Vh
11
- MzZjZTU3OTMzMGZhOTMxYjIzYjYwODc3NzAyMDJhYjFjYTEwNGU=
12
- data.tar.gz: !binary |-
13
- YTFjYmI0YmUxY2JhMzE3NmMxODkyOTM0ZWQxNWIzMTg0ZDZkNTFlOGE1OTJj
14
- ODlhY2Q5NWQ1Y2JjMmU3OWQyOTQzYzcwYmIwM2NjZTllNmE2YjE5M2NhMTNk
15
- ZWYyMjM1YjcxZGJmMjk1YWVhNGJmNzgyZjVjY2U3YmFmMTczYWE=
6
+ metadata.gz: 7f756c1fc77440d7805ceeda97220d64dd1ad1f8f0fd940eb9f2be76f683bc5b7bb3c5ea8e4f6a8fd3a65f9b39951f58faba1537722ac5e6c3ff40b84d6310e5
7
+ data.tar.gz: a4ed85b29750424cc833bfe1bec6b43805304f2c006bd61fe0612eabd703a38110317a7a5d74a6900e429337db60def0a344d829ff5436ae05688504ae4ed355
data/.gitignore CHANGED
@@ -17,7 +17,6 @@ reports
17
17
  # YARD artifacts
18
18
  .yardoc
19
19
  _yardoc
20
- doc/
21
20
  .bin
22
21
 
23
22
  # Editor files
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
2
  --format documentation
3
+ --require spec_helper
@@ -2,6 +2,53 @@ Do this to generate your change history
2
2
 
3
3
  $ git log --pretty=format:' * %h - %s (%an, %ad)'
4
4
 
5
+ #### 1.1.0 (2014-08-21)
6
+
7
+ * d25395b - Fixed pacts failing to publish because of too deeply nested JSON (Beth, Tue Aug 19 11:13:02 2014 +1000)
8
+ * 9288c98 - Saving password in Base64 just so it is not plain text. WIP (Beth, Tue Aug 19 09:14:53 2014 +1000)
9
+ * 6a40151 - Added username and password to webhook request (Beth, Mon Aug 18 22:02:48 2014 +1000)
10
+ * 6eb0d70 - Added mouseover for relationship paths (Beth, Fri Aug 15 15:38:56 2014 +1000)
11
+ * 8e916fc - Added clickable relationship links (Beth, Fri Aug 15 11:37:57 2014 +1000)
12
+ * 7fc6418 - Added webhook HAL documentation. (Beth, Tue Aug 12 17:17:08 2014 +1000)
13
+ * 434fbe8 - Added useful rels to help navigate between webhook resources. (Beth, Tue Aug 12 09:14:08 2014 +1000)
14
+ * 959675b - Adding description to webhooks link (Beth, Mon Aug 11 21:46:39 2014 +1000)
15
+ * 9cbf2b1 - Added webhook test execution endpoint. (Beth, Mon Aug 11 21:37:47 2014 +1000)
16
+ * 6bdfd16 - Webhooks belonging to a pacticipant will be deleted when the pacticipant is deleted. (Beth, Mon Aug 11 14:16:50 2014 +1000)
17
+ * 27572e2 - WIP - ensuring webhook executes when a pact version is overridden and changed. (Beth, Fri Aug 8 16:59:48 2014 +1000)
18
+ * 2469ad5 - Adding webhook DELETE (Beth, Fri Aug 8 16:45:48 2014 +1000)
19
+ * 7ae9b59 - Adding code to execte webhook and to detect when pact content has changed (Beth, Fri Aug 8 10:13:16 2014 +1000)
20
+ * c8289fb - Adding /webhooks resource (Beth, Thu Aug 7 16:57:27 2014 +1000)
21
+ * 2d818ee - Added endpoint to retrieve webhook by UUID (Beth, Thu Aug 7 14:35:04 2014 +1000)
22
+ * 25c3866 - Completed web hooks resource. (Beth, Wed Aug 6 11:38:39 2014 +1000)
23
+ * a59e46e - Started work on webhooks (Beth, Sat Aug 2 18:12:16 2014 +1000)
24
+ * 56d9ae5 - Return 400 error for pacts with invalid JSON (Beth, Sat Aug 2 07:08:39 2014 +1000)
25
+ * 884aa06 - Added links from relationship page to group. (Beth, Thu Jul 31 20:05:55 2014 +1000)
26
+ * 642570e - Adding group UI endpoint. (Beth, Thu Jul 31 17:36:37 2014 +1000)
27
+ * 3609028 - Adding a group resource (Beth, Mon Jul 28 09:11:46 2014 +1000)
28
+ * 437df9e - Added created_at and updated_at timestamps to all objects. (Beth, Fri Jul 25 16:53:46 2014 +1000)
29
+ * 594f160 - Turning exception showing on (Beth, Fri Jul 25 08:59:57 2014 +1000)
30
+ * 7250a51 - Updated to pact 1.3.0 (Beth, Thu Jul 24 12:13:38 2014 +1000)
31
+ * 9824247 - Implemented DELETE for pacticipant resource (Beth, Tue Jun 10 17:32:26 2014 +1000)
32
+ * 1c65600 - Swapped links and properties order in the HAL browser, because the documents are large, and scrolling to the bottom of the page to click around is annoying. (Beth, Fri Jun 6 10:19:47 2014 +1000)
33
+
34
+ #### 1.0.0 (2014-06-06)
35
+
36
+ * ed25adb - Sorting relationships by consumer name, then provider name. (Beth, Wed May 21 15:13:39 2014 +1000)
37
+ * 7aae530 - Releasing version 1.0.0.alpha3 (Beth, Mon May 19 15:44:33 2014 +1000)
38
+ * 53e24cb - Increased json_content size from text to mediumtext (16MB) (Beth, Mon May 19 15:43:32 2014 +1000)
39
+ * 1f65546 - Releasing 1.0.0.alpha2 (Beth, Mon May 19 12:49:42 2014 +1000)
40
+ * 3714ab5 - Adding network graph spike files (Beth, Sat May 17 21:12:04 2014 +1000)
41
+ * 73e2b81 - Implemented finding latest pact by tag (Beth, Sat May 17 17:56:58 2014 +1000)
42
+ * bfa62cc - Changed /pact to /pacts because it is more RESTy (Beth, Sat May 17 12:22:55 2014 +1000)
43
+ * 91c8fab - Releasing 1.0.0.alpha1 (Beth, Fri May 9 15:21:13 2014 +1000)
44
+ * f497f13 - Made HtmlPactRenderer configurable in case shokkenki want to use the PactBroker ;) (Beth, Fri May 9 14:20:38 2014 +1000)
45
+ * 5343019 - Added Relationship UI (Beth, Fri May 9 12:23:30 2014 +1000)
46
+ * f7270a6 - Added HTML rendering of latest pact. Added /relationships CSV endpoint. (Beth, Thu May 8 16:17:52 2014 +1000)
47
+ * 264e16b - Created nice interface for making a pact_broker instance (Beth, Sat Apr 26 16:43:07 2014 +1000)
48
+ * 8001792 - Added HAL browser (Beth, Wed Apr 23 13:31:25 2014 +1000)
49
+ * 8c94d1f - Creating example app (Beth, Wed Apr 23 13:06:40 2014 +1000)
50
+
51
+
5
52
  #### 0.0.10 (2014-06-06)
6
53
 
7
54
  * 24daeea - Added task to delete pacticipant (bethesque Tue May 20 11:59:10 2014 +1000)
data/README.md CHANGED
@@ -21,10 +21,12 @@ See the [Pact Broker Client](https://github.com/bethesque/pact_broker-client) fo
21
21
 
22
22
  ## Usage
23
23
 
24
+ * Create a database using a product that is supported by the Sequel gem (listed on this page http://sequel.jeremyevans.net/rdoc/files/README_rdoc.html). At time of writing, Sequel has adapters for: ADO, Amalgalite, CUBRID, DataObjects, DB2, DBI, Firebird, IBM_DB, Informix, JDBC, MySQL, Mysql2, ODBC, OpenBase, Oracle, PostgreSQL, SQLAnywhere, SQLite3, Swift, and TinyTDS
25
+ * Install ruby 1.9.3 or later
24
26
  * Copy the [example](/example) directory to your workstation.
25
- * Modify the config.ru and Gemfile as desired (eg. choose database driver gem)
27
+ * Modify the config.ru and Gemfile as desired (eg. choose database driver gem, set your database credentials)
26
28
  * Run `bundle`
27
29
  * Run `bundle exec rackup`
28
30
  * Open [http://localhost:9292](http://localhost:9292) and you should see the HAL browser.
29
31
 
30
- For production usage, use a web application server like Phusion Passenger to serve the Pact Broker application.
32
+ For production usage, use a web application server like [Phusion Passenger](https://www.phusionpassenger.com) to serve the Pact Broker application.
data/config.ru CHANGED
@@ -5,13 +5,11 @@ require 'rack/hal_browser'
5
5
  require 'pact_broker/ui/controllers/relationships'
6
6
 
7
7
 
8
- use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js"], :root => "public"
9
- use Rack::HalBrowser::Redirect, :exclude => ['/diagnostic', '/trace','/index','/force.csv']
8
+ use Rack::Static, :urls => ["/stylesheets", "/css", "/fonts", "/js", "/javascripts"], :root => "public"
9
+ use Rack::HalBrowser::Redirect, :exclude => ['/diagnostic', '/trace','/index']
10
10
 
11
11
  run Rack::URLMap.new(
12
12
  '/ui/relationships' => PactBroker::UI::Controllers::Relationships,
13
- '/index.html' => Rack::File.new("#{File.dirname(__FILE__)}/assets/index.html"),
14
- '/index2.html' => Rack::File.new("#{File.dirname(__FILE__)}/assets/index2.html"),
15
- '/force.csv' => Rack::File.new("#{File.dirname(__FILE__)}/assets/force.csv"),
13
+ '/network-graph' => Rack::File.new("#{File.dirname(__FILE__)}/public/Network Graph REA.html"),
16
14
  '/' => PactBroker::API,
17
15
  )
@@ -0,0 +1,12 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column(:pacts, :created_at, DateTime)
4
+ add_column(:pacts, :updated_at, DateTime)
5
+ add_column(:tags, :created_at, DateTime)
6
+ add_column(:tags, :updated_at, DateTime)
7
+ add_column(:versions, :created_at, DateTime)
8
+ add_column(:versions, :updated_at, DateTime)
9
+ add_column(:pacticipants, :created_at, DateTime)
10
+ add_column(:pacticipants, :updated_at, DateTime)
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ Sequel.migration do
2
+ up do
3
+ self[:pacts].update(:created_at => DateTime.now, :updated_at => DateTime.now)
4
+ self[:versions].update(:created_at => DateTime.now, :updated_at => DateTime.now)
5
+ self[:pacticipants].update(:created_at => DateTime.now, :updated_at => DateTime.now)
6
+ self[:tags].update(:created_at => DateTime.now, :updated_at => DateTime.now)
7
+ end
8
+
9
+ down do
10
+ self[:pacts].update(:created_at => nil, :updated_at => nil)
11
+ self[:versions].update(:created_at => nil, :updated_at => nil)
12
+ self[:pacticipants].update(:created_at => nil, :updated_at => nil)
13
+ self[:tags].update(:created_at => nil, :updated_at => nil)
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ Sequel.migration do
2
+ change do
3
+ alter_table(:tags) do
4
+ set_column_not_null(:created_at)
5
+ set_column_not_null(:updated_at)
6
+ end
7
+ alter_table(:pacticipants) do
8
+ set_column_not_null(:created_at)
9
+ set_column_not_null(:updated_at)
10
+ end
11
+ alter_table(:versions) do
12
+ set_column_not_null(:created_at)
13
+ set_column_not_null(:updated_at)
14
+ end
15
+ alter_table(:pacts) do
16
+ set_column_not_null(:created_at)
17
+ set_column_not_null(:updated_at)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ Sequel.migration do
2
+ change do
3
+ create_table(:webhooks) do
4
+ primary_key :id
5
+ String :uuid, null: false, unique: true, unique_constraint_name: 'uq_webhook_uuid'
6
+ String :method, null: false
7
+ String :url, null: false
8
+ String :body
9
+ Boolean :is_json_request_body
10
+ foreign_key :consumer_id, :pacticipants, null: false, foreign_key_constraint_name: 'fk_webhooks_consumer'
11
+ foreign_key :provider_id, :pacticipants, null: false, foreign_key_constraint_name: 'fk_webhooks_provider'
12
+ end
13
+
14
+ create_table(:webhook_headers) do
15
+ String :name, null: false
16
+ String :value
17
+ foreign_key :webhook_id, :webhooks, null: false, foreign_key_constraint_name: 'fk_webhookheaders_webhooks'
18
+ primary_key [:webhook_id, :name], :name=>:webhooks_headers_pk
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,8 @@
1
+ Sequel.migration do
2
+ change do
3
+ add_column(:webhooks, :created_at, DateTime)
4
+ add_column(:webhooks, :updated_at, DateTime)
5
+ add_column(:webhooks, :username, String)
6
+ add_column(:webhooks, :password, String)
7
+ end
8
+ end
@@ -6,6 +6,11 @@ require 'pact_broker/api/resources/pacticipants'
6
6
  require 'pact_broker/api/resources/tag'
7
7
  require 'pact_broker/api/resources/index'
8
8
  require 'pact_broker/api/resources/relationships'
9
+ require 'pact_broker/api/resources/group'
10
+ require 'pact_broker/api/resources/pact_webhooks'
11
+ require 'pact_broker/api/resources/webhooks'
12
+ require 'pact_broker/api/resources/webhook'
13
+ require 'pact_broker/api/resources/webhook_execution'
9
14
 
10
15
  require 'webmachine/adapters/rack'
11
16
 
@@ -27,6 +32,15 @@ module PactBroker
27
32
  add ['pacticipants', :name], Api::Resources::Pacticipant
28
33
  add ['pacticipants', :pacticipant_name, 'versions', :pacticipant_version_number, 'tags', :tag_name], Api::Resources::Tag
29
34
  add ['relationships'], Api::Resources::Relationships
35
+ add ['groups', :pacticipant_name], Api::Resources::Group
36
+ # If the HTML and the CSV resources are both requested by the browser,
37
+ # Chrome gets confused by the content types, and when you click back, it tries to load the CSV
38
+ # instead of the HTML page. So we have to give it a different URL.
39
+ add ['groups', :pacticipant_name, 'csv'], Api::Resources::Group
40
+ add ['webhooks', 'provider', :provider_name, 'consumer', :consumer_name ], Api::Resources::PactWebhooks
41
+ add ['webhooks', :uuid ], Api::Resources::Webhook
42
+ add ['webhooks', :uuid, 'execute' ], Api::Resources::WebhookExecution
43
+ add ['webhooks'], Api::Resources::Webhooks
30
44
  add [], Api::Resources::Index
31
45
  end
32
46
  end
@@ -3,5 +3,5 @@ require 'pact_broker/api/decorators/pacticipant_collection_decorator'
3
3
  require 'pact_broker/api/decorators/version_decorator'
4
4
  require 'pact_broker/api/decorators/pact_collection_decorator'
5
5
  require 'pact_broker/api/decorators/pact_pacticipant_decorator'
6
- require 'pact_broker/api/decorators/pact_decorator'
7
- require 'pact_broker/api/decorators/tag_decorator'
6
+ require 'pact_broker/api/decorators/pact_details_decorator'
7
+ require 'pact_broker/api/decorators/tag_decorator'
@@ -1,6 +1,7 @@
1
1
  require 'roar/decorator'
2
2
  require 'roar/representer/json/hal'
3
3
  require 'pact_broker/api/pact_broker_urls'
4
+ require 'pact_broker/api/decorators/decorator_context'
4
5
 
5
6
  module PactBroker
6
7
 
@@ -15,4 +16,4 @@ module PactBroker
15
16
  end
16
17
  end
17
18
  end
18
- end
19
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'base_decorator'
2
+ require_relative 'version_decorator'
3
+
4
+ module PactBroker
5
+
6
+ module Api
7
+
8
+ module Decorators
9
+
10
+ class BasicPacticipantRepresenter < BaseDecorator
11
+
12
+ property :name
13
+
14
+ link :self do | options |
15
+ pacticipant_url(options[:base_url], represented)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module PactBroker
2
+ module Api
3
+ module Decorators
4
+
5
+ class DecoratorContext < Hash
6
+
7
+ attr_reader :base_url, :resource_url, :resource_title
8
+
9
+ def initialize base_url, resource_url, options
10
+ @base_url = base_url
11
+ @resource_url = resource_url
12
+ @resource_title = options[:resource_title]
13
+ merge!(options)
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -1,4 +1,4 @@
1
- require_relative 'pact_decorator'
1
+ require_relative 'pact_details_decorator'
2
2
 
3
3
  module PactBroker
4
4
 
@@ -6,7 +6,7 @@ module PactBroker
6
6
 
7
7
  module Decorators
8
8
 
9
- class LatestPactDecorator < PactDecorator
9
+ class LatestPactDecorator < PactDetailsDecorator
10
10
 
11
11
  links :self do | options |
12
12
  [
@@ -1,5 +1,5 @@
1
1
  require_relative 'base_decorator'
2
- require_relative 'pact_pacticipant_decorator'
2
+ require 'pact_broker/json'
3
3
 
4
4
  module PactBroker
5
5
 
@@ -9,11 +9,18 @@ module PactBroker
9
9
 
10
10
  class PactDecorator < BaseDecorator
11
11
 
12
- property :consumer, :extend => PactBroker::Api::Decorators::PactPacticipantRepresenter, :embedded => true
13
- property :provider, :extend => PactBroker::Api::Decorators::PactPacticipantRepresenter, :embedded => true
12
+ property :createdAt, getter: lambda { |_| created_at.xmlschema }
13
+ property :updatedAt, getter: lambda { |_| updated_at.xmlschema }
14
14
 
15
- link :self do | options |
16
- pact_url(options[:base_url], represented)
15
+ def to_hash(options = {})
16
+ ::JSON.parse(represented.json_content, PACT_PARSING_OPTIONS).merge super
17
+ end
18
+
19
+ link :'pact-webhooks' do | options |
20
+ {
21
+ title: 'Webhooks for this pact',
22
+ href: webhooks_for_pact_url(represented.consumer, represented.provider, options.fetch(:base_url))
23
+ }
17
24
  end
18
25
 
19
26
  end
@@ -0,0 +1,22 @@
1
+ require_relative 'base_decorator'
2
+ require_relative 'pact_pacticipant_decorator'
3
+
4
+ module PactBroker
5
+
6
+ module Api
7
+
8
+ module Decorators
9
+
10
+ class PactDetailsDecorator < BaseDecorator
11
+
12
+ property :consumer, :extend => PactBroker::Api::Decorators::PactPacticipantRepresenter, :embedded => true
13
+ property :provider, :extend => PactBroker::Api::Decorators::PactPacticipantRepresenter, :embedded => true
14
+
15
+ link :self do | options |
16
+ pact_url(options[:base_url], represented)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -10,15 +10,17 @@ module PactBroker
10
10
  class PacticipantRepresenter < BaseDecorator
11
11
 
12
12
  property :name
13
- property :repository_url
13
+ property :repository_url, as: :repositoryUrl
14
+ property :latest_version, as: :'latest-version', :class => PactBroker::Models::Version, :extend => PactBroker::Api::Decorators::VersionRepresenter, :embedded => true
15
+ property :createdAt, getter: lambda { |_| created_at.xmlschema }
16
+ property :updatedAt, getter: lambda { |_| updated_at.xmlschema }
14
17
 
15
- property :latest_version, :class => PactBroker::Models::Version, :extend => PactBroker::Api::Decorators::VersionRepresenter, :embedded => true
16
18
 
17
19
  link :self do | options |
18
20
  pacticipant_url(options[:base_url], represented)
19
21
  end
20
22
 
21
- link :latest_version do | options |
23
+ link 'latest-version' do | options |
22
24
  latest_version_url(options[:base_url], represented)
23
25
  end
24
26
 
@@ -29,4 +31,4 @@ module PactBroker
29
31
  end
30
32
  end
31
33
  end
32
- end
34
+ end
@@ -1,4 +1,5 @@
1
1
  require 'csv'
2
+ require 'set'
2
3
 
3
4
  module PactBroker
4
5
 
@@ -10,16 +11,37 @@ module PactBroker
10
11
 
11
12
  def initialize pacts
12
13
  @pacts = pacts
14
+ @relationships = pacts.collect{|pact| PactBroker::Models::Relationship.new(pact.consumer,pact.provider)}
13
15
  end
14
16
 
15
17
  def to_csv
18
+ hash = {}
19
+ pacticipants = @relationships.collect{|r| r.pacticipants}.flatten.uniq
20
+
21
+ @relationships.each do | relationship |
22
+ hash[relationship.consumer.id] ||= pacticipant_array(relationship.consumer, hash.size + 1)
23
+ hash[relationship.provider.id] ||= pacticipant_array(relationship.provider, hash.size + 1)
24
+ hash[relationship.consumer.id] << relationship.provider.id
25
+ end
26
+
27
+ max_length = hash.values.collect{|array| array.size}.max
28
+
29
+ hash.values.each do | array |
30
+ while array.size < max_length
31
+ array << 0
32
+ end
33
+ end
16
34
 
17
35
  CSV.generate do |csv|
18
- csv << ["source", "target", "weight"]
19
- pacts.each do | pact |
20
- csv << [pact.consumer.name, pact.provider.name, 1]
36
+ hash.values.each do | array |
37
+ csv << array
21
38
  end
22
39
  end
40
+
41
+ end
42
+
43
+ def pacticipant_array pacticipant, order
44
+ [pacticipant.id, pacticipant.name, 1, 1, 0, order]
23
45
  end
24
46
 
25
47
  private