pact_broker 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +0 -1
- data/.rspec +1 -0
- data/CHANGELOG.md +47 -0
- data/README.md +4 -2
- data/config.ru +3 -5
- data/db/migrations/09_add_timestamps.rb +12 -0
- data/db/migrations/10_populate_timestamps.rb +15 -0
- data/db/migrations/11_made_timestamps_mandatory.rb +20 -0
- data/db/migrations/12_create_webhooks_table.rb +21 -0
- data/db/migrations/13_add_columns_to_webhooks.rb +8 -0
- data/lib/pact_broker/api.rb +14 -0
- data/lib/pact_broker/api/decorators.rb +2 -2
- data/lib/pact_broker/api/decorators/base_decorator.rb +2 -1
- data/lib/pact_broker/api/decorators/basic_pacticipant_decorator.rb +21 -0
- data/lib/pact_broker/api/decorators/decorator_context.rb +20 -0
- data/lib/pact_broker/api/decorators/latest_pact_decorator.rb +2 -2
- data/lib/pact_broker/api/decorators/pact_decorator.rb +12 -5
- data/lib/pact_broker/api/decorators/pact_details_decorator.rb +22 -0
- data/lib/pact_broker/api/decorators/pacticipant_decorator.rb +6 -4
- data/lib/pact_broker/api/decorators/relationships_csv_decorator.rb +25 -3
- data/lib/pact_broker/api/decorators/representable_pact.rb +3 -1
- data/lib/pact_broker/api/decorators/tag_decorator.rb +3 -0
- data/lib/pact_broker/api/decorators/webhook_decorator.rb +52 -0
- data/lib/pact_broker/api/decorators/webhook_execution_result_decorator.rb +58 -0
- data/lib/pact_broker/api/decorators/webhook_request_decorator.rb +18 -0
- data/lib/pact_broker/api/decorators/webhooks_decorator.rb +37 -0
- data/lib/pact_broker/api/pact_broker_urls.rb +16 -0
- data/lib/pact_broker/api/renderers/html_pact_renderer.rb +2 -1
- data/lib/pact_broker/api/resources/base_resource.rb +12 -1
- data/lib/pact_broker/api/resources/group.rb +38 -0
- data/lib/pact_broker/api/resources/index.rb +30 -21
- 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/pact.rb +18 -2
- data/lib/pact_broker/api/resources/pact_webhooks.rb +87 -0
- data/lib/pact_broker/api/resources/pacticipant.rb +15 -6
- data/lib/pact_broker/api/resources/pacticipants.rb +1 -1
- data/lib/pact_broker/api/resources/tag.rb +2 -2
- data/lib/pact_broker/api/resources/webhook.rb +44 -0
- data/lib/pact_broker/api/resources/webhook_execution.rb +43 -0
- data/lib/pact_broker/api/resources/webhooks.rb +29 -0
- data/lib/pact_broker/app.rb +46 -8
- data/lib/pact_broker/db.rb +10 -0
- data/lib/pact_broker/doc/controllers/app.rb +32 -0
- data/lib/pact_broker/doc/views/latest-pacts.markdown +3 -0
- data/lib/pact_broker/doc/views/layouts/main.haml +5 -0
- data/lib/pact_broker/doc/views/pacticipants.markdown +10 -0
- data/lib/pact_broker/doc/views/self.markdown +8 -0
- data/lib/pact_broker/doc/views/webhooks.markdown +48 -0
- data/lib/pact_broker/functions/groupify.rb +39 -0
- data/lib/pact_broker/jobs/after_pact_save.rb +13 -0
- data/lib/pact_broker/json.rb +4 -0
- data/lib/pact_broker/locale/en.yml +23 -0
- data/lib/pact_broker/messages.rb +18 -0
- data/lib/pact_broker/models/group.rb +21 -0
- data/lib/pact_broker/models/pact.rb +4 -2
- data/lib/pact_broker/models/pacticipant.rb +3 -1
- data/lib/pact_broker/models/relationship.rb +34 -0
- data/lib/pact_broker/models/tag.rb +3 -1
- data/lib/pact_broker/models/version.rb +3 -1
- data/lib/pact_broker/models/webhook.rb +53 -0
- data/lib/pact_broker/models/webhook_execution_result.rb +26 -0
- data/lib/pact_broker/models/webhook_request.rb +107 -0
- data/lib/pact_broker/models/webhook_request_header.rb +13 -0
- data/lib/pact_broker/repositories.rb +6 -0
- data/lib/pact_broker/repositories/pact_repository.rb +25 -7
- data/lib/pact_broker/repositories/pacticipant_repository.rb +4 -0
- data/lib/pact_broker/repositories/webhook_repository.rb +134 -0
- data/lib/pact_broker/services.rb +10 -0
- data/lib/pact_broker/services/group_service.rb +24 -0
- data/lib/pact_broker/services/pact_service.rb +37 -7
- data/lib/pact_broker/services/pacticipant_service.rb +12 -1
- data/lib/pact_broker/services/webhook_service.rb +63 -0
- data/lib/pact_broker/tasks.rb +0 -1
- data/lib/pact_broker/ui/controllers/base_controller.rb +1 -0
- data/lib/pact_broker/ui/controllers/groups.rb +25 -0
- data/lib/pact_broker/ui/controllers/relationships.rb +0 -2
- data/lib/pact_broker/ui/helpers/url_helper.rb +17 -0
- data/lib/pact_broker/ui/view_models/relationship.rb +13 -4
- data/lib/pact_broker/ui/view_models/relationships.rb +1 -1
- data/lib/pact_broker/ui/views/groups/show.html.erb +409 -0
- data/lib/pact_broker/ui/views/relationships/show.haml +4 -2
- data/lib/pact_broker/version.rb +1 -1
- data/pact_broker.gemspec +7 -6
- data/public/{d3.v3.js.pagespeed.ce.dFNRrGTALe.js → javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js} +0 -0
- data/public/stylesheets/relationships.css +4 -0
- data/spec/integration/endpoints/group.rb +22 -0
- data/spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb +49 -0
- data/spec/lib/pact_broker/api/decorators/pacticipant_decorator_spec.rb +25 -0
- data/spec/lib/pact_broker/api/decorators/relationships_csv_decorator_spec.rb +7 -4
- data/spec/lib/pact_broker/api/decorators/webhook_decorator_spec.rb +121 -0
- data/spec/lib/pact_broker/api/decorators/webhook_execution_result_decorator_spec.rb +69 -0
- data/spec/lib/pact_broker/api/decorators/webhook_request_decorator_spec.rb +78 -0
- data/spec/lib/pact_broker/api/decorators/webhooks_decorator_spec.rb +46 -0
- data/spec/lib/pact_broker/api/resources/group_spec.rb +80 -0
- data/spec/lib/pact_broker/api/resources/pact_spec.rb +41 -0
- data/spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb +184 -0
- data/spec/lib/pact_broker/api/resources/pacticipant_spec.rb +71 -0
- data/spec/lib/pact_broker/api/resources/webhook_execution_spec.rb +77 -0
- data/spec/lib/pact_broker/api/resources/webhook_spec.rb +60 -0
- data/spec/lib/pact_broker/api/resources/webhooks_spec.rb +44 -0
- data/spec/lib/pact_broker/doc/controllers/app_spec.rb +51 -0
- data/spec/lib/pact_broker/functions/groupify_spec.rb +50 -0
- data/spec/lib/pact_broker/models/group_spec.rb +26 -0
- data/spec/lib/pact_broker/models/webhook_request_spec.rb +175 -0
- data/spec/lib/pact_broker/models/webhook_spec.rb +59 -0
- data/spec/lib/pact_broker/repositories/pact_repository_spec.rb +40 -0
- data/spec/lib/pact_broker/repositories/webhook_repository_spec.rb +257 -0
- data/spec/lib/pact_broker/services/group_service_spec.rb +52 -0
- data/spec/lib/pact_broker/services/pact_service_spec.rb +49 -0
- data/spec/lib/pact_broker/services/pacticipant_service_spec.rb +50 -0
- data/spec/lib/pact_broker/services/webhook_service_spec.rb +51 -0
- data/spec/lib/pact_broker/ui/view_models/relationship_spec.rb +20 -6
- data/spec/lib/pact_broker/ui/view_models/relationships_spec.rb +33 -0
- data/spec/service_consumers/provider_states_for_pact_broker_client.rb +1 -1
- data/spec/spec_helper.rb +11 -4
- data/spec/support/provider_state_builder.rb +11 -0
- data/spec/support/shared_examples_for_responses.rb +25 -0
- data/vendor/hal-browser/js/hal/views/embedded_resource.js +3 -3
- data/vendor/hal-browser/js/hal/views/resource.js +3 -3
- metadata +174 -80
- data/assets/d3.v3.js +0 -9263
- data/assets/force.csv +0 -29
- data/assets/index.html +0 -186
- data/assets/index2.html +0 -224
- data/assets/relationships +0 -4
- data/assets/stylesheets/github.css +0 -387
- data/lib/pact_broker/tasks/delete.rake +0 -20
- data/public/Network Graph REA.html +0 -48
- data/public/rea.csv +0 -10
@@ -8,7 +8,7 @@ module PactBroker
|
|
8
8
|
attr_reader :relationships
|
9
9
|
|
10
10
|
def initialize relationships
|
11
|
-
@relationships = relationships.collect{ |relationship| Relationship.new(relationship) }
|
11
|
+
@relationships = relationships.collect{ |relationship| Relationship.new(relationship) }.sort
|
12
12
|
end
|
13
13
|
|
14
14
|
def each(&block)
|
@@ -0,0 +1,409 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>Network Graph</title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<meta name="description" content="">
|
8
|
+
<meta name="author" content="Duncan Alexander">
|
9
|
+
<script type="text/javascript" src="/javascripts/d3.v3.js.pagespeed.ce.dFNRrGTALe.js"></script>
|
10
|
+
<style>
|
11
|
+
body{
|
12
|
+
font-family:"Helvetica Neue",Arial,sans-serif;
|
13
|
+
font-size:.95em;
|
14
|
+
font-weight:bold;
|
15
|
+
padding:2em
|
16
|
+
}
|
17
|
+
.pacticpantLabel {
|
18
|
+
cursor: default
|
19
|
+
}
|
20
|
+
.relationship {
|
21
|
+
cursor: pointer;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
25
|
+
<!--[if lt IE 9]>
|
26
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
27
|
+
<![endif]-->
|
28
|
+
<!-- developed by Duncan Alexander - hypothete.com -->
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<h1>Network graph of <%= pacticipant_name %> relationships</h1>
|
32
|
+
<script type="text/javascript">
|
33
|
+
var windowWidth, windowHeight, svg;
|
34
|
+
|
35
|
+
var enlargeCanvasToFit = function (radius) {
|
36
|
+
//Make SVG canvas bigger if it won't fit
|
37
|
+
if (3 * radius > windowWidth) {
|
38
|
+
windowWidth = 3 * radius;
|
39
|
+
svg.attr("width", windowWidth);
|
40
|
+
}
|
41
|
+
if (3.5 * radius > windowHeight) {
|
42
|
+
windowHeight = 3.5 * radius;
|
43
|
+
svg.attr("height", windowHeight);
|
44
|
+
}
|
45
|
+
};
|
46
|
+
|
47
|
+
var parseCSV = function (data) {
|
48
|
+
var pacticipants = [];
|
49
|
+
data.forEach(
|
50
|
+
function(row) {
|
51
|
+
var pacticipant = {
|
52
|
+
id: row[0],
|
53
|
+
pacticipantName: row[1],
|
54
|
+
order: parseInt(row[5]),
|
55
|
+
connectedPacticipantIds: row.slice(6).filter(function(e) {
|
56
|
+
if (parseInt(e) != NaN && parseInt(e) > 0) {
|
57
|
+
return e;
|
58
|
+
}
|
59
|
+
})
|
60
|
+
};
|
61
|
+
|
62
|
+
pacticipants.push(pacticipant);
|
63
|
+
});
|
64
|
+
pacticipants.sort(function(a, b) {
|
65
|
+
return d3.ascending(a.order, b.order);
|
66
|
+
});
|
67
|
+
return pacticipants;
|
68
|
+
};
|
69
|
+
|
70
|
+
var getPacticipantNames = function (pacticipants) {
|
71
|
+
return pacticipants.map(function(p){ return p.pacticipantName });
|
72
|
+
};
|
73
|
+
|
74
|
+
var relationshipPath = function(relationship, nodeLocations, pacticipants) {
|
75
|
+
var dx = nodeLocations[relationship.endId].x - nodeLocations[relationship.startId].x;
|
76
|
+
var dy = nodeLocations[relationship.endId].y - nodeLocations[relationship.startId].y;
|
77
|
+
var dr = Math.sqrt(dx * dx + dy * dy);
|
78
|
+
var inout = 1;
|
79
|
+
|
80
|
+
var indexOfEndGreaterThanIndexOfStart = nodeLocations[relationship.endId].i > nodeLocations[relationship.startId].i;
|
81
|
+
var differenceBetweenStartAndEndIndexes = Math.abs(nodeLocations[relationship.endId].i - nodeLocations[relationship.startId].i);
|
82
|
+
var indexOfEndLessThanIndexOfStart = nodeLocations[relationship.endId].i < nodeLocations[relationship.startId].i
|
83
|
+
|
84
|
+
if ((indexOfEndGreaterThanIndexOfStart && differenceBetweenStartAndEndIndexes <= pacticipants.length / 2) || (indexOfEndLessThanIndexOfStart && differenceBetweenStartAndEndIndexes > pacticipants.length / 2)) {
|
85
|
+
inout = 0;
|
86
|
+
}
|
87
|
+
return "M" + 0 + "," + 0 + "A" + dr + ", " + dr + " 0 0," + inout + " " + dx + "," + dy;
|
88
|
+
};
|
89
|
+
|
90
|
+
var latestPactUrl = function (consumerName, providerName) {
|
91
|
+
//TODO send this with the relationship data
|
92
|
+
return '/pacts/provider/' + providerName + '/consumer/' + consumerName + '/latest';
|
93
|
+
};
|
94
|
+
|
95
|
+
var relationshipData = function(pacticipant, relationships) {
|
96
|
+
var relationshipsInvolvingPacticipant = [];
|
97
|
+
var relationshipLinks = [];
|
98
|
+
relationships.forEach(function(relationship) {
|
99
|
+
var dummyRelationship = {};
|
100
|
+
dummyRelationship.id = relationship.id;
|
101
|
+
if (relationship.consumerId == pacticipant.id) {
|
102
|
+
dummyRelationship.startId = relationship.consumerId;
|
103
|
+
dummyRelationship.endId = relationship.providerId;
|
104
|
+
if (relationship.relationshipType) {
|
105
|
+
dummyRelationship.relationshipType = relationship.relationshipType;
|
106
|
+
} else {
|
107
|
+
dummyRelationship.relationshipType = 'consumer';
|
108
|
+
}
|
109
|
+
dummyRelationship.href = relationship.href;
|
110
|
+
relationshipsInvolvingPacticipant.push(dummyRelationship);
|
111
|
+
var relationshipLink = {};
|
112
|
+
relationshipLink.startId = relationship.consumerId;
|
113
|
+
relationshipLink.endId = relationship.providerId;
|
114
|
+
relationshipLink.relationshipType = 'link';
|
115
|
+
relationshipLink.href = relationship.href;
|
116
|
+
relationshipLink.id = relationship.id;
|
117
|
+
relationshipLinks.push(relationshipLink);
|
118
|
+
}
|
119
|
+
else if (relationship.providerId == pacticipant.id) {
|
120
|
+
dummyRelationship.startId = relationship.providerId;
|
121
|
+
dummyRelationship.endId = relationship.consumerId;
|
122
|
+
if (relationship.relationshipType) {
|
123
|
+
dummyRelationship.relationshipType = relationship.relationshipType;
|
124
|
+
} else {
|
125
|
+
dummyRelationship.relationshipType = 'provider';
|
126
|
+
}
|
127
|
+
dummyRelationship.href = relationship.href;
|
128
|
+
relationshipsInvolvingPacticipant.push(dummyRelationship);
|
129
|
+
}
|
130
|
+
});
|
131
|
+
return relationshipLinks.concat(relationshipsInvolvingPacticipant);
|
132
|
+
};
|
133
|
+
|
134
|
+
var createRelationships = function (pacticipants) {
|
135
|
+
var relationships = [];
|
136
|
+
var findPacticipantById = function (id) {
|
137
|
+
return pacticipants.filter(function (pacticipant) {
|
138
|
+
return pacticipant.id == id;
|
139
|
+
})[0];
|
140
|
+
};
|
141
|
+
pacticipants.forEach(function(d) {
|
142
|
+
d.connectedPacticipantIds.forEach(function(connectedPacticipantId) {
|
143
|
+
relationships.push(
|
144
|
+
{
|
145
|
+
id: ['c', d.id, 'p', connectedPacticipantId].join(''),
|
146
|
+
consumerId: d.id,
|
147
|
+
providerId: connectedPacticipantId,
|
148
|
+
href: latestPactUrl(d.pacticipantName, findPacticipantById(connectedPacticipantId).pacticipantName)
|
149
|
+
}
|
150
|
+
);
|
151
|
+
});
|
152
|
+
});
|
153
|
+
|
154
|
+
relationships.sort(function(a, b) {
|
155
|
+
return d3.ascending(a.consumerId, b.providerId);
|
156
|
+
});
|
157
|
+
return relationships;
|
158
|
+
|
159
|
+
};
|
160
|
+
|
161
|
+
var transformPacticipantNode = function (d, i, radius, pacticipants, nodeLocations) {
|
162
|
+
//Node locations - makes the big circle
|
163
|
+
var x = radius * Math.cos(2 * Math.PI * (i / pacticipants.length)) + windowWidth / 2;
|
164
|
+
var y = radius * Math.sin(2 * Math.PI * (i / pacticipants.length)) + windowHeight / 2;
|
165
|
+
nodeLocations[d.id] = {
|
166
|
+
x: x,
|
167
|
+
y: y,
|
168
|
+
i: i
|
169
|
+
};
|
170
|
+
return "translate(" + x + "," + y + ")";
|
171
|
+
};
|
172
|
+
|
173
|
+
var relationshipColour = function(relationship) {
|
174
|
+
return "gray";
|
175
|
+
};
|
176
|
+
|
177
|
+
var fadeAllRelationships = function() {
|
178
|
+
svg.selectAll(".relationship.visible")
|
179
|
+
.transition()
|
180
|
+
.duration(TRANSITION_TIME)
|
181
|
+
.attr("opacity", OPACITY_FADED)
|
182
|
+
.attr("stroke-width", RELATIONSHIP_STROKE_FADED);
|
183
|
+
};
|
184
|
+
|
185
|
+
var boldRelationships = function(relationships) {
|
186
|
+
relationships.transition()
|
187
|
+
.duration(TRANSITION_TIME)
|
188
|
+
.attr("opacity", OPACITY_DARK)
|
189
|
+
.attr("stroke-width", RELATIONSHIP_STROKE_DARK);
|
190
|
+
};
|
191
|
+
|
192
|
+
var normalizeRelationships = function() {
|
193
|
+
svg.selectAll(".relationship.visible")
|
194
|
+
.transition()
|
195
|
+
.duration(TRANSITION_TIME)
|
196
|
+
.attr("stroke-width", RELATIONSHIP_STROKE_NORMAL)
|
197
|
+
.attr("opacity", OPACITY_NORMAL);
|
198
|
+
};
|
199
|
+
|
200
|
+
var pacticipantMouseover = function() {
|
201
|
+
fadeAllRelationships();
|
202
|
+
boldRelationships(
|
203
|
+
d3.select(this.parentNode)
|
204
|
+
.selectAll(".relationship.visible"));
|
205
|
+
};
|
206
|
+
var pacticipantMouseout = function() {
|
207
|
+
normalizeRelationships();
|
208
|
+
};
|
209
|
+
|
210
|
+
var relationshipMouseover = function(relationship) {
|
211
|
+
fadeAllRelationships();
|
212
|
+
boldRelationships( svg.selectAll("." + relationship.id + ".visible") );
|
213
|
+
};
|
214
|
+
|
215
|
+
var relationshipMouseout = function() {
|
216
|
+
normalizeRelationships();
|
217
|
+
};
|
218
|
+
|
219
|
+
var relationshipOnclick = function(relationship) {
|
220
|
+
location.href = relationship.href;
|
221
|
+
};
|
222
|
+
|
223
|
+
var textContent = function(d, i) { return this.parentNode.className.animVal; };
|
224
|
+
|
225
|
+
var OPACITY_FADED = 0.3; //0.1;
|
226
|
+
var OPACITY_NORMAL = 0.75; //0.75;
|
227
|
+
var OPACITY_DARK = 1;
|
228
|
+
var RELATIONSHIP_STROKE_DARK = 1;
|
229
|
+
var RELATIONSHIP_STROKE_NORMAL = 0.75;
|
230
|
+
var RELATIONSHIP_STROKE_FADED = 0.35;
|
231
|
+
var TRANSITION_TIME = 400;
|
232
|
+
|
233
|
+
window.onload = function() {
|
234
|
+
var titleHeight = 250;
|
235
|
+
windowWidth = window.innerWidth - titleHeight;
|
236
|
+
windowHeight = window.innerHeight;
|
237
|
+
svg = d3.select("body").append("svg").attr("width", windowWidth).attr("height", windowHeight).attr("version", 1.1).attr("xmlns", "http://www.w3.org/2000/svg");
|
238
|
+
var pacticipants = [];
|
239
|
+
var maxrad = 0;
|
240
|
+
var pacticipantNameArray = [];
|
241
|
+
var circleMinRadius = 200;
|
242
|
+
|
243
|
+
|
244
|
+
var defs = svg.append('defs');
|
245
|
+
defs.append("marker")
|
246
|
+
.attr("id", "arrowGrayStart")
|
247
|
+
.attr("viewBox","0 0 10 10")
|
248
|
+
.attr("refX","10")
|
249
|
+
.attr("refY","5")
|
250
|
+
.attr("markerUnits","strokeWidth")
|
251
|
+
.attr("markerWidth","15")
|
252
|
+
.attr("markerHeight","15")
|
253
|
+
.attr("orient","auto")
|
254
|
+
.append("path")
|
255
|
+
.attr("d","M 0 0 L 10 5 L 0 10 z")
|
256
|
+
.attr("fill", "#A0A0A0");
|
257
|
+
|
258
|
+
defs.append("marker")
|
259
|
+
.attr("id", "arrowGrayEnd")
|
260
|
+
.attr("viewBox","0 0 10 10")
|
261
|
+
.attr("refX","0")
|
262
|
+
.attr("refY","5")
|
263
|
+
.attr("markerUnits","strokeWidth")
|
264
|
+
.attr("markerWidth","15")
|
265
|
+
.attr("markerHeight","15")
|
266
|
+
.attr("orient","auto")
|
267
|
+
.append("path")
|
268
|
+
.attr("d","M 10 0 L 10 10 L 0 5 z")
|
269
|
+
.attr("fill", "#A0A0A0");
|
270
|
+
|
271
|
+
|
272
|
+
d3.text("<%= csv_path %>", "text/csv", function(unparsedData) {
|
273
|
+
var data=d3.csv.parseRows(unparsedData);
|
274
|
+
pacticipants = parseCSV(data);
|
275
|
+
pacticipantNameArray = getPacticipantNames(pacticipants);
|
276
|
+
|
277
|
+
var nodeLocations = {};
|
278
|
+
var radius = Math.max(circleMinRadius, pacticipants.length * 2.5);
|
279
|
+
|
280
|
+
enlargeCanvasToFit(radius, windowWidth, windowHeight, svg);
|
281
|
+
|
282
|
+
maxrad = (radius * Math.PI / pacticipants.length) + 2;
|
283
|
+
var g = svg.selectAll("g").data(pacticipants).enter().append("g").attr("transform", function(d, i) {
|
284
|
+
return transformPacticipantNode(d, i, radius, pacticipants, nodeLocations);
|
285
|
+
}).attr("id", function(d, i) {
|
286
|
+
return i;
|
287
|
+
}).attr("class", function(pacticipant) {
|
288
|
+
return pacticipant.pacticipantName;
|
289
|
+
});
|
290
|
+
|
291
|
+
relationships = createRelationships(pacticipants);
|
292
|
+
|
293
|
+
g.selectAll("path")
|
294
|
+
.data(function(pacticipant){ return relationshipData(pacticipant, relationships); }).enter()
|
295
|
+
.append("path")
|
296
|
+
.attr("d", function(relationship){ return relationshipPath(relationship, nodeLocations, pacticipants); })
|
297
|
+
.attr("class", function(relationship) {
|
298
|
+
var clazz = relationship.id + " " + relationship.relationshipType + " relationship";
|
299
|
+
if(relationship.relationshipType !== 'link') {
|
300
|
+
clazz += ' visible';
|
301
|
+
}
|
302
|
+
return clazz;
|
303
|
+
})
|
304
|
+
.attr("fill", "none");
|
305
|
+
|
306
|
+
g.selectAll(".consumer, .provider")
|
307
|
+
.attr("stroke", relationshipColour)
|
308
|
+
.attr("stroke-width", RELATIONSHIP_STROKE_NORMAL)
|
309
|
+
.attr("opacity", OPACITY_NORMAL);
|
310
|
+
|
311
|
+
g.selectAll(".relationship.link")
|
312
|
+
.attr("stroke-width", 14)
|
313
|
+
.attr("opacity", 0)
|
314
|
+
.attr("stroke", 'white');
|
315
|
+
|
316
|
+
g.selectAll(".relationship")
|
317
|
+
.on("click", relationshipOnclick)
|
318
|
+
.on("mouseover", relationshipMouseover)
|
319
|
+
.on("mouseout", relationshipMouseout);
|
320
|
+
|
321
|
+
|
322
|
+
svg.selectAll(".consumer").attr("marker-end", "url(#arrowGrayStart)");
|
323
|
+
svg.selectAll(".provider").attr("marker-start", "url(#arrowGrayEnd)");
|
324
|
+
|
325
|
+
var pacticipantColour = d3.scale.category10().domain([0, pacticipants.length]);
|
326
|
+
|
327
|
+
var onRight = function (i) {
|
328
|
+
return i <= pacticipants.length / 4 || i >= pacticipants.length * 3 / 4;
|
329
|
+
};
|
330
|
+
|
331
|
+
var textFill = function(pacticipant) {
|
332
|
+
return pacticipantColour(pacticipant.order);
|
333
|
+
}
|
334
|
+
|
335
|
+
var circleXOffset = function(d, i) {
|
336
|
+
//controls the positioning in regards to the edge of the circle
|
337
|
+
return 6 * Math.cos(2 * Math.PI * i / pacticipants.length);
|
338
|
+
};
|
339
|
+
|
340
|
+
var circleYOffset = function(d, i) {
|
341
|
+
//controls the positioning in regards to the edge of the circle
|
342
|
+
return 6 * Math.sin(2 * Math.PI * i / pacticipants.length);
|
343
|
+
};
|
344
|
+
|
345
|
+
var circles = g.append("circle")
|
346
|
+
.attr("r", function(pacticipant) { return 6; })
|
347
|
+
.attr("fill", textFill)
|
348
|
+
.attr("stroke", textFill)
|
349
|
+
.attr("stroke-width", 2)
|
350
|
+
.attr("cx", circleXOffset)
|
351
|
+
.attr("cy", circleYOffset);
|
352
|
+
|
353
|
+
var textAnchor = function(d, i) {
|
354
|
+
if (onRight(i)) {
|
355
|
+
return "start";
|
356
|
+
} else {
|
357
|
+
return "end";
|
358
|
+
}
|
359
|
+
};
|
360
|
+
|
361
|
+
var textXOffset = function(d, i) {
|
362
|
+
//controls the positioning in regards to the edge of the circle
|
363
|
+
return 40 * Math.cos(2 * Math.PI * i / pacticipants.length);
|
364
|
+
};
|
365
|
+
|
366
|
+
var isFinite = function(num) {
|
367
|
+
return !(num == Number.POSITIVE_INFINITY || num == Number.NEGATIVE_INFINITY)
|
368
|
+
};
|
369
|
+
|
370
|
+
|
371
|
+
var textYOffset = function(d, i) {
|
372
|
+
var thing = 4 * Math.PI * i / pacticipants.length;
|
373
|
+
var counterOffset = 0;
|
374
|
+
|
375
|
+
counterOffset = (0.2 / (20 * Math.tan(thing/2))) * 1000;
|
376
|
+
|
377
|
+
if(!isFinite(counterOffset)) { //Right, middle node
|
378
|
+
counterOffset = 0;
|
379
|
+
} else {
|
380
|
+
//Near the asymptotes, it gets bigger really quickly, if it's a big number,
|
381
|
+
//it's likely it should actually be on the asymptote, and therefore, have no counterOffset
|
382
|
+
if(Math.abs(counterOffset) > 30) {
|
383
|
+
//Left, middle node
|
384
|
+
counterOffset = 0;
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
388
|
+
return (40 * Math.sin(2 * Math.PI * i / pacticipants.length)) - counterOffset;
|
389
|
+
};
|
390
|
+
|
391
|
+
var textYOffset2 = function(d, i) {
|
392
|
+
return (40 * Math.sin(2 * Math.PI * i / pacticipants.length));
|
393
|
+
};
|
394
|
+
|
395
|
+
var text = g.append("text").text(textContent)
|
396
|
+
.attr("x", function(d, i) { return textXOffset(d, i, maxrad); })
|
397
|
+
.attr("y", function(d, i) { return textYOffset(d, i, maxrad); })
|
398
|
+
.attr("text-anchor", textAnchor)
|
399
|
+
.attr("fill", textFill)
|
400
|
+
// .attr("font-size", function(){ return 15; });
|
401
|
+
.attr("class", function() { return "pacticpantLabel"; });
|
402
|
+
|
403
|
+
circles.on("mouseover", pacticipantMouseover).on("mouseout", pacticipantMouseout);
|
404
|
+
text.on("mouseover", pacticipantMouseover).on("mouseout", pacticipantMouseout);
|
405
|
+
|
406
|
+
});
|
407
|
+
}</script>
|
408
|
+
</body>
|
409
|
+
</html>
|
@@ -30,12 +30,14 @@
|
|
30
30
|
- relationships.each do | relationship |
|
31
31
|
%tr
|
32
32
|
%td.consumer
|
33
|
-
|
33
|
+
%a{:href => relationship.consumer_group_url}
|
34
|
+
= relationship.consumer_name
|
34
35
|
%td.pact
|
35
36
|
%a.btn.btn-primary{:href => relationship.latest_pact_url}
|
36
37
|
%span.glyphicon.glyphicon-arrow-right
|
37
38
|
%td.provider
|
38
|
-
|
39
|
+
%a{:href => relationship.provider_group_url}
|
40
|
+
= relationship.provider_name
|
39
41
|
|
40
42
|
:javascript
|
41
43
|
$(function(){
|
data/lib/pact_broker/version.rb
CHANGED
data/pact_broker.gemspec
CHANGED
@@ -23,21 +23,22 @@ Gem::Specification.new do |gem|
|
|
23
23
|
gem.add_runtime_dependency 'httparty'
|
24
24
|
gem.add_runtime_dependency 'json'
|
25
25
|
gem.add_runtime_dependency 'roar'
|
26
|
-
gem.add_runtime_dependency 'sequel'
|
27
|
-
gem.add_runtime_dependency 'sqlite3'
|
26
|
+
gem.add_runtime_dependency 'sequel', '~> 4.12'
|
28
27
|
gem.add_runtime_dependency 'webmachine'
|
29
28
|
gem.add_runtime_dependency 'versionomy'
|
30
29
|
gem.add_runtime_dependency 'rack'
|
31
|
-
gem.add_runtime_dependency 'redcarpet', '~>3.1
|
32
|
-
gem.add_runtime_dependency 'pact', '~>1.
|
30
|
+
gem.add_runtime_dependency 'redcarpet', '~>3.1'
|
31
|
+
gem.add_runtime_dependency 'pact', '~>1.3'
|
33
32
|
gem.add_runtime_dependency 'padrino', '~>0.12'
|
34
33
|
gem.add_runtime_dependency 'haml'
|
35
34
|
|
35
|
+
gem.add_development_dependency 'sqlite3'
|
36
36
|
gem.add_development_dependency 'pry'
|
37
37
|
gem.add_development_dependency 'rake', '~>10.0'
|
38
38
|
gem.add_development_dependency 'fakefs', '~>0.4'
|
39
|
-
gem.add_development_dependency 'rspec-fire', '~>1.2.0'
|
40
39
|
gem.add_development_dependency 'mysql2', '~>0.3.15'
|
41
|
-
gem.add_development_dependency '
|
40
|
+
gem.add_development_dependency 'webmock'
|
41
|
+
gem.add_development_dependency 'rspec', '~>3.0'
|
42
|
+
gem.add_development_dependency 'rspec-its'
|
42
43
|
|
43
44
|
end
|