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.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +64 -0
- data/Gemfile.lock +20 -14
- data/README.md +16 -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 +7 -2
- data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +12 -7
- data/lib/kitchen/directions/bake_chapter_key_equations.rb +26 -21
- 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_summary.rb +48 -42
- data/lib/kitchen/directions/bake_composite_chapters.rb +1 -1
- data/lib/kitchen/directions/bake_composite_pages.rb +1 -1
- data/lib/kitchen/directions/bake_equations.rb +14 -4
- data/lib/kitchen/directions/bake_example.rb +5 -1
- data/lib/kitchen/directions/bake_figure.rb +1 -1
- data/lib/kitchen/directions/bake_first_elements.rb +22 -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 +36 -26
- data/lib/kitchen/directions/bake_link_placeholders.rb +1 -1
- data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +4 -0
- data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +9 -21
- data/lib/kitchen/directions/bake_numbered_exercise/main.rb +6 -2
- data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +25 -12
- data/lib/kitchen/directions/bake_numbered_table/v1.rb +1 -8
- data/lib/kitchen/directions/bake_page_abstracts.rb +1 -1
- 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_suggested_reading.rb +5 -0
- data/lib/kitchen/directions/bake_toc.rb +4 -2
- data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/eob_solutions_container.xhtml.erb +0 -0
- data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/main.rb +1 -1
- data/lib/kitchen/directions/{bake_book_answer_key → book_answer_key_container}/v1.rb +2 -2
- data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/chapter_review.xhtml.erb +0 -0
- data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/main.rb +1 -1
- data/lib/kitchen/directions/{bake_chapter_review → chapter_review_container}/v1.rb +2 -2
- data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +1 -1
- data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
- data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v1.rb +8 -10
- data/lib/kitchen/directions/{bake_chapter_review_exercises → move_exercises_to_eoc}/v2.rb +8 -9
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/main.rb +1 -1
- data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/calculus.rb +1 -1
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/strategies/uphysics.rb +7 -5
- data/lib/kitchen/directions/{bake_chapter_answer_key → move_solutions_to_answer_key}/v1.rb +3 -1
- data/lib/kitchen/document.rb +20 -42
- data/lib/kitchen/element.rb +9 -3
- data/lib/kitchen/element_base.rb +93 -21
- data/lib/kitchen/element_enumerator_base.rb +33 -2
- 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 +7 -10
- data/lib/kitchen/exercise_element_enumerator.rb +1 -1
- data/lib/kitchen/figure_element.rb +8 -11
- data/lib/kitchen/figure_element_enumerator.rb +1 -1
- data/lib/kitchen/id_tracker.rb +68 -0
- data/lib/kitchen/metadata_element.rb +8 -2
- data/lib/kitchen/metadata_element_enumerator.rb +1 -1
- data/lib/kitchen/note_element.rb +8 -11
- data/lib/kitchen/note_element_enumerator.rb +1 -1
- data/lib/kitchen/oven.rb +5 -1
- data/lib/kitchen/page_element.rb +25 -9
- data/lib/kitchen/page_element_enumerator.rb +1 -1
- data/lib/kitchen/patches/i18n.rb +34 -0
- data/lib/kitchen/patches/nokogiri.rb +55 -0
- data/lib/kitchen/patches/nokogiri_profiling.rb +60 -0
- 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 +3 -0
- data/lib/locales/es.yml +32 -0
- data/lib/openstax_kitchen.rb +2 -5
- data/openstax_kitchen.gemspec +1 -0
- metadata +51 -23
- data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -39
- data/lib/kitchen/directions/bake_chapter_key_concepts/key_concepts.xhtml.erb +0 -16
- data/lib/kitchen/directions/bake_chapter_review_exercises/main.rb +0 -15
- data/lib/kitchen/directions/bake_chapter_review_exercises/review_exercises.xhtml.erb +0 -10
- data/lib/kitchen/directions/bake_exercises/main.rb +0 -12
- data/lib/kitchen/directions/bake_exercises/v1.rb +0 -169
- data/lib/kitchen/directions/bake_notes/bake_notes.rb +0 -48
- data/lib/kitchen/directions/bake_problem_first_elements.rb +0 -16
- data/lib/kitchen/transliterations.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8e1365bab888949c899b5cb36518be9456bd23d0369ddab9a42ac81f82cc024
|
4
|
+
data.tar.gz: cd86a88028f0946885add3866ffad6133f84ce48a779800cb5105cc8153736d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16b9afc1d63a6098aad2396e114975ea35d39890c9a4c27c88dfef7710d129ddf16e3f18d775042ae919d0dff5284d41b53f668621d5cd74f2e723a670fd33d9
|
7
|
+
data.tar.gz: 9b93c51846a460a3e71c6a6080f53be61f1fa93ab268f954ddf3b7d447a1f9602dd789d876bc41e2997f8f44e682453c413f2f28ea7754c4d7f1015d3ecde1a6
|
data/.gitignore
CHANGED
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 (
|
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.
|
14
|
+
activesupport (6.1.3.2)
|
14
15
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
-
i18n (>=
|
16
|
-
minitest (
|
17
|
-
tzinfo (~>
|
18
|
-
zeitwerk (~> 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.
|
27
|
+
concurrent-ruby (1.1.8)
|
25
28
|
diff-lcs (1.3)
|
26
29
|
docile (1.3.3)
|
27
|
-
i18n (1.8.
|
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.
|
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.
|
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
|
-
|
99
|
-
|
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.
|
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
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
|
@@ -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(:composite_page),
|
15
15
|
sub_element_class: CompositePageElement,
|
16
16
|
enumerator_class: self
|
17
17
|
)
|
data/lib/kitchen/config.rb
CHANGED
@@ -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
|