Class: Spoom::Coverage::D3::Timeline::Versions
- Inherits:
-
Spoom::Coverage::D3::Timeline
- Object
- Base
- Spoom::Coverage::D3::Timeline
- Spoom::Coverage::D3::Timeline::Versions
- Defined in:
- lib/spoom/coverage/d3/timeline.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(id, snapshots) ⇒ Versions
constructor
: (String id, Array snapshots) -> void.
-
#plot ⇒ Object
: -> String.
-
#tooltip ⇒ Object
: -> String.
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
: (String id, Array snapshots) -> void
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: snapshot.commit_sha, static: snapshot.version_static, runtime: snapshot.version_runtime, } end super(id, data, []) end |
Instance Method Details
#plot ⇒ Object
: -> String
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 261 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" |
#tooltip ⇒ Object
: -> String
246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/spoom/coverage/d3/timeline.rb', line 246 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" |