openstax_kitchen 3.2.0 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/changelog.yml +27 -0
  3. data/.github/workflows/rubocop.yml +28 -0
  4. data/.gitignore +1 -1
  5. data/CHANGELOG.md +94 -1
  6. data/Gemfile.lock +26 -18
  7. data/README.md +16 -0
  8. data/codecov.yaml +1 -0
  9. data/docker/ci +0 -1
  10. data/docker/rubocop +22 -0
  11. data/lib/kitchen/book_document.rb +1 -1
  12. data/lib/kitchen/book_element.rb +16 -2
  13. data/lib/kitchen/chapter_element.rb +10 -13
  14. data/lib/kitchen/chapter_element_enumerator.rb +1 -1
  15. data/lib/kitchen/composite_chapter_element.rb +7 -11
  16. data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
  17. data/lib/kitchen/composite_page_element.rb +15 -10
  18. data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
  19. data/lib/kitchen/config.rb +14 -0
  20. data/lib/kitchen/directions/bake_appendix.rb +3 -1
  21. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  22. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  23. data/lib/kitchen/directions/bake_chapter_introductions.rb +23 -16
  24. data/lib/kitchen/directions/bake_chapter_introductions/chapter_introduction.xhtml.erb +0 -0
  25. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +7 -2
  26. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +12 -7
  27. data/lib/kitchen/directions/bake_chapter_key_equations.rb +26 -21
  28. data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
  29. data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
  30. data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +2 -2
  31. data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +2 -1
  32. data/lib/kitchen/directions/bake_chapter_solutions/main.rb +11 -0
  33. data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +37 -0
  34. data/lib/kitchen/directions/bake_chapter_summary.rb +56 -43
  35. data/lib/kitchen/directions/bake_composite_chapters.rb +1 -1
  36. data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
  37. data/lib/kitchen/directions/bake_equations.rb +2 -2
  38. data/lib/kitchen/directions/bake_example.rb +8 -1
  39. data/lib/kitchen/directions/bake_figure.rb +14 -1
  40. data/lib/kitchen/directions/bake_first_elements.rb +22 -0
  41. data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
  42. data/lib/kitchen/directions/bake_footnotes/v1.rb +13 -9
  43. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  44. data/lib/kitchen/directions/{bake_chapter_review → bake_free_response}/main.rb +3 -3
  45. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  46. data/lib/kitchen/directions/bake_further_research.rb +61 -0
  47. data/lib/kitchen/directions/bake_index/v1.rb +36 -26
  48. data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
  49. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +4 -0
  50. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/main.rb +43 -0
  51. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v1.rb +37 -0
  52. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v2.rb +25 -0
  53. data/lib/kitchen/directions/bake_notes/bake_numbered_notes/v3.rb +32 -0
  54. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +7 -2
  55. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +34 -12
  56. data/lib/kitchen/directions/bake_numbered_table/bake_table_body.rb +29 -0
  57. data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -0
  58. data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -24
  59. data/lib/kitchen/directions/bake_numbered_table/v2.rb +31 -0
  60. data/lib/kitchen/directions/bake_page_abstracts.rb +1 -1
  61. data/lib/kitchen/directions/bake_preface/main.rb +2 -2
  62. data/lib/kitchen/directions/bake_preface/v1.rb +3 -2
  63. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  64. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  65. data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
  66. data/lib/kitchen/directions/bake_toc.rb +4 -2
  67. data/lib/kitchen/directions/book_answer_key_container/eob_answer_key_outer_container.xhtml.erb +9 -0
  68. data/lib/kitchen/directions/book_answer_key_container/main.rb +11 -0
  69. data/lib/kitchen/directions/book_answer_key_container/v1.rb +14 -0
  70. data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
  71. data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
  72. data/lib/kitchen/directions/chapter_review_container/v1.rb +15 -0
  73. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +14 -1
  74. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +37 -0
  75. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v1.rb +8 -10
  76. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v2.rb +8 -9
  77. data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +49 -0
  78. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/main.rb +7 -3
  79. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/calculus.rb +1 -1
  80. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +27 -0
  81. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/precalculus.rb +84 -0
  82. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/uphysics.rb +7 -5
  83. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/v1.rb +12 -6
  84. data/lib/kitchen/document.rb +20 -42
  85. data/lib/kitchen/element.rb +9 -3
  86. data/lib/kitchen/element_base.rb +108 -21
  87. data/lib/kitchen/element_enumerator_base.rb +33 -2
  88. data/lib/kitchen/element_enumerator_factory.rb +28 -12
  89. data/lib/kitchen/element_factory.rb +3 -3
  90. data/lib/kitchen/example_element.rb +8 -11
  91. data/lib/kitchen/example_element_enumerator.rb +1 -1
  92. data/lib/kitchen/exercise_element.rb +7 -10
  93. data/lib/kitchen/exercise_element_enumerator.rb +1 -1
  94. data/lib/kitchen/figure_element.rb +8 -11
  95. data/lib/kitchen/figure_element_enumerator.rb +1 -1
  96. data/lib/kitchen/id_tracker.rb +68 -0
  97. data/lib/kitchen/metadata_element.rb +8 -2
  98. data/lib/kitchen/metadata_element_enumerator.rb +1 -1
  99. data/lib/kitchen/note_element.rb +8 -11
  100. data/lib/kitchen/note_element_enumerator.rb +1 -1
  101. data/lib/kitchen/oven.rb +5 -1
  102. data/lib/kitchen/page_element.rb +27 -12
  103. data/lib/kitchen/page_element_enumerator.rb +1 -1
  104. data/lib/kitchen/patches/i18n.rb +34 -0
  105. data/lib/kitchen/patches/integer.rb +24 -0
  106. data/lib/kitchen/patches/nokogiri.rb +62 -0
  107. data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
  108. data/lib/kitchen/reference_element.rb +27 -0
  109. data/lib/kitchen/references_element_enumerator.rb +20 -0
  110. data/lib/kitchen/search_query.rb +31 -3
  111. data/lib/kitchen/selector.rb +25 -0
  112. data/lib/kitchen/selectors/base.rb +39 -0
  113. data/lib/kitchen/selectors/standard_1.rb +13 -0
  114. data/lib/kitchen/table_element.rb +8 -11
  115. data/lib/kitchen/table_element_enumerator.rb +1 -1
  116. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  117. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  118. data/lib/kitchen/term_element.rb +5 -8
  119. data/lib/kitchen/term_element_enumerator.rb +1 -1
  120. data/lib/kitchen/unit_element.rb +13 -7
  121. data/lib/kitchen/unit_element_enumerator.rb +1 -1
  122. data/lib/kitchen/version.rb +1 -1
  123. data/lib/locales/en.yml +5 -1
  124. data/lib/locales/es.yml +33 -0
  125. data/lib/locales/pl.yml +3 -2
  126. data/lib/openstax_kitchen.rb +2 -5
  127. data/openstax_kitchen.gemspec +1 -0
  128. metadata +66 -25
  129. data/.github/config.yml +0 -14
  130. data/lib/kitchen/directions/bake_book_answer_key/eob_solutions_container.xhtml.erb +0 -9
  131. data/lib/kitchen/directions/bake_book_answer_key/main.rb +0 -11
  132. data/lib/kitchen/directions/bake_book_answer_key/v1.rb +0 -13
  133. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -39
  134. data/lib/kitchen/directions/bake_chapter_key_concepts/key_concepts.xhtml.erb +0 -16
  135. data/lib/kitchen/directions/bake_chapter_review/chapter_review.xhtml.erb +0 -9
  136. data/lib/kitchen/directions/bake_chapter_review/v1.rb +0 -13
  137. data/lib/kitchen/directions/bake_chapter_review_exercises/main.rb +0 -15
  138. data/lib/kitchen/directions/bake_chapter_review_exercises/review_exercises.xhtml.erb +0 -10
  139. data/lib/kitchen/directions/bake_exercises/main.rb +0 -12
  140. data/lib/kitchen/directions/bake_exercises/v1.rb +0 -169
  141. data/lib/kitchen/directions/bake_notes/bake_notes.rb +0 -48
  142. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +0 -63
  143. data/lib/kitchen/directions/bake_problem_first_elements.rb +0 -16
  144. data/lib/kitchen/transliterations.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e855f5598f3d3a425d670a828131a25605935b01ce0de9c38cceea7bb27703f
