openstax_kitchen 3.1.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/CHANGELOG.md +64 -0
  4. data/Gemfile.lock +20 -14
  5. data/README.md +16 -0
  6. data/codecov.yaml +1 -0
  7. data/docker/ci +0 -1
  8. data/lib/kitchen/book_document.rb +1 -1
  9. data/lib/kitchen/book_element.rb +16 -2
  10. data/lib/kitchen/chapter_element.rb +10 -13
  11. data/lib/kitchen/chapter_element_enumerator.rb +1 -1
  12. data/lib/kitchen/composite_chapter_element.rb +7 -11
  13. data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
  14. data/lib/kitchen/composite_page_element.rb +15 -10
  15. data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
  16. data/lib/kitchen/config.rb +14 -0
  17. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  18. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  19. data/lib/kitchen/directions/bake_chapter_introductions.rb +1 -1
  20. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +7 -2
  21. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +12 -7
  22. data/lib/kitchen/directions/bake_chapter_key_equations.rb +26 -21
  23. data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
  24. data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
  25. data/lib/kitchen/directions/bake_chapter_summary.rb +48 -42
  26. data/lib/kitchen/directions/bake_composite_chapters.rb +1 -1
  27. data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
  28. data/lib/kitchen/directions/bake_equations.rb +14 -4
  29. data/lib/kitchen/directions/bake_example.rb +5 -1
  30. data/lib/kitchen/directions/bake_figure.rb +1 -1
  31. data/lib/kitchen/directions/bake_first_elements.rb +22 -0
  32. data/lib/kitchen/directions/bake_footnotes/v1.rb +2 -1
  33. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  34. data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
  35. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  36. data/lib/kitchen/directions/bake_further_research.rb +59 -0
  37. data/lib/kitchen/directions/bake_index/v1.rb +36 -26
  38. data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
  39. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +4 -0
  40. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +9 -21
  41. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +6 -2
  42. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +25 -12
  43. data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -8
  44. data/lib/kitchen/directions/bake_page_abstracts.rb +1 -1
  45. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  46. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  47. data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
  48. data/lib/kitchen/directions/bake_toc.rb +4 -2
  49. data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/eob_solutions_container.xhtml.erb +0 -0
  50. data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/main.rb +1 -1
  51. data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/v1.rb +2 -2
  52. data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/chapter_review.xhtml.erb +0 -0
  53. data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/main.rb +1 -1
  54. data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/v1.rb +2 -2
  55. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +1 -1
  56. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
  57. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v1.rb +8 -10
  58. data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v2.rb +8 -9
  59. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/main.rb +1 -1
  60. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
  61. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/calculus.rb +1 -1
  62. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/uphysics.rb +7 -5
  63. data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/v1.rb +3 -1
  64. data/lib/kitchen/document.rb +20 -42
  65. data/lib/kitchen/element.rb +9 -3
  66. data/lib/kitchen/element_base.rb +93 -21
  67. data/lib/kitchen/element_enumerator_base.rb +33 -2
  68. data/lib/kitchen/element_enumerator_factory.rb +28 -12
  69. data/lib/kitchen/element_factory.rb +3 -3
  70. data/lib/kitchen/example_element.rb +8 -11
  71. data/lib/kitchen/example_element_enumerator.rb +1 -1
  72. data/lib/kitchen/exercise_element.rb +7 -10
  73. data/lib/kitchen/exercise_element_enumerator.rb +1 -1
  74. data/lib/kitchen/figure_element.rb +8 -11
  75. data/lib/kitchen/figure_element_enumerator.rb +1 -1
  76. data/lib/kitchen/id_tracker.rb +68 -0
  77. data/lib/kitchen/metadata_element.rb +8 -2
  78. data/lib/kitchen/metadata_element_enumerator.rb +1 -1
  79. data/lib/kitchen/note_element.rb +8 -11
  80. data/lib/kitchen/note_element_enumerator.rb +1 -1
  81. data/lib/kitchen/oven.rb +5 -1
  82. data/lib/kitchen/page_element.rb +25 -9
  83. data/lib/kitchen/page_element_enumerator.rb +1 -1
  84. data/lib/kitchen/patches/i18n.rb +34 -0
  85. data/lib/kitchen/patches/nokogiri.rb +55 -0
  86. data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
  87. data/lib/kitchen/reference_element.rb +27 -0
  88. data/lib/kitchen/references_element_enumerator.rb +20 -0
  89. data/lib/kitchen/search_query.rb +31 -3
  90. data/lib/kitchen/selector.rb +25 -0
  91. data/lib/kitchen/selectors/base.rb +39 -0
  92. data/lib/kitchen/selectors/standard_1.rb +13 -0
  93. data/lib/kitchen/table_element.rb +8 -11
  94. data/lib/kitchen/table_element_enumerator.rb +1 -1
  95. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  96. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  97. data/lib/kitchen/term_element.rb +5 -8
  98. data/lib/kitchen/term_element_enumerator.rb +1 -1
  99. data/lib/kitchen/unit_element.rb +13 -7
  100. data/lib/kitchen/unit_element_enumerator.rb +1 -1
  101. data/lib/kitchen/version.rb +1 -1
  102. data/lib/locales/en.yml +3 -0
  103. data/lib/locales/es.yml +32 -0
  104. data/lib/openstax_kitchen.rb +2 -5
  105. data/openstax_kitchen.gemspec +1 -0
  106. metadata +51 -23
  107. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -39
  108. data/lib/kitchen/directions/bake_chapter_key_concepts/key_concepts.xhtml.erb +0 -16
  109. data/lib/kitchen/directions/bake_chapter_review_exercises/main.rb +0 -15
  110. data/lib/kitchen/directions/bake_chapter_review_exercises/review_exercises.xhtml.erb +0 -10
  111. data/lib/kitchen/directions/bake_exercises/main.rb +0 -12
  112. data/lib/kitchen/directions/bake_exercises/v1.rb +0 -169
  113. data/lib/kitchen/directions/bake_notes/bake_notes.rb +0 -48
  114. data/lib/kitchen/directions/bake_problem_first_elements.rb +0 -16
  115. data/lib/kitchen/transliterations.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 994e6a3d5161afbcd853fe2b432e7aeb80bf2390d4d7b7ae8463e6da8ce21f15
