rorvswild 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,125 +1,331 @@
1
- <div id="RorVsWild.Local" class="<%= widget_css %>">
2
- <div data-barber="RorVsWild.Local" data-editor-url="<%= editor_url %>">
3
- </div>
1
+ <div id="RorVsWild.Local" class="<%= widget_css %>" >
2
+ <% if @current_request %>
3
+ <div data-barber="RorVsWild.Local" data-editor-url="<%= editor_url %>" data-request-uuid="<%= @current_request["uuid"] %>"></div>
4
+ <% else %>
5
+ <div data-barber="RorVsWild.Local" data-editor-url="<%= editor_url %>"></div>
6
+ <% end %>
4
7
  </div>
5
8
 
6
9
  <script type="x-tmpl-mustache" data-partial="RorVsWild.Local">
7
10
  <div id="rorvswild-local-requests" class="rorvswild-local-panel {{containerClass}}">
8
-
9
11
  <div class="rorvswild-local-panel__header">
10
- <a href="https://www.rorvswild.com" class="rorvswild-local-panel__logo">
11
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34.83 30.83">
12
- <polygon points="17.41 9.41 13.41 9.41 9.41 13.41 17.41 21.41 25.41 13.41 21.41 9.41 17.41 9.41"/>
13
- <polyline points="1.41 21.41 9.41 29.41 17.41 21.41 25.41 29.41 33.41 21.41"/>
14
- <polyline points="9.41 5.41 5.41 1.41 1.41 5.41"/>
15
- <polyline points="33.41 5.41 29.41 1.41 25.41 5.41"/>
16
- </svg>
17
- </a>
18
-
19
- {{#currentRequest}}
20
- <span class="rorvswild-local-panel__header__title">breakdown</span>
21
- {{/currentRequest}}
22
- {{^currentRequest}}
23
- <span class="rorvswild-local-panel__header__title">history</span>
24
- {{/currentRequest}}
25
- <span class="rorvswild-local-panel__header__icons">
26
- <a href="https://github.com/BaseSecrete/rorvswild" class="rorvswild-local-panel__github" title="Source code">
27
- <svg width="16px" height="16px" viewBox="0 0 16 16">
28
- <path d="M8,0 C3.58,0 0,3.58 0,8 C0,11.54 2.29,14.53 5.47,15.59 C5.87,15.66 6.02,15.42 6.02,15.21 C6.02,15.02 6.01,14.39 6.01,13.72 C4,14.09 3.48,13.23 3.32,12.78 C3.23,12.55 2.84,11.84 2.5,11.65 C2.22,11.5 1.82,11.13 2.49,11.12 C3.12,11.11 3.57,11.7 3.72,11.94 C4.44,13.15 5.59,12.81 6.05,12.6 C6.12,12.08 6.33,11.73 6.56,11.53 C4.78,11.33 2.92,10.64 2.92,7.58 C2.92,6.71 3.23,5.99 3.74,5.43 C3.66,5.23 3.38,4.41 3.82,3.31 C3.82,3.31 4.49,3.1 6.02,4.13 C6.66,3.95 7.34,3.86 8.02,3.86 C8.7,3.86 9.38,3.95 10.02,4.13 C11.55,3.09 12.22,3.31 12.22,3.31 C12.66,4.41 12.38,5.23 12.3,5.43 C12.81,5.99 13.12,6.7 13.12,7.58 C13.12,10.65 11.25,11.33 9.47,11.53 C9.76,11.78 10.01,12.26 10.01,13.01 C10.01,14.08 10,14.94 10,15.21 C10,15.42 10.15,15.67 10.55,15.59 C13.71,14.53 16,11.53 16,8 C16,3.58 12.42,0 8,0 L8,0 Z"></path>
12
+ <div class="rorvswild-local-panel__width-limiter">
13
+ <a href="https://www.rorvswild.com" class="rorvswild-local-panel__logo">
14
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 34.83 30.83">
15
+ <polygon points="17.41 9.41 13.41 9.41 9.41 13.41 17.41 21.41 25.41 13.41 21.41 9.41 17.41 9.41"/>
16
+ <polyline points="1.41 21.41 9.41 29.41 17.41 21.41 25.41 29.41 33.41 21.41"/>
17
+ <polyline points="9.41 5.41 5.41 1.41 1.41 5.41"/>
18
+ <polyline points="33.41 5.41 29.41 1.41 25.41 5.41"/>
29
19
  </svg>
30
20
  </a>
31
- {{#embedded}}
32
- <div data-events="click->collapse" class="rorvswild-local-panel__close" title="Close">
33
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
34
- <line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>
21
+
22
+ <nav id="rorvswild-local-nav">
23
+ <ul>
24
+ <li data-events="click->goToRequestIndex" class="tab--requests">Requests</li>
25
+ <li data-events="click->goToJobIndex" class="tab--jobs">Jobs</li>
26
+ <li data-events="click->goToErrors" class="tab--errors">Errors</li>
27
+ </ul>
28
+ </nav>
29
+
30
+ <span class="rorvswild-local-panel__header__icons">
31
+ <a href="https://github.com/BaseSecrete/rorvswild" class="rorvswild-local-panel__github" title="Source code">
32
+ <svg width="16px" height="16px" viewBox="0 0 16 16">
33
+ <path d="M8,0 C3.58,0 0,3.58 0,8 C0,11.54 2.29,14.53 5.47,15.59 C5.87,15.66 6.02,15.42 6.02,15.21 C6.02,15.02 6.01,14.39 6.01,13.72 C4,14.09 3.48,13.23 3.32,12.78 C3.23,12.55 2.84,11.84 2.5,11.65 C2.22,11.5 1.82,11.13 2.49,11.12 C3.12,11.11 3.57,11.7 3.72,11.94 C4.44,13.15 5.59,12.81 6.05,12.6 C6.12,12.08 6.33,11.73 6.56,11.53 C4.78,11.33 2.92,10.64 2.92,7.58 C2.92,6.71 3.23,5.99 3.74,5.43 C3.66,5.23 3.38,4.41 3.82,3.31 C3.82,3.31 4.49,3.1 6.02,4.13 C6.66,3.95 7.34,3.86 8.02,3.86 C8.7,3.86 9.38,3.95 10.02,4.13 C11.55,3.09 12.22,3.31 12.22,3.31 C12.66,4.41 12.38,5.23 12.3,5.43 C12.81,5.99 13.12,6.7 13.12,7.58 C13.12,10.65 11.25,11.33 9.47,11.53 C9.76,11.78 10.01,12.26 10.01,13.01 C10.01,14.08 10,14.94 10,15.21 C10,15.42 10.15,15.67 10.55,15.59 C13.71,14.53 16,11.53 16,8 C16,3.58 12.42,0 8,0 L8,0 Z"></path>
35
34
  </svg>
36
- </div>
37
- {{/embedded}}
38
- </span>
35
+ </a>
36
+ {{#embedded}}
37
+ <div data-events="click->collapse" class="rorvswild-local-panel__close" title="Close">
38
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
39
+ <line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>
40
+ </svg>
41
+ </div>
42
+ {{/embedded}}
43
+ </span>
44
+ </div>
39
45
  </div>
46
+
40
47
  <div class="rorvswild-local-panel__content">
41
- {{#currentRequest}}
42
- <div data-events="click->goToHistory" class="rorvswild-local-panel__back-button" title="Go to history">
43
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
44
- <line x1="20" y1="12" x2="4" y2="12"></line>
45
- <polyline points="10 18 4 12 10 6"></polyline>
46
- </svg>
47
- </div>
48
- {{> RorVsWild.Local.RequestDetails}}
49
- {{/currentRequest}}
50
-
51
- {{^currentRequest}}
52
- {{#requests}}
53
- {{> RorVsWild.Local.RequestSummary}}
54
- {{/requests}}
55
- {{/currentRequest}}
48
+ <div class="rorvswild-local-panel__width-limiter">
49
+ {{{renderBody}}}
50
+ </div>
56
51
  </div>
57
52
  <div class="rorvswild-local-panel__footer">
58
53
  This data is not sent to rorvswild.com. <a href="https://www.rorvswild.com" class="rorvswild-local-panel__footer__link">Create an account</a> to monitor your production environment.
59
54
  </div>
60
55
  </div>
61
56
 
62
- {{#embedded}}
63
- <div class="rorvswild-local-toggler" data-events="click->toggle">{{lastRuntime}}<small>ms</small></div>
64
- {{/embedded}}
57
+ <% if @current_request %>
58
+ {{#embedded}}
59
+ <div class="rorvswild-local-toggler" data-events="click->toggle" data-uuid="<%= @current_request["uuid"] %>"><%= @current_request["runtime"].round %><small>ms</small></div>
60
+ {{/embedded}}
61
+ <% end %>
62
+ </script>
63
+
64
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.RequestIndex">
65
+ {{^requests}}
66
+ <h2 class="rorvswild-local-panel--blank">No requests</h2>
67
+ {{/requests}}
68
+ {{#requests}}
69
+ <div data-events="click->goToRequestDetail" data-uuid="{{uuid}}" class="rorvswild-local-panel__row">
70
+ <div class="rorvswild-local-panel__name">
71
+ <span>{{name}}</span>
72
+ <div class="rorvswild-local-panel__path">{{path}}</div>
73
+ </div>
74
+ <span class="rorvswild-local-panel__runtime">{{runtime}}<small>ms</small></span>
75
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
76
+ </div>
77
+ {{/requests}}
78
+ </script>
79
+
80
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.JobIndex">
81
+ {{^jobs}}
82
+ <h2 class="rorvswild-local-panel--blank">No jobs</h2>
83
+ {{/jobs}}
84
+ {{#jobs}}
85
+ <div data-events="click->goToJobDetail" data-uuid="{{uuid}}"" class="rorvswild-local-panel__row">
86
+ <div class="rorvswild-local-panel__name">
87
+ <span>{{name}}</span>
88
+ <div class="rorvswild-local-panel__path">{{path}}</div>
89
+ </div>
90
+ <span class="rorvswild-local-panel__runtime">{{runtime}}<small>ms</small></span>
91
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
92
+ </div>
93
+ {{/jobs}}
65
94
  </script>
66
95
 
67
96
  <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.RequestSummary">
68
- <div data-events="click->goToRequestDetails" data-request-id="{{id}}" class="rorvswild-local-panel__request">
69
- <span class="rorvswild-local-panel__request__name">
70
- {{name}}
71
- <span class="rorvswild-local-panel__request__path">
97
+ <div data-events="click->goToRequestDetail" data-uuid="{{uuid}}" class="rorvswild-local-panel__row">
98
+ <div class="rorvswild-local-panel__name">
99
+ <span>{{name}}</span>
100
+ <div class="rorvswild-local-panel__path">
72
101
  {{path}}
73
- </span>
74
- </span>
75
- <span class="rorvswild-local-panel__request__runtime">{{runtime}}<small>ms</small></span>
76
- <span class="rorvswild-local-panel__request__started-at">{{queuedAt}}</span>
102
+ </div>
103
+ </div>
104
+ <span class="rorvswild-local-panel__runtime">{{runtime}}<small>ms</small></span>
105
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
77
106
  </div>
78
107
  </script>
79
108
 
80
- <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.RequestDetails">
81
- <div class="rorvswild-local-panel__request-details">
82
- <div class="rorvswild-local-panel__request-details__request">
83
- <span class="rorvswild-local-panel__request__name">
84
- <h2 class="rorvswild-local-panel__request__name__title">{{name}}</h2>
85
- <span class="rorvswild-local-panel__request__path">
86
- {{path}}
109
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.RequestDetail">
110
+ {{#currentRequest}}
111
+ <div class="rorvswild-local-panel__details">
112
+ <div class="rorvswild-local-panel__details__header">
113
+ <span class="rorvswild-local-panel__name">
114
+ <h2 class="rorvswild-local-panel__title">{{name}}</h2>
115
+ <span class="rorvswild-local-panel__path">
116
+ {{path}}
117
+ </span>
87
118
  </span>
88
- </span>
89
- <span class="rorvswild-local-panel__request__runtime">{{runtime}}<small>ms</small></span>
90
- <span class="rorvswild-local-panel__request__started-at">{{queuedAt}}</span>
119
+ <span class="rorvswild-local-panel__runtime">{{runtime}}<small>ms</small></span>
120
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
121
+ </div>
122
+ {{> RorVsWild.Local.Sections}}
91
123
  </div>
92
- <div class="rorvswild-local-panel__request-details__sections">
93
- {{#sections}}
94
- {{> RorVsWild.Local.Section}}
95
- {{/sections}}
124
+ {{/currentRequest}}
125
+ </script>
126
+
127
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.JobDetail">
128
+ {{#currentJob}}
129
+ <div class="rorvswild-local-panel__details">
130
+ <div class="rorvswild-local-panel__details__header">
131
+ <span class="rorvswild-local-panel__name">
132
+ <h2 class="rorvswild-local-panel__title">{{name}}</h2>
133
+ <span class="rorvswild-local-panel__path">
134
+ {{path}}
135
+ </span>
136
+ </span>
137
+ <span class="rorvswild-local-panel__runtime">{{runtime}}<small>ms</small></span>
138
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
139
+ </div>
140
+ {{> RorVsWild.Local.Sections}}
96
141
  </div>
142
+ {{/currentJob}}
143
+ </script>
144
+
145
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.Sections">
146
+ <div class="rorvswild-local-panel__details__sections">
147
+ {{> RorVsWild.Local.SectionImpactPerKind}}
148
+ {{#sections}}
149
+ {{> RorVsWild.Local.Section}}
150
+ {{/sections}}
97
151
  </div>
98
152
  </script>
99
153
 
154
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.SectionImpactPerKind">
155
+ <ul class="rorvswild-local-panel__breakdown">
156
+ {{#sectionsImpactPerKind}}
157
+ <li style="width: {{impact}}%" title="{{kind}} {{impact}}%">
158
+ <span class="rorvswild-local-panel__breakdown__label">{{kind}}</span> <span class="rorvswild-local-panel__breakdown__value">{{impact}}%</span>
159
+ </li>
160
+ {{/sectionsImpactPerKind}}
161
+ </ul>
162
+ </script>
163
+
100
164
  <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.Section">
101
- <div class="rorvswild-local-panel__request-details__section">
102
- <div class="rorvswild-local-panel__request-details__section__main">
103
- <span class="rorvswild-local-panel__request-details__section__file">
104
- {{#url}}
105
- <a href="{{url}}" class="rorvswild-local-panel__request-details__section__file__name" title="Open in your editor">{{file}}<span>:{{line}}</span></a>
106
- {{/url}}
107
- {{^url}}
108
- <span class="rorvswild-local-panel__request-details__section__file__name">{{file}}<span>:{{line}}</span></span>
109
- {{/url}}
110
- <div class="rorvswild-local-panel__request-details__section__code">
111
- <span class="rorvswild-local-panel__request-details__section__kind">{{kind}}</span>
112
- <span class="rorvswild-local-panel__request-details__section__command">
113
- <pre><code class="{{language}}">{{command}}</code></pre>
114
- </span>
115
- </div>
165
+ <div class="rorvswild-local-panel__details__section" id="section-{{id}}">
166
+ <div class="rorvswild-local-panel__details__section__main">
167
+ <span class="rorvswild-local-panel__details__section__file">
168
+ <button data-events="click->toggleCommand" data-target="#section-{{id}}" class="rorvswild-local-panel__details__section__kind"><span>{{kind}}</button>
169
+ {{#locationUrl}}
170
+ <a href="{{locationUrl}}" class="rorvswild-local-panel__file__name" title="Open in your editor">{{location}}</a>
171
+ {{/locationUrl}}
172
+ {{^locationUrl}}
173
+ <span class="rorvswild-local-panel__file__name">{{file}}<span>:{{line}}</span></span>
174
+ {{/locationUrl}}
116
175
  </span>
117
- <span class="rorvswild-local-panel__request-details__section__average" title="average runtime">{{averageRuntime}}<small>ms</small></span>
118
- <span class="rorvswild-local-panel__request-details__section__calls" title="calls">x{{calls}}</span>
119
- <span class="rorvswild-local-panel__request-details__section__impact" title="impact">{{impact}}<small>&#37;</small></span>
176
+ <span class="rorvswild-local-panel__details__section__average" title="Self runtime">{{selfRuntime}}<small>ms</small></span>
177
+ <span class="rorvswild-local-panel__details__section__impact" title="Impact">{{impact}}<small>&#37;</small></span>
178
+ </div>
179
+
180
+ <div class="rorvswild-local-panel__details__section__code">
181
+ <dl>
182
+ <div>
183
+ <dt title="self + children">Total runtime</dt>
184
+ <dd title="{{selfRuntime}} + {{childrenRuntime}}">{{totalRuntime}}<small>ms</small></dd>
185
+ </div>
186
+ <div>
187
+ <dt title="total - self">Children runtime</dt>
188
+ <dd title="{{totalRuntime}} - {{selfRuntime}}">{{childrenRuntime}}<small>ms</small></dd>
189
+ </div>
190
+ <div>
191
+ <dt title="total - children">Self runtime</dt>
192
+ <dd title="{{totalRuntime}} - {{childrenRuntime}}">{{selfRuntime}}<small>ms</small></dd>
193
+ </div>
194
+ <div>
195
+ <dt>Calls</dt>
196
+ <dd class="dd--calls">{{calls}}<small>x</small></dd>
197
+ </div>
198
+ <div>
199
+ <dt title="self runtime / calls">Average runtime</dt>
200
+ <dd title="{{selfRuntime}} / {{calls}}">{{averageRuntime}}<small>ms</small></dd>
201
+ </div>
202
+ </dl>
203
+ {{#command}}
204
+ <pre><code class="{{language}}">{{command}}</code></pre>
205
+ {{/command}}
120
206
  </div>
121
207
  </div>
122
208
  </script>
123
209
 
210
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.ErrorIndex">
211
+ {{^errors}}
212
+ <h2 class="rorvswild-local-panel--blank">No errors</h2>
213
+ {{/errors}}
214
+ {{#errors}}
215
+ <div data-events="click->goToErrorDetail" data-uuid="{{uuid}}" class="rorvswild-local-panel__row rorvswild-local-panel__error">
216
+ <div class="rorvswild-local-panel__name">
217
+ <span>{{exception}}</span> {{shortMessage}}
218
+ <div class="rorvswild-local-panel__path">{{file}}:{{line}}</div>
219
+ </div>
220
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
221
+ </div>
222
+ {{/errors}}
223
+ </script>
224
+
225
+ <script type="x-tmpl-mustache" data-partial="RorVsWild.Local.ErrorDetail">
226
+ {{#currentError}}
227
+ <div class="rorvswild-local-panel__details rorvswild-local-panel__error">
228
+ <div class="rorvswild-local-panel__details__header">
229
+ <span class="rorvswild-local-panel__name">
230
+ <h2 class="rorvswild-local-panel__title">{{exception}}</h2>
231
+ <span class="rorvswild-local-panel__path">
232
+ {{#locationUrl}}
233
+ <a href="{{locationUrl}}" class="rorvswild-local-panel__file__name" title="Open in your editor">{{file}}:{{line}}</a>
234
+ {{/locationUrl}}
235
+ {{^locationUrl}}
236
+ {{file}}:{{line}}
237
+ {{/locationUrl}}
238
+ </span>
239
+ </span>
240
+ <span class="rorvswild-local-panel__started-at">{{queuedAt}}</span>
241
+ </div>
242
+
243
+ {{#message}}
244
+ <div class="rorvswild-local-panel__card">
245
+ <h3 class="rorvswild-local-panel__card__title">Message</h3>
246
+ <code><pre class="language-none">{{message}}</pre></code>
247
+ </div>
248
+ {{/message}}
249
+
250
+ <div class="rorvswild-local-panel__card">
251
+ <h3 class="rorvswild-local-panel__card__title">Backtrace</h3>
252
+ {{#compactBacktraceLocations}}
253
+ <pre class="language-markup"><a href="{{url}}" class="rorvswild-local-panel__file__name" title="Open in your editor">{{path}}</a></pre>
254
+ {{/compactBacktraceLocations}}
255
+ <details>
256
+ <summary>
257
+ view full trace
258
+ </summary>
259
+ <code><pre class="language-none">{{formattedBacktrace}}</pre></code>
260
+ </details>
261
+ </div>
262
+
263
+ {{#request}}
264
+ <div class="rorvswild-local-panel__card">
265
+ <h3 class="rorvswild-local-panel__card__title">Request</h3>
266
+ <dl>
267
+ <div><dt>name</dt><dd>{{name}}</dd></div>
268
+ <div><dt>method</dt><dd>{{method}}</dd></div>
269
+ <div><dt>URL</dt><dd>{{url}}</dd></div>
270
+ </dl>
271
+ </div>
272
+ {{/request}}
273
+
274
+ {{#job}}
275
+ <div class="rorvswild-local-panel__card">
276
+ <h3 class="rorvswild-local-panel__card__title">Job</h3>
277
+ <dl>
278
+ <div><dt>name</dt><dd>{{name}}</dd></div>
279
+ </dl>
280
+ </div>
281
+ {{/job}}
282
+
283
+ {{#hasParameters}}
284
+ <div class="rorvswild-local-panel__card">
285
+ <h3 class="rorvswild-local-panel__card__title">Parameters</h3>
286
+ <pre class="language-json"><code>{{parametersInJson}}</code></pre>
287
+ </div>
288
+ {{/hasParameters}}
289
+
290
+ {{#hasRequestHeaders}}
291
+ <div class="rorvswild-local-panel__card">
292
+ <h3 class="rorvswild-local-panel__card__title">Headers</h3>
293
+ <dl>
294
+ {{#eachRequestHeader}}
295
+ <div>
296
+ <dt>{{name}}</dt><dd>{{value}}</dd>
297
+ </div>
298
+ {{/eachRequestHeader}}
299
+ </dl>
300
+ </div>
301
+ {{/hasRequestHeaders}}
302
+
303
+ {{#hasContext}}
304
+ <div class="rorvswild-local-panel__card">
305
+ <h3 class="rorvswild-local-panel__card__title">Context</h3>
306
+ <dl>
307
+ {{#eachContext}}
308
+ <div>
309
+ <dt>{{name}}</dt><dd>{{value}}</dd>
310
+ </div>
311
+ {{/eachContext}}
312
+ </dl>
313
+ </div>
314
+ {{/hasContext}}
315
+
316
+ <div class="rorvswild-local-panel__card">
317
+ <h3 class="rorvswild-local-panel__card__title">Environment</h3>
318
+ <dl>
319
+ {{#eachEnvironment}}
320
+ <div>
321
+ <dt>{{name}}</dt><dd>{{value}}</dd>
322
+ </div>
323
+ {{/eachEnvironment}}
324
+ </dl>
325
+ </div>
326
+ </div>
327
+ {{/currentError}}
328
+ </script>
329
+
124
330
  <link rel="stylesheet" media="all" href="/rorvswild.css"/>
125
331
  <script src="/rorvswild.js"></script>
@@ -17,6 +17,9 @@ module RorVsWild
17
17
  when "/rorvswild.css" then serve_stylesheet
18
18
  when "/rorvswild.js" then serve_javascript
19
19
  when "/rorvswild.json" then serve_json
20
+ when "/rorvswild/requests.json" then serve_requests
21
+ when "/rorvswild/jobs.json" then serve_jobs
22
+ when "/rorvswild/errors.json" then serve_errors
20
23
  else serve_embed_profiler(env)
21
24
  end
22
25
  end
@@ -34,6 +37,7 @@ module RorVsWild
34
37
  log_incompatible_middleware_warning
35
38
  elsif body.respond_to?(:each)
36
39
  content_length = 0
40
+ @current_request = RorVsWild.agent.queue.requests.first
37
41
  body.each do |string|
38
42
  inject_into(string)
39
43
  content_length += string.size
@@ -56,6 +60,18 @@ module RorVsWild
56
60
  [200, {"Content-Type" => "application/json"}, StringIO.new(RorVsWild.agent.queue.requests.to_json)]
57
61
  end
58
62
 
63
+ def serve_requests
64
+ [200, {"Content-Type" => "application/json"}, StringIO.new(RorVsWild.agent.queue.requests.to_json)]
65
+ end
66
+
67
+ def serve_jobs
68
+ [200, {"Content-Type" => "application/json"}, StringIO.new(RorVsWild.agent.queue.jobs.to_json)]
69
+ end
70
+
71
+ def serve_errors
72
+ [200, {"Content-Type" => "application/json"}, StringIO.new(RorVsWild.agent.queue.errors.to_json)]
73
+ end
74
+
59
75
  private
60
76
 
61
77
  def widget_css
@@ -1,18 +1,56 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RorVsWild
2
4
  module Local
3
5
  class Queue
4
- attr_reader :requests
5
- def initialize
6
- @requests = []
7
- end
8
-
9
6
  def push_job(data)
7
+ push_to(data, "jobs")
8
+ push_error(data[:error]) if data[:error]
10
9
  end
11
10
 
12
11
  def push_request(data)
13
- requests.unshift(data)
12
+ push_to(data, "requests")
13
+ push_error(data[:error]) if data[:error]
14
+ end
15
+
16
+ def push_error(data)
17
+ push_to(data, "errors")
18
+ end
19
+
20
+ def requests
21
+ load_data("requests")
22
+ end
23
+
24
+ def jobs
25
+ load_data("jobs")
26
+ end
27
+
28
+ def errors
29
+ load_data("errors")
30
+ end
31
+
32
+ private
33
+
34
+ def push_to(data, name)
14
35
  data[:queued_at] = Time.now
15
- requests.pop if requests.size > 100
36
+ data[:uuid] = SecureRandom.uuid
37
+ array = load_data(name)
38
+ array.unshift(data)
39
+ array.pop if array.size > 100
40
+ save_data(array, name)
41
+ end
42
+
43
+ def save_data(data, name)
44
+ File.open(File.join(directoy, "#{name}.json"), "w") { |file| JSON.dump(data, file) }
45
+ end
46
+
47
+ def load_data(name)
48
+ JSON.load_file(File.join(directoy, "#{name}.json")) rescue []
49
+ end
50
+
51
+ def directoy
52
+ dir = File.directory?("tmp") ? "tmp" : Dir.tmpdir
53
+ FileUtils.mkpath(File.join(dir, "rorvswild"))[0]
16
54
  end
17
55
  end
18
56
  end