4
- data.tar.gz: 50b1a58be988e539a031390ee7387a1249a1ddcdc2734c3b9a0d9c9dfa43b426
3
+ metadata.gz: 544eb8b780fd248111e4dc9738c32b7edfefc101fbf6abd82f25c01bada69708
4
+ data.tar.gz: c3f1e2658259f5d9a04dde8aa188793c3c82e8ef6a4f6c1354e2b50d5ed7982d
5
5
  SHA512:
6
- metadata.gz: 844384ec30da9c49e15026d1e5604e7248ef3a2806bbd242be398a04d6d8bddb8924225036dc3f4cfd0a0033fa27fa0bb975768317ddae012684bcf01e5b7483
7
- data.tar.gz: 3f68410be5d1f0e7b06a8f8b618f44cd022a35d6e5ab6ce76a785eb5f702cd22ef2312cba218d8d0fb0628ce13d04cffc023fc647bee16c6ebe6ab566c2f862e
6
+ metadata.gz: 1829a8193fd8d53e2eaa4d91bd00417eb439b1dce3e690b865ff7741d3aad8637282a680f7840842180bfd811cbd79d7275b1c75502fdbcb72d39ed81572b905
7
+ data.tar.gz: 6cf08743860774a7f7b6fa73d26d4adbc56d7e2849e2178fc020456f113774942d23f7f14f2a5f02393c43cbfa0312b787bbb8a1adbdca4943fd76cb697ff9c0
@@ -0,0 +1,27 @@
1
+ name: CHANGELOG.md
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ exists:
11
+ timeout-minutes: 10
12
+ runs-on: ubuntu-18.04
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ with:
17
+ fetch-depth: 0
18
+ - name: Check for CHANGELOG.md in this PR
19
+ # https://dev.to/scienta/get-changed-files-in-github-actions-1p36
20
+ run: |
21
+ if [[ $(git diff --name-only --diff-filter=ACMRT ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep CHANGELOG.md) ]]; then
22
+ echo "CHANGELOG.md is included in the pull request! Way to go!"
23
+ exit 0
24
+ else
25
+ echo "CHANGELOG.md was not modified in this pull request. Boo!"
26
+ exit 1
27
+ fi
@@ -0,0 +1,28 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ lint:
11
+ timeout-minutes: 10
12
+ runs-on: ubuntu-18.04
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ with:
17
+ fetch-depth: 0
18
+ - uses: actions/cache@v2
19
+ with:
20
+ path: vendor/bundle
21
+ key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
22
+ restore-keys: |
23
+ ${{ runner.os }}-gems-
24
+ - name: Build docker image and run rubocop within it
25
+ # See https://docs.codecov.io/docs/testing-with-docker
26
+ run: |
27
+ ./docker/build --ci
28
+ ./docker/rubocop ${{ github.event.pull_request.base.sha }} ${{ github.sha }}
data/.gitignore CHANGED
@@ -7,6 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /vendor/
10
11
 