4
- data.tar.gz: 7c276963aaa777b1e6116b98a9af0659f8b4e9c1491a3fe968bd9f15fc46f61c
3
+ metadata.gz: c8e1365bab888949c899b5cb36518be9456bd23d0369ddab9a42ac81f82cc024
4
+ data.tar.gz: cd86a88028f0946885add3866ffad6133f84ce48a779800cb5105cc8153736d4
5
5
  SHA512:
6
- metadata.gz: a0041d04e8a1e39295c21ed0884db3e1b838edac90c7c317409b3499e1e2d5744450d26ccb1518a55c7cf6ec39a35b278e03781b8f9933486d789583b9c39bdd
7
- data.tar.gz: f9207ee80e17ae3035d2c29cca11f4d59e10afc7193e73f751763fb27987477e7cffcc914166927d196484c0c82767d3c1302bca92a64098d4eb2674edb83843
6
+ metadata.gz: 16b9afc1d63a6098aad2396e114975ea35d39890c9a4c27c88dfef7710d129ddf16e3f18d775042ae919d0dff5284d41b53f668621d5cd74f2e723a670fd33d9
7
+ data.tar.gz: 9b93c51846a460a3e71c6a6080f53be61f1fa93ab268f954ddf3b7d447a1f9602dd789d876bc41e2997f8f44e682453c413f2f28ea7754c4d7f1015d3ecde1a6
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,6 +6,70 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [5.0.0] - 2021-06-02
10
+
11
+ * 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)
12
+ * Moved selectors from recipe to kitchen on `BakeFirstElements` Direction (minor)
13
+ * Auto-detect language based on document; force output encoding to UTF-8 (major)
14
+ * Switched to using a library to sort strings in a language-specific way (patch)
15
+ * Remove summary attribute from `BakeNumberedTable` (major)
16
+
17
+ ## [4.1.1] - 2021-05-24
18
+
19
+ * Adds low level Nokogiri caching, disabled by default (patch)
20
+ * Cache Selector objects since they don't change (patch)
21
+ * Use more specific selectors when to reduce bake time (patch)
22
+
23
+ ## [4.1.0] - 2021-05-18
24
+
25
+ * Fixed performance problem with element class detection (patch)
26
+ * Added `BakeChapterReferences` Directions (minor)
27
+
28
+ ## [4.0.0] - 2021-05-18
29
+
30
+ * Changes `default_css_or_xpath` to optionally be a proc to be evaluated w.r.t. a document's config (minor)
31
+ * Support namespaces defined on elements other than the root (minor)
32
+ * Non-splash figures now treated like normal intro-body content in `BakeChapterIntroductions`
33
+ * `BakeNumberedNotes` and the uphysics strategy for `MoveSolutionsToAnswerKey` updated to accomodate multiple exercises in a note.
34
+ * `BakeFootnotes` now looks for footnotes in composite chapters
35
+ * Move exercise pantry label storage to `BakeNumberedExercises` to ensure consistency between exercise number and link text
36
+ * Update `BakeIndex` term capitalization handling to be less case sensitive (minor)
37
+ * Added a title tag variable to choose between h2 and h3 for children of chapter review (minor)
38
+ * Added a fix for examples not to bake table captions (minor)
39
+ * Replaced a .text with .children to include math text (minor)
40
+ * Changed title tag on numbered notes to always be h3 (major)
41
+ * Storing all note subtitles in the pantry for link placeholders (minor)
42
+ * Added another xmlns string option to remove if clone (minor)
43
+ * Add class to reference superscript & add metadata to `BakeSuggestedReading` (minor)
44
+ * Add `BakeFreeResponse` Directions (minor)
45
+ * Add terms from composite pages to index (minor)
46
+ * Access `.pantry` and `.clipboard` through an element instead of just its document (minor)
47
+ * Add `suppress_solution` option to `BakeNumberedExercise` (minor)
48
+ * Add strategy for American Government answer key (minor)
49
+ * Add `BakeReferences` direction (minor)
50
+ * Fix xmlns string replacement done in PR #209 (minor)
51
+ * Move title above metadata in `BakeSuggestedReading` direction (major)
52
+ * Remove depreciated directions `BakeNotes` and `BakeExercises` (major)
53
+ * Adds `eoc_composite_metadata_title` to en.yml and eoc template (major)
54
+ * Add `template` folder to kitchen to hold templates (minor)
55
+ * Add `eoc_section_title_template` (minor)
56
+ * Expand specs with `append_to` to have with/without `append_to` contexts (minor)
57
+ * Add `is?` method to `ElementBase` (minor)
58
+ * Replaced in_composite_chapter to use `is?` (minor)
59
+ * Add callable `short_type` to Elements (minor)
60
+ * Add template for eob titles - `eob_section_title_template` (minor)
61
+
62
+ ## [3.2.0] - 2021-04-20
63
+
64
+ * Adds method to allow unit and page title text to be retrieved regardless of bake status (minor)
65
+ * Rename several directions (major)
66
+ * `BakeChapterReviewExercises` -> `MoveExercisesToEOC`
67
+ * `BakeChapterReview` -> `ChapterReviewContainer`
68
+ * `BakeBookAnswerKey` -> `BookAnswerKeyContainer`
69
+ * `BakeChapterAnswerKey` -> `MoveSolutionsToAnswerKey`
70
+ * Refactors `BakeFirstElements` and `BakeNumberedExercise` (minor)
71
+ * Adds a decorating option of equation numbers on `BakeEquations` (minor)
72
+
9
73
  ## [3.1.0] - 2021-04-19
