Class: Spoom::Coverage::D3::Timeline::Versions

Inherits:
Spoom::Coverage::D3::Timeline show all
Extended by:
T::Sig
Defined in:
lib/spoom/coverage/d3/timeline.rb

Instance Attribute Summary

Attributes inherited from Base

#id

Instance Method Summary collapse

Methods inherited from Spoom::Coverage::D3::Timeline

#area, header_script, header_style, #line, #points, #script, #x_scale, #x_ticks, #y_scale, #y_ticks

Methods inherited from Base

header_script, header_style, #html, #script

Constructor Details

#initialize(id, snapshots) ⇒ Versions



232
233
234
235
236
237
238
239
240
241
242
# File 'lib/spoom/coverage/d3/timeline.rb', line 232

def initialize(id, snapshots)
  data = snapshots.map do |snapshot|
    {
      timestamp: snapshot.commit_timestamp,
      commit: snapshot.commit_sha,
      static: snapshot.version_static,
      runtime: snapshot.version_runtime,
    }
  end
  super(id, data, [])
end

Instance Method Details

#plotObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/spoom/coverage/d3/timeline.rb', line 259

def plot
  "    \#{x_scale}\n    \#{y_scale(\n      min: \"d3.min([d3.min(data_\#{id}, (d) => parseVersion(d.static)),\n                    d3.min(data_\#{id}, (d) => parseVersion(d.runtime))]) - 0.01\",\n      max: \"d3.max([d3.max(data_\#{id}, (d) => parseVersion(d.static)),\n                    d3.max(data_\#{id}, (d) => parseVersion(d.runtime))]) + 0.01\",\n      ticks: 'ticks(8)'\n    )}\n    \#{line(y: 'parseVersion(d.runtime)', color: '#e83e8c', curve: 'curveStepAfter')}\n    \#{line(y: 'parseVersion(d.static)', color: '#007bff', curve: 'curveStepAfter')}\n    \#{points(y: 'parseVersion(d.static)')}\n    \#{x_ticks}\n    \#{y_ticks(ticks: 'ticks(4)', format: \"'v0.' + d.toFixed(2)\", padding: 50)}\n  JS\nend\n"

#tooltipObject



245
246
247
248
249
250
251
252
253
254
255
256
# File 'lib/spoom/coverage/d3/timeline.rb', line 245

def tooltip
  "    function tooltip_\#{id}(d) {\n      moveTooltip(d)\n        .html(\"commit <b>\" + d.commit + \"</b><br>\"\n          + d3.timeFormat(\"%y/%m/%d\")(parseDate(d.timestamp)) + \"<br><br>\"\n          + \"static: v<b>\" + d.static + \"</b><br>\"\n          + \"runtime: v<b>\" + d.runtime + \"</b><br><br>\"\n          + \"versions from<br>Gemfile.lock\")\n    }\n  JS\nend\n"