11
12
  # rspec failure tracking
12
13
  .rspec_status
@@ -17,4 +18,3 @@ tutorial/outputs/*.html
17
18
 
18
19
  tutorials/**/actual_baked.*html
19
20
  tutorials/**/my_recipe.rb
20
-
data/CHANGELOG.md CHANGED
@@ -6,8 +6,101 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- ## [3.2.0] - 2021-04-19
10
9
 
10
+ ## [6.0.0] - 2021-06-15
11
+
12
+ * Allow `BakeChapterSummary` to skip pages where there is no summary (minor)
13
+ * Change `PageElement#summary` to return nil instead of raise an error if no matches (major?)
14
+ * Fix bug in `BakeNumberedNotes:::V3` when there are multiple os-numbers (minor)
15
+ * Add Rubocop and a working CHANGELOG check to GitHub actions (patch)
16
+ * Allow `BakeFootnotes` to number footnotes with Roman numerals (minor)
17
+ * Create V2 for `BakeNumberedTables` (minor)
18
+ * Remove extraneous title in `BakeChapterSectionExercises` (minor)
19
+ * Create V2 for `BookAnswerKeyContainer` and `MoveSolutionsToEOC` with singular option for wrapper class (minor)
20
+ * Delete `abstract` and `description` elements from preface in `BakePreface` (minor)
21
+ * Stop deleting the first `<strong>` tag in `BakeNumberedNotes` (major)
22
+ * Allow `BakeFigure` to bake unnumbered splash figures (minor)
23
+ * Extend `ChapterReviewContainer` to accept other classes (major?)
24
+ * Add a `Strategy` for Precalculus (minor)
25
+ * Create a `BakeNumberedNotes` V2 (minor)
26
+ * Added a version of `BakeChapterIntroductions` without a chapter outline (minor)
27
+ * Add `BakeChapterSolutions` which bakes the free response solutions at the eoc (minor)
28
+ * Changed locale `eoc_answer_key_title` to `answer_key_title` as it was only used in eob (major)
29
+ * Added spec for translations (minor)
30
+ * Remove summary attribute from numbered tables, add option to pass title element to `BakePreface` (minor)
31
+ * Renamed `American Government` strategy to `Default` inside `move_solutions_to_answer_key` for other books to use it with a sent in classname (major)
32
+ * Adds `#previous` method to note_elements to find the immediately previous element (minor)
33
+ * Adds `BakeNumberedNotes` V3 (minor)
34
+ * Added line that puts the classname `has-footnote` in the footnote ref's parent element (major)
35
+ * Added a condition into `BakeChapterSummary` so it doesn't bake the title if it already includes the respective number in it
36
+ * Create v3 of MoveExercisesToEOC which differs from v1 by the presence of a section title
37
+ and from v2 the lack of additional "os-section-area" and os-#{@klass} wrapper (minor)
38
+ * Add a condition in BakeNumberedExercise to make it possible to suppress even solutions in the Answer Key (minor)
39
+ * Fix BakeFurtherResearch baking with main bake script error by breaking the loop if further research sections are not present (minor)
40
+ * Fix for `BakeIndex` for words that start with a number to be grouped as symbols and for first letters with accent marks to be grouped with regular letters in alphabetic order (major)
41
+
42
+ ## [5.0.0] - 2021-06-02
43
+
44
+ * Reditributed duplicated id logic across `#record_id_copied`, `#record_id_cut`, `#record_id_pasted`, added a couple more tests for `#copy`, `#cut`, and `#paste`, created a new class `IdTracker` and moved `#record_id_copied`, `#record_id_cut`, `#record_id_pasted`, and `modified_id_to_paste` into the new class (major)
45
+ * Moved selectors from recipe to kitchen on `BakeFirstElements` Direction (minor)
46
+ * Auto-detect language based on document; force output encoding to UTF-8 (major)
47
+ * Switched to using a library to sort strings in a language-specific way (patch)
48
+ * Remove summary attribute from `BakeNumberedTable` (major)
49
+
50
+ ## [4.1.1] - 2021-05-24
51
+
52
+ * Adds low level Nokogiri caching, disabled by default (patch)
53
+ * Cache Selector objects since they don't change (patch)
54
+ * Use more specific selectors when to reduce bake time (patch)
55
+
56
+ ## [4.1.0] - 2021-05-18
57
+
58
+ * Fixed performance problem with element class detection (patch)
59
+ * Added `BakeChapterReferences` Directions (minor)
60
+
61
+ ## [4.0.0] - 2021-05-18
62
+
63
+ * Changes `default_css_or_xpath` to optionally be a proc to be evaluated w.r.t. a document's config (minor)
64
+ * Support namespaces defined on elements other than the root (minor)
65
+ * Non-splash figures now treated like normal intro-body content in `BakeChapterIntroductions`
66
+ * `BakeNumberedNotes` and the uphysics strategy for `MoveSolutionsToAnswerKey` updated to accomodate multiple exercises in a note.
67
+ * `BakeFootnotes` now looks for footnotes in composite chapters
68
+ * Move exercise pantry label storage to `BakeNumberedExercises` to ensure consistency between exercise number and link text
69
+ * Update `BakeIndex` term capitalization handling to be less case sensitive (minor)
70
+ * Added a title tag variable to choose between h2 and h3 for children of chapter review (minor)
71
+ * Added a fix for examples not to bake table captions (minor)
72
+ * Replaced a .text with .children to include math text (minor)
73
+ * Changed title tag on numbered notes to always be h3 (major)
74
+ * Storing all note subtitles in the pantry for link placeholders (minor)
75
+ * Added another xmlns string option to remove if clone (minor)
76
+ * Add class to reference superscript & add metadata to `BakeSuggestedReading` (minor)
77
+ * Add `BakeFreeResponse` Directions (minor)
78
+ * Add terms from composite pages to index (minor)
79
+ * Access `.pantry` and `.clipboard` through an element instead of just its document (minor)
80
+ * Add `suppress_solution` option to `BakeNumberedExercise` (minor)
81
+ * Add strategy for American Government answer key (minor)
82
+ * Add `BakeReferences` direction (minor)
83
+ * Fix xmlns string replacement done in PR #209 (minor)
84
+ * Move title above metadata in `BakeSuggestedReading` direction (major)
85
+ * Remove depreciated directions `BakeNotes` and `BakeExercises` (major)
86
+ * Adds `eoc_composite_metadata_title` to en.yml and eoc template (major)
87
+ * Add `template` folder to kitchen to hold templates (minor)
88
+ * Add `eoc_section_title_template` (minor)
89
+ * Expand specs with `append_to` to have with/without `append_to` contexts (minor)
90
+ * Add `is?` method to `ElementBase` (minor)
91
+ * Replaced in_composite_chapter to use `is?` (minor)
92
+ * Add callable `short_type` to Elements (minor)
93
+ * Add template for eob titles - `eob_section_title_template` (minor)
94
+
95
+ ## [3.2.0] - 2021-04-20
96
+
97
+ * Adds method to allow unit and page title text to be retrieved regardless of bake status (minor)
98
+ * Rename several directions (major)
99
+ * `BakeChapterReviewExercises` -> `MoveExercisesToEOC`
100
+ * `BakeChapterReview` -> `ChapterReviewContainer`
101
+ * `BakeBookAnswerKey` -> `BookAnswerKeyContainer`
102
+ * `BakeChapterAnswerKey` -> `MoveSolutionsToAnswerKey`
103
+ * Refactors `BakeFirstElements` and `BakeNumberedExercise` (minor)
11
104
  * Adds a decorating option of equation numbers on `BakeEquations` (minor)
