Module: Kitchen::Directions::BakeCheckpoint

Defined in:
lib/kitchen/directions/bake_checkpoint.rb

Class Method Summary collapse

Class Method Details

.v1(checkpoint:, number:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/kitchen/directions/bake_checkpoint.rb', line 6

def self.v1(checkpoint:, number:)
  checkpoint.wrap_children(class: 'os-note-body')

  checkpoint.prepend(child:
    "      <div class=\"os-title\">\n        <span class=\"os-title-label\">\#{I18n.t(:checkpoint)} </span>\n        <span class=\"os-number\">\#{number}</span>\n        <span class=\"os-divider\"> </span>\n      </div>\n    HTML\n  )\n\n  exercise = checkpoint.exercises.first!\n  exercise.search(\"[data-type='commentary']\").trash\n\n  problem = exercise.problem\n  problem.wrap_children(class: 'os-problem-container')\n\n  solution = exercise.solution\n  exercise.add_class('unnumbered') unless solution.present?\n  return unless solution.present?\n\n  solution.id = \"\#{exercise.id}-solution\"\n  exercise.add_class('os-hasSolution')\n\n  solution.replace_children(with:\n    <<~HTML\n      <span class=\"os-divider\"> </span>\n      <a class=\"os-number\" href=\"#\#{exercise.id}\">\#{number}</a>\n      <div class=\"os-solution-container\">\#{solution.children}</div>\n    HTML\n  )\n\n  exercise.add_class('unnumbered')\nend\n"