openstax_kitchen 3.0.0 → 4.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +77 -3
- data/Gemfile.lock +13 -14
- data/README.md +23 -0
- data/codecov.yaml +1 -0
- data/docker/ci +0 -1
- data/lib/kitchen/book_document.rb +1 -1
- data/lib/kitchen/book_element.rb +16 -2
- data/lib/kitchen/chapter_element.rb +10 -13
- data/lib/kitchen/chapter_element_enumerator.rb +1 -1
- data/lib/kitchen/composite_chapter_element.rb +7 -11
- data/lib/kitchen/composite_chapter_element_enumerator.rb +21 -0
- data/lib/kitchen/composite_page_element.rb +15 -10
- data/lib/kitchen/composite_page_element_enumerator.rb +1 -1
- data/lib/kitchen/config.rb +14 -0
- data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
- data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
- data/lib/kitchen/directions/bake_chapter_introductions.rb +1 -1
- data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +16 -0
- data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +35 -0
- data/lib/kitchen/directions/bake_chapter_key_equations.rb +27 -20
- data/lib/kitchen/directions/bake_chapter_references/main.rb +16 -0
- data/lib/kitchen/directions/bake_chapter_references/v1.rb +35 -0
- data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +11 -0
- data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +28 -0
- data/lib/kitchen/directions/bake_chapter_summary.rb +48 -42
- data/lib/kitchen/directions/bake_checkpoint.rb +44 -0
- data/lib/kitchen/directions/bake_composite_chapters.rb +14 -0
- data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
- data/lib/kitchen/directions/bake_equations.rb +37 -0
- data/lib/kitchen/directions/bake_example.rb +34 -8
- data/lib/kitchen/directions/bake_figure.rb +1 -1
- data/lib/kitchen/directions/bake_first_elements.rb +16 -0
- data/lib/kitchen/directions/bake_footnotes/v1.rb +2 -1
- data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
- data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
- data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
- data/lib/kitchen/directions/bake_further_research.rb +59 -0
- data/lib/kitchen/directions/bake_index/v1.rb +35 -14
- data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
- data/lib/kitchen/directions/bake_non_introduction_pages.rb +26 -0
- data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +29 -0
- data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +22 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +51 -0
- data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +30 -0
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +15 -0
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +47 -0
- data/lib/kitchen/directions/bake_numbered_table/main.rb +2 -2
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +18 -4
- data/lib/kitchen/directions/bake_page_abstracts.rb +16 -0
- data/lib/kitchen/directions/bake_references/main.rb +16 -0
- data/lib/kitchen/directions/bake_references/v1.rb +48 -0
- data/lib/kitchen/directions/bake_stepwise.rb +1 -5
- data/lib/kitchen/directions/bake_suggested_reading.rb +5 -0
- data/lib/kitchen/directions/bake_theorem/main.rb +11 -0
- data/lib/kitchen/directions/bake_theorem/v1.rb +28 -0
- data/lib/kitchen/directions/bake_toc.rb +10 -2
- data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +9 -0
- data/lib/kitchen/directions/{bake_exercises → book_answer_key_container}/main.rb +1 -1
- data/lib/kitchen/directions/book_answer_key_container/v1.rb +13 -0
- data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
- data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
- data/lib/kitchen/directions/chapter_review_container/v1.rb +13 -0
- data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +20 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +36 -0
- data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +49 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +14 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +41 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +63 -0
- data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +34 -0
- data/lib/kitchen/document.rb +3 -0
- data/lib/kitchen/element.rb +9 -3
- data/lib/kitchen/element_base.rb +118 -16
- data/lib/kitchen/element_enumerator_base.rb +118 -8
- data/lib/kitchen/element_enumerator_factory.rb +28 -12
- data/lib/kitchen/element_factory.rb +3 -3
- data/lib/kitchen/example_element.rb +8 -11
- data/lib/kitchen/example_element_enumerator.rb +1 -1
- data/lib/kitchen/exercise_element.rb +42 -0
- data/lib/kitchen/exercise_element_enumerator.rb +21 -0
- data/lib/kitchen/figure_element.rb +8 -11
- data/lib/kitchen/figure_element_enumerator.rb +1 -1
- data/lib/kitchen/metadata_element.rb +8 -2
- data/lib/kitchen/metadata_element_enumerator.rb +1 -1
- data/lib/kitchen/note_element.rb +25 -27
- data/lib/kitchen/note_element_enumerator.rb +1 -1
- data/lib/kitchen/oven.rb +2 -0
- data/lib/kitchen/page_element.rb +33 -9
- data/lib/kitchen/page_element_enumerator.rb +1 -1
- data/lib/kitchen/patches/nokogiri.rb +55 -0
- data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
- data/lib/kitchen/recipe.rb +35 -2
- data/lib/kitchen/reference_element.rb +27 -0
- data/lib/kitchen/references_element_enumerator.rb +20 -0
- data/lib/kitchen/search_query.rb +31 -3
- data/lib/kitchen/selector.rb +25 -0
- data/lib/kitchen/selectors/base.rb +39 -0
- data/lib/kitchen/selectors/standard_1.rb +13 -0
- data/lib/kitchen/table_element.rb +8 -11
- data/lib/kitchen/table_element_enumerator.rb +1 -1
- data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
- data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
- data/lib/kitchen/term_element.rb +5 -8
- data/lib/kitchen/term_element_enumerator.rb +1 -1
- data/lib/kitchen/unit_element.rb +13 -7
- data/lib/kitchen/unit_element_enumerator.rb +1 -1
- data/lib/kitchen/version.rb +1 -1
- data/lib/locales/en.yml +12 -7
- data/lib/locales/pl.yml +24 -0
- data/lib/openstax_kitchen.rb +2 -1
- metadata +54 -6
- data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -37
- data/lib/kitchen/directions/bake_exercises/v1.rb +0 -166
- data/lib/kitchen/directions/bake_notes.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b80bf07271b311949246bf6a63a9d10fe5f14396175f66a129debcc9e9ef15e3
|
4
|
+
data.tar.gz: 7a3a7050d134a0b106d3a80dc18add9209742fca1eea4873f351eb0dd4d05034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fee3b2b4dd92639af2e20520c3f65a31255d944df649e91c5c0e5c8f0a8e1e1f6d19b4477480c5cbc899f7124727c8a40b5a0759985ec94225885baf36b3287
|
7
|
+
data.tar.gz: ed62932aa44e597135158cc182daefd2773b89070e1d82750669d4d1f760fa8179f1197c67eddcdec73c1cdc2b1bd7537ca28c8f5603d3a2a7962457d777141f
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,80 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [4.1.1] - 2021-05-24
|
10
|
+
|
11
|
+
* Adds low level Nokogiri caching, disabled by default (patch)
|
12
|
+
* Cache Selector objects since they don't change (patch)
|
13
|
+
* Use more specific selectors when to reduce bake time (patch)
|
14
|
+
|
15
|
+
## [4.1.0] - 2021-05-18
|
16
|
+
|
17
|
+
* Fixed performance problem with element class detection (patch)
|
18
|
+
* Added `BakeChapterReferences` Directions (minor)
|
19
|
+
|
20
|
+
## [4.0.0] - 2021-05-18
|
21
|
+
|
22
|
+
* Changes `default_css_or_xpath` to optionally be a proc to be evaluated w.r.t. a document's config (minor)
|
23
|
+
* Support namespaces defined on elements other than the root (minor)
|
24
|
+
* Non-splash figures now treated like normal intro-body content in `BakeChapterIntroductions`
|
25
|
+
* `BakeNumberedNotes` and the uphysics strategy for `MoveSolutionsToAnswerKey` updated to accomodate multiple exercises in a note.
|
26
|
+
* `BakeFootnotes` now looks for footnotes in composite chapters
|
27
|
+
* Move exercise pantry label storage to `BakeNumberedExercises` to ensure consistency between exercise number and link text
|
28
|
+
* Update `BakeIndex` term capitalization handling to be less case sensitive (minor)
|
29
|
+
* Added a title tag variable to choose between h2 and h3 for children of chapter review (minor)
|
30
|
+
* Added a fix for examples not to bake table captions (minor)
|
31
|
+
* Replaced a .text with .children to include math text (minor)
|
32
|
+
* Changed title tag on numbered notes to always be h3 (major)
|
33
|
+
* Storing all note subtitles in the pantry for link placeholders (minor)
|
34
|
+
* Added another xmlns string option to remove if clone (minor)
|
35
|
+
* Add class to reference superscript & add metadata to `BakeSuggestedReading` (minor)
|
36
|
+
* Add `BakeFreeResponse` Directions (minor)
|
37
|
+
* Add terms from composite pages to index (minor)
|
38
|
+
* Access `.pantry` and `.clipboard` through an element instead of just its document (minor)
|
39
|
+
* Add `suppress_solution` option to `BakeNumberedExercise` (minor)
|
40
|
+
* Add strategy for American Government answer key (minor)
|
41
|
+
* Add `BakeReferences` direction (minor)
|
42
|
+
* Fix xmlns string replacement done in PR #209 (minor)
|
43
|
+
* Move title above metadata in `BakeSuggestedReading` direction (major)
|
44
|
+
* Remove depreciated directions `BakeNotes` and `BakeExercises` (major)
|
45
|
+
* Adds `eoc_composite_metadata_title` to en.yml and eoc template (major)
|
46
|
+
* Add `template` folder to kitchen to hold templates (minor)
|
47
|
+
* Add `eoc_section_title_template` (minor)
|
48
|
+
* Expand specs with `append_to` to have with/without `append_to` contexts (minor)
|
49
|
+
* Add `is?` method to `ElementBase` (minor)
|
50
|
+
* Replaced in_composite_chapter to use `is?` (minor)
|
51
|
+
* Add callable `short_type` to Elements (minor)
|
52
|
+
* Add template for eob titles - `eob_section_title_template` (minor)
|
53
|
+
|
54
|
+
## [3.2.0] - 2021-04-20
|
55
|
+
|
56
|
+
* Adds method to allow unit and page title text to be retrieved regardless of bake status (minor)
|
57
|
+
* Rename several directions (major)
|
58
|
+
* `BakeChapterReviewExercises` -> `MoveExercisesToEOC`
|
59
|
+
* `BakeChapterReview` -> `ChapterReviewContainer`
|
60
|
+
* `BakeBookAnswerKey` -> `BookAnswerKeyContainer`
|
61
|
+
* `BakeChapterAnswerKey` -> `MoveSolutionsToAnswerKey`
|
62
|
+
* Refactors `BakeFirstElements` and `BakeNumberedExercise` (minor)
|
63
|
+
* Adds a decorating option of equation numbers on `BakeEquations` (minor)
|
64
|
+
|
65
|
+
## [3.1.0] - 2021-04-19
|
66
|
+
|
67
|
+
* Add the ability to copy an element's ID to `ElementBase` (minor)
|
68
|
+
* Create `pl.yml` and add pl to available locals in `StubHelpers` module (minor)
|
69
|
+
* Add to `BakeNumberedNotes` directions for baking exercises in a note (with this comes removing bake checkpoints and theorems)
|
70
|
+
* Add `BakeEquations` direction (minor)
|
71
|
+
* Remove `NoteElement` logging (minor)
|
72
|
+
* Adds `BakeChapterReviewExercises` v2 and a u-physics `Strategy` to `BakeChapterAnswerKey` to support baking exercises in u-physics (minor)
|
73
|
+
* Have deprecated directions log a warning (minor)
|
74
|
+
* Added `wrap_children` method on elements (minor)
|
75
|
+
* Refactored `NoteElement` to infer the note title from book-specific locales (minor)
|
76
|
+
* Added support for a recipe to infer or be given a book-specific locale file (minor)
|
77
|
+
* Added `NumberedTable` support for titles and always captions (minor)
|
78
|
+
* Added titles method to `ElementEnumeratorBase` and `ElementBase` (minor)
|
79
|
+
* Added a file for baking composite chapters called (`bake_composite_chapters`) and the respective spec.
|
80
|
+
(minor change)
|
81
|
+
* Added `BakeProblemFirstElements` direction (minor)
|
82
|
+
|
9
83
|
## [3.0.0] - 2021-03-17
|
10
84
|
|
11
85
|
* Added a subfigure? method to `FigureElements`(minor)
|
@@ -19,11 +93,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
19
93
|
* Added ability to filter searches based on `only` and `except` conditions, which can be names of element methods or blocks of code (minor)
|
20
94
|
* Changed from tracking and using `css_or_xpath` strings and arrays to `search_query` objects that
|
21
95
|
wrap `css_or_xpath` variables along with `only` and `except` conditions. (major?)
|
96
|
+
* Refactored bake_exercises to better support parallel work on multiple versions. (minor)
|
22
97
|
|
23
98
|
## [2.0.0] - 2020-12-18
|
24
|
-
|
25
|
-
|
26
|
-
(minor change) Does not affect existing recipes.
|
99
|
+
* Added a file for baking key concepts called (`bake_chapter_key_concepts`) and the respective specs.
|
100
|
+
(minor change) only affects the book if called from the recipe
|
27
101
|
* Changed the main gem source file to have the same name as the gem (`openstax_kitchen`) so that you don't have to `require` a different name than you use in your `gem` call.
|
28
102
|
|
29
103
|
## [1.0.0] - 2020-12-15
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
openstax_kitchen (
|
4
|
+
openstax_kitchen (4.1.1)
|
5
5
|
activesupport
|
6
6
|
i18n
|
7
7
|
nokogiri
|
@@ -10,21 +10,21 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (6.
|
13
|
+
activesupport (6.1.3.2)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (>=
|
16
|
-
minitest (
|
17
|
-
tzinfo (~>
|
18
|
-
zeitwerk (~> 2.
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
zeitwerk (~> 2.3)
|
19
19
|
ast (2.4.1)
|
20
20
|
byebug (11.1.2)
|
21
21
|
codecov (0.2.13)
|
22
22
|
simplecov (~> 0.18.0)
|
23
23
|
coderay (1.1.3)
|
24
|
-
concurrent-ruby (1.1.
|
24
|
+
concurrent-ruby (1.1.8)
|
25
25
|
diff-lcs (1.3)
|
26
26
|
docile (1.3.3)
|
27
|
-
i18n (1.8.
|
27
|
+
i18n (1.8.10)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
29
|
inch (0.8.0)
|
30
30
|
pry
|
@@ -33,7 +33,7 @@ GEM
|
|
33
33
|
yard (~> 0.9.12)
|
34
34
|
method_source (1.0.0)
|
35
35
|
mini_portile2 (2.5.0)
|
36
|
-
minitest (5.14.
|
36
|
+
minitest (5.14.4)
|
37
37
|
nokogiri (1.11.1)
|
38
38
|
mini_portile2 (~> 2.5.0)
|
39
39
|
racc (~> 1.4)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
rainbow (3.0.0)
|
53
53
|
rake (12.3.3)
|
54
54
|
regexp_parser (2.0.1)
|
55
|
-
rexml (3.2.
|
55
|
+
rexml (3.2.5)
|
56
56
|
rspec (3.9.0)
|
57
57
|
rspec-core (~> 3.9.0)
|
58
58
|
rspec-expectations (~> 3.9.0)
|
@@ -92,14 +92,13 @@ GEM
|
|
92
92
|
tdiff (0.3.4)
|
93
93
|
term-ansicolor (1.7.1)
|
94
94
|
tins (~> 1.0)
|
95
|
-
thread_safe (0.3.6)
|
96
95
|
tins (1.26.0)
|
97
96
|
sync
|
98
|
-
tzinfo (
|
99
|
-
|
97
|
+
tzinfo (2.0.4)
|
98
|
+
concurrent-ruby (~> 1.0)
|
100
99
|
unicode-display_width (1.7.0)
|
101
100
|
yard (0.9.24)
|
102
|
-
zeitwerk (2.4.
|
101
|
+
zeitwerk (2.4.2)
|
103
102
|
|
104
103
|
PLATFORMS
|
105
104
|
ruby
|
data/README.md
CHANGED
@@ -210,6 +210,13 @@ And we can wrap an element with another element:
|
|
210
210
|
doc.search("span").first.wrap("<span class='other'>")
|
211
211
|
```
|
212
212
|
|
213
|
+
or wrap an element's children:
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
# <div><span>Hi</span></div> => <div><span><span class="other" data-type="foo">Hi</span></span></div>
|
217
|
+
doc.search("span").first.wrap_children('span', class: 'other', data_type: 'foo')
|
218
|
+
```
|
219
|
+
|
213
220
|
### Checking for elements
|
214
221
|
|
215
222
|
You can see if an element contains an element matching a selector:
|
@@ -634,6 +641,22 @@ expect(book_1).to match_normalized_html("some string of HTML here")
|
|
634
641
|
expect(book_1).to match_html_nodes("some string of HTML here")
|
635
642
|
```
|
636
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
|
+
|
637
660
|
### VSCode
|
638
661
|
|
639
662
|
1. Visit `vscode:extension/ms-vscode-remote.remote-containers` in a browser
|
data/codecov.yaml
CHANGED
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/lib/kitchen/book_element.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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('
|
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:
|
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
|
-
|
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
|
-
|
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
|
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
|
38
|
-
|
42
|
+
def is_index?
|
43
|
+
has_class?('os-index-container')
|
39
44
|
end
|
40
45
|
|
41
|
-
# Returns true if this page is a book
|
46
|
+
# Returns true if this page is a book reference
|
42
47
|
#
|
43
48
|
# @return [Boolean]
|
44
49
|
#
|
45
|
-
def
|
46
|
-
has_class?('os-
|
50
|
+
def is_reference?
|
51
|
+
has_class?('os-reference-container')
|
47
52
|
end
|
48
53
|
|
49
54
|
end
|