@@ -14,13 +14,14 @@ class NotAPactError < StandardError; end
14
14
15
15
include PactBroker ::Logging
16
16
17
- def self . call pact
18
- new ( pact ) . call
17
+ def self . call pact , options = { }
18
+ new ( pact , options ) . call
19
19
end
20
20
21
- def initialize pact
21
+ def initialize pact , options = { }
22
22
@json_content = pact . json_content
23
23
@pact = pact
24
+ @options = options
24
25
end
25
26
26
27
def call
@@ -40,12 +41,16 @@ def head
40
41
<link rel='stylesheet' type='text/css' href='/stylesheets/pact.css'>
41
42
<link rel='stylesheet' type='text/css' href='/stylesheets/github-json.css'>
42
43
<script src='/javascripts/highlight.pack.js'></script>
44
+ <script src='/javascripts/jquery-2.1.1.min.js'></script>
45
+ <script src='/js/bootstrap.min.js'></script>
46
+ <script src='/javascripts/pact.js'></script>
43
47
<script>hljs.initHighlightingOnLoad();</script>"
44
48
end
45
49
46
50
def pact_metadata
47
51
"<div class='pact-metadata'>
48
52
<ul>
53
+ #{ badge_li }
49
54
<li>
50
55
<span class='name'>#{ @pact . consumer . name } version:</span>
51
56
<span class='value'>#{ @pact . consumer_version_number } #{ tags } </span>
@@ -64,6 +69,26 @@ def pact_metadata
64
69
</div>"
65
70
end
66
71
72
+ def badge_li
73
+ if PactBroker . configuration . enable_badge_resources
74
+ "<li>
75
+ <img src='#{ badge_url } ' class='badge'/>
76
+ </li>
77
+ <li class='badge-markdown' style='display:none'>
78
+ <textarea rows='3' cols='100' >#{ badge_markdown } </textarea>
79
+ </li>
80
+ "
81
+ end
82
+ end
83
+
84
+ def badge_markdown
85
+ "[](#{ latest_pact_url } )"
86
+ end
87
+
88
+ def base_url
89
+ @options [ :base_url ] || ''
90
+ end
91
+
67
92
def title
68
93
"Pact between #{ @pact . consumer . name } and #{ @pact . provider . name } "
69
94
end
@@ -80,6 +105,14 @@ def pact_url
80
105
PactBroker ::Api ::PactBrokerUrls . pact_url '' , @pact
81
106
end
82
107
108
+ def latest_pact_url
109
+ PactBroker ::Api ::PactBrokerUrls . latest_pact_url base_url , @pact
110
+ end
111
+
112
+ def badge_url
113
+ PactBroker ::Api ::PactBrokerUrls . badge_url_for_latest_pact @pact , base_url
114
+ end
115
+
83
116
def tags
84
117
if @pact . consumer_version_tag_names . any?
85
118
" (#{ @pact . consumer_version_tag_names . join ( ", " ) } )"
0 commit comments