12
105
 
13
106
  ## [3.1.0] - 2021-04-19
data/Gemfile.lock CHANGED
@@ -1,30 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (3.2.0)
4
+ openstax_kitchen (6.0.0)
5
5
  activesupport
6
6
  i18n
7
7
  nokogiri
8
8
  rainbow
9
+ twitter_cldr
9
10
 
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- activesupport (6.0.3.3)
14
+ activesupport (6.1.3.2)
14
15
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
- i18n (>= 0.7, < 2)
16
- minitest (~> 5.1)
17
- tzinfo (~> 1.1)
18
- zeitwerk (~> 2.2, >= 2.2.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ zeitwerk (~> 2.3)
19
20
  ast (2.4.1)
20
21
  byebug (11.1.2)
21
- codecov (0.2.13)
22
- simplecov (~> 0.18.0)
22
+ camertron-eprun (1.1.1)
23
+ cldr-plurals-runtime-rb (1.1.0)
24
+ codecov (0.5.2)
25
+ simplecov (>= 0.15, < 0.22)
23
26
  coderay (1.1.3)
24
- concurrent-ruby (1.1.7)
27
+ concurrent-ruby (1.1.9)
25
28
  diff-lcs (1.3)
26
- docile (1.3.3)
27
- i18n (1.8.5)
29
+ docile (1.4.0)
30
+ i18n (1.8.10)
28
31
  concurrent-ruby (~> 1.0)
29
32
  inch (0.8.0)
30
33
  pry
@@ -33,7 +36,7 @@ GEM
33
36
  yard (~> 0.9.12)
34
37
  method_source (1.0.0)
35
38
  mini_portile2 (2.5.0)
36
- minitest (5.14.2)
39
+ minitest (5.14.4)
37
40
  nokogiri (1.11.1)
38
41
  mini_portile2 (~> 2.5.0)
39
42
  racc (~> 1.4)
@@ -52,7 +55,7 @@ GEM
52
55
  rainbow (3.0.0)
53
56
  rake (12.3.3)
54
57
  regexp_parser (2.0.1)
55
- rexml (3.2.4)
58
+ rexml (3.2.5)
56
59
  rspec (3.9.0)
57
60
  rspec-core (~> 3.9.0)
58
61
  rspec-expectations (~> 3.9.0)
@@ -83,23 +86,28 @@ GEM
83
86
  rubocop (~> 1.0)
84
87
  rubocop-ast (>= 1.1.0)
85
88
  ruby-progressbar (1.10.1)
86
- simplecov (0.18.5)
89
+ simplecov (0.21.2)
87
90
  docile (~> 1.1)
88
91
  simplecov-html (~> 0.11)
92
+ simplecov_json_formatter (~> 0.1)
89
93
  simplecov-html (0.12.3)
94
+ simplecov_json_formatter (0.1.3)
90
95
  sparkr (0.4.1)
91
96
  sync (0.5.0)
92
97
  tdiff (0.3.4)
93
98
  term-ansicolor (1.7.1)
94
99
  tins (~> 1.0)
95
- thread_safe (0.3.6)
96
100
  tins (1.26.0)
97
101
  sync
98
- tzinfo (1.2.7)
99
- thread_safe (~> 0.1)
102
+ twitter_cldr (6.6.0)
103
+ camertron-eprun
104
+ cldr-plurals-runtime-rb (~> 1.1)
105
+ tzinfo
106
+ tzinfo (2.0.4)
107
+ concurrent-ruby (~> 1.0)
100
108
  unicode-display_width (1.7.0)
101
109
  yard (0.9.24)
102
- zeitwerk (2.4.0)
110
+ zeitwerk (2.4.2)
103
111
 
104
112
  PLATFORMS
105
113
  ruby
data/README.md CHANGED
@@ -641,6 +641,22 @@ expect(book_1).to match_normalized_html("some string of HTML here")
641
641
  expect(book_1).to match_html_nodes("some string of HTML here")
642
642
  ```
643
643
 
644
+ ### Profiling
645
+
646
+ If you set the `PROFILE` environment variable to something before you run specs or a recipe, search query profile data will be collected and printed, e.g.
647
+
648
+ ```bash
649
+ %> PROFILE=1 rspec
650
+ ```
651
+
652
+ ### Caching
653
+
654
+ There's a low-level CSS query caching tool that saves repeated queries. In some tests, it saves 15% of query time. It is disabled by default (because we aren't super sure that it is completely safe) but can be turned on with
655
+
656
+ ```ruby
657
+ doc.config.enable_search_cache = true
658
+ ```
659
+
644
660
  ### VSCode
645
661
 
646
662
  1. Visit `vscode:extension/ms-vscode-remote.remote-containers` in a browser
data/codecov.yaml CHANGED
@@ -25,3 +25,4 @@ ignore:
25
25
  - "bin"
26
26
  - "docker"
27
27
  - "books"
28
+ - "lib/kitchen/patches/nokogiri_profiling"
data/docker/ci CHANGED
@@ -10,7 +10,6 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
10
10
  docker run $CI_ENV \
11
11
  -e ENABLE_CODECOV=1 -e CI=true \
12
12
  -v $DIR/..:/code \
13
- -v vendor/bundle \
14
13
  -w /code \
15
14
  openstax/kitchen.ci:latest \
16
15
  /bin/bash -c "bundle config path vendor/bundle; bundle install; bundle exec rspec"
data/docker/rubocop ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # set -x
4
+
5
+ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6
+
7
+ from="${1:-main}"
8
+ to="${2:-HEAD}"
9
+
10
+ echo "Checking from $from to $to"
11
+
12
+ # https://dev.to/scienta/get-changed-files-in-github-actions-1p36
13
+ changed_ruby_files=$(git diff --name-only --diff-filter=ACMRT $from $to | grep -E "(lib\/|spec\/)*.rb$" | xargs)
14
+
15
+ if [[ -z "${changed_ruby_files// }" ]]; then
16
+ echo "No files to lint with Rubocop"
17
+ else
18
+ docker run -v $DIR/..:/code \
19
+ -w /code \
20
+ openstax/kitchen.ci:latest \
21
+ /bin/bash -c "bundle config path vendor/bundle; bundle install; bundle exec rubocop $changed_ruby_files --disable-pending-cops"
22
+ fi
@@ -29,7 +29,7 @@ module Kitchen
29
29
  # @return [BookElement]
30
30
  #
31
31
  def book
32
- BookElement.new(node: nokogiri_document.search('html').first, document: self)
32
+ BookElement.new(node: nokogiri_document.root, document: self)
33
33
  end
34
34
 
35
35
  end
@@ -13,8 +13,14 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: BookElementEnumerator,
17
- short_type: :book)
16
+ enumerator_class: BookElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :book
18
24
  end
19
25
 
20
26
  # Returns the "body" element
@@ -41,5 +47,13 @@ module Kitchen
41
47
  first!('nav#toc')
42
48
  end
43
49
 
50
+ # Returns true if this class represents the element for the given node
51
+ #
52
+ # @param node [Nokogiri::XML::Node] the underlying node
53
+ # @return [Boolean]
54
+ #
55
+ def self.is_the_element_class_for?(node, **)
56
+ node.name == 'body'
57
+ end
44
58
  end
45
59
  end
@@ -13,8 +13,14 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: ChapterElementEnumerator,
17
- short_type: :chapter)
16
+ enumerator_class: ChapterElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :chapter
18
24
  end
19
25
 
20
26
  # Returns the title element (the one in the immediate children, not the one in the metadata)
@@ -35,7 +41,7 @@ module Kitchen
35
41
  # @return [Element, nil]
36
42
  #
37
43
  def introduction_page
38
- pages('.introduction').first
44
+ pages('$.introduction').first
39
45
  end
40
46
 
41
47
  # Returns an enumerator for the glossaries
@@ -59,16 +65,7 @@ module Kitchen
59
65
  # @return [ElementEnumerator]
60
66
  #
61
67
  def abstracts
62
- search('[data-type="abstract"]')
63
- end
64
-
65
- # Returns true if this class represents the element for the given node
66
- #
67
- # @param node [Nokogiri::XML::Node] the underlying node
68
- # @return [Boolean]
69
- #
70
- def self.is_the_element_class_for?(node)
71
- node['data-type'] == 'chapter'
68
+ search('div[data-type="abstract"]')
72
69
  end
73
70
 
74
71
  end
@@ -11,7 +11,7 @@ module Kitchen
11
11
  #
12
12
  def self.factory
13
13
  ElementEnumeratorFactory.new(
14
- default_css_or_xpath: "div[data-type='chapter']", # TODO: element.document.selectors.chapter
14
+ default_css_or_xpath: Selector.named(:chapter),
15
15
  sub_element_class: ChapterElement,
16
16
  enumerator_class: self
17
17
  )
@@ -13,8 +13,13 @@ module Kitchen
13
13
  def initialize(node:, document: nil)
14
14
  super(node: node,
15
15
  document: document,
16
- enumerator_class: ElementEnumerator,
17
- short_type: :composite_chapter)
16
+ enumerator_class: ElementEnumerator)
17
+ end
18
+
19
+ # Returns short type
20
+ #
21
+ def self.short_type
22
+ :composite_chapter
18
23
  end
19
24
 
20
25
  # Returns the title element (the one in the immediate children, not the one in the metadata)
@@ -29,14 +34,5 @@ module Kitchen
29
34
  first!("./*[@data-type = 'document-title']")
30
35
  end
31
36
 
32
- # Returns true if this class represents the element for the given node
33
- #
34
- # @param node [Nokogiri::XML::Node] the underlying node
35
- # @return [Boolean]
36
- #
37
- def self.is_the_element_class_for?(node)
38
- node['data-type'] == 'composite-chapter'
39
- end
40
-
41
37
  end
42
38
  end