10
74
 
11
75
  * Add the ability to copy an element's ID to `ElementBase` (minor)
data/Gemfile.lock CHANGED
@@ -1,30 +1,33 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- openstax_kitchen (3.1.0)
4
+ openstax_kitchen (5.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)
22
+ camertron-eprun (1.1.1)
23
+ cldr-plurals-runtime-rb (1.1.0)
21
24
  codecov (0.2.13)
22
25
  simplecov (~> 0.18.0)
23
26
  coderay (1.1.3)
24
- concurrent-ruby (1.1.7)
27
+ concurrent-ruby (1.1.8)
25
28
  diff-lcs (1.3)
26
29
  docile (1.3.3)
27
- i18n (1.8.5)
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)
@@ -92,14 +95,17 @@ GEM
92
95
  tdiff (0.3.4)
93
96
  term-ansicolor (1.7.1)
94
97
  tins (~> 1.0)
95
- thread_safe (0.3.6)
96
98
  tins (1.26.0)
97
99
  sync
98
- tzinfo (1.2.7)
99
- thread_safe (~> 0.1)
100
+ twitter_cldr (6.6.0)
101
+ camertron-eprun
102
+ cldr-plurals-runtime-rb (~> 1.1)
103
+ tzinfo
104
+ tzinfo (2.0.4)
105
+ concurrent-ruby (~> 1.0)
100
106
  unicode-display_width (1.7.0)
101
107
  yard (0.9.24)
102
- zeitwerk (2.4.0)
108
+ zeitwerk (2.4.2)
103
109
 
104
110
  PLATFORMS
105
111
  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"
@@ -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
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ # An enumerator for composite page elements
5
+ #
6
+ class CompositeChapterElementEnumerator < ElementEnumeratorBase
7
+
8
+ # Returns a factory for this enumerator
9
+ #
10
+ # @return [ElementEnumeratorFactory]
11
+ #
12
+ def self.factory
13
+ ElementEnumeratorFactory.new(
14
+ default_css_or_xpath: Selector.named(:composite_chapter),
15
+ sub_element_class: CompositeChapterElement,
16
+ enumerator_class: self
17
+ )
18
+ end
19
+
20
+ end
21
+ 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: CompositePageElementEnumerator,
17
- short_type: :composite_page)
16
+ enumerator_class: CompositePageElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :composite_page
18
24
  end
19
25
 
20
26
  # Returns the title element (the one in the immediate children, not the one in the metadata)
@@ -26,24 +32,23 @@ module Kitchen
26
32
  # Get the title in the immediate children, not the one in the metadata. Could use
27
33
  # CSS of ":not([data-type='metadata']) > [data-type='document-title'], [data-type='document-title']"
28
34
  # but xpath is shorter
29
- first!("./*[@data-type = 'document-title']")
35
+ first!("./*[@data-type = 'document-title' or @data-type = 'title']")
30
36
  end
31
37
 
32
- # Returns true if this class represents the element for the given node
38
+ # Returns true if this page is a book index
33
39
  #
34
- # @param node [Nokogiri::XML::Node] the underlying node
35
40
  # @return [Boolean]
36
41
  #
37
- def self.is_the_element_class_for?(node)
38
- node['data-type'] == 'composite-page'
42
+ def is_index?
43
+ has_class?('os-index-container')
39
44
  end
40
45
 
41
- # Returns true if this page is a book index
46
+ # Returns true if this page is a book reference
42
47
  #
43
48
  # @return [Boolean]
44
49
  #
45
- def is_index?
46
- has_class?('os-index-container')
50
+ def is_reference?
51
+ has_class?('os-reference-container')
47
52
  end
48
53
 
49
54
  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='composite-page']",
14
+ default_css_or_xpath: Selector.named(:composite_page),
15
15
  sub_element_class: CompositePageElement,
16
16
  enumerator_class: self
17
17
  )
@@ -11,6 +11,18 @@ module Kitchen
11
11
  #
12
12
  attr_reader :selectors
13
13
 
14
+ # @!attribute [rw] enable_all_namespaces
15
+ #
16
+ # @return [Boolean]
17
+ #
18
+ attr_accessor :enable_all_namespaces
19
+
20
+ # @!attribute [rw] enable_search_cache
21
+ #
22
+ # @return [Boolean]
23
+ #
24
+ attr_accessor :enable_search_cache
25
+
14
26
  # Creates a new config from a file (not implemented)
15
27
  #
16
28
  def self.new_from_file(_file)
@@ -21,6 +33,8 @@ module Kitchen
21
33
  #
22
34
  def initialize(hash: {}, selectors: nil)
23
35
  @selectors = selectors || Kitchen::Selectors::Standard1.new
36
+ @enable_all_namespaces = hash[:enable_all_namespaces] || true
37
+ @enable_search_cache = hash[:enable_search_cache] || false
24
38
  @hash = hash
25
39
  end
26
40
  end