openstax_kitchen 6.0.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/changelog.yml +0 -3
  3. data/CHANGELOG.md +38 -4
  4. data/Gemfile.lock +2 -2
  5. data/docker/rubocop +6 -4
  6. data/lib/kitchen/chapter_element.rb +0 -8
  7. data/lib/kitchen/composite_page_element.rb +20 -3
  8. data/lib/kitchen/directions/.rubocop.yml +3 -0
  9. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -16
  10. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +9 -13
  11. data/lib/kitchen/directions/bake_chapter_key_equations.rb +10 -17
  12. data/lib/kitchen/directions/bake_chapter_references/main.rb +1 -2
  13. data/lib/kitchen/directions/bake_chapter_references/v1.rb +33 -21
  14. data/lib/kitchen/directions/bake_chapter_solutions/v1.rb +8 -12
  15. data/lib/kitchen/directions/bake_chapter_summary.rb +10 -32
  16. data/lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb +11 -0
  17. data/lib/kitchen/directions/bake_example.rb +7 -1
  18. data/lib/kitchen/directions/bake_further_research.rb +13 -39
  19. data/lib/kitchen/directions/bake_inline_lists.rb +22 -0
  20. data/lib/kitchen/directions/bake_references/main.rb +7 -0
  21. data/lib/kitchen/directions/bake_references/v2.rb +35 -0
  22. data/lib/kitchen/directions/bake_toc.rb +3 -1
  23. data/lib/kitchen/directions/eoc_composite_page_container/main.rb +27 -0
  24. data/lib/kitchen/directions/eoc_composite_page_container/v1.rb +19 -0
  25. data/lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb +37 -0
  26. data/lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb +27 -0
  27. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +10 -27
  28. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +11 -18
  29. data/lib/kitchen/directions/move_exercises_to_eoc/v3.rb +14 -38
  30. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +5 -5
  31. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/default.rb +3 -3
  32. data/lib/kitchen/element_base.rb +2 -2
  33. data/lib/kitchen/example_element.rb +1 -1
  34. data/lib/kitchen/i18n_string.rb +16 -0
  35. data/lib/kitchen/patches/array.rb +15 -0
  36. data/lib/kitchen/templates/eoc_section_template.xhtml.erb +11 -0
  37. data/lib/kitchen/templates/eoc_section_template_old.xhtml.erb +11 -0
  38. data/lib/kitchen/version.rb +1 -1
  39. data/lib/locales/en.yml +7 -5
  40. data/lib/locales/es.yml +7 -5
  41. data/lib/locales/pl.yml +6 -3
  42. data/lib/openstax_kitchen.rb +1 -0
  43. metadata +13 -3
  44. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +0 -10
@@ -4,11 +4,11 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
4
4
  module Strategies
5
5
  class Calculus
6
6
  def bake(chapter:, append_to:)
7
- checkpoint_solutions = chapter.search('.checkpoint [data-type="solution"]').cut
7
+ checkpoint_solutions = chapter.search('div.checkpoint div[data-type="solution"]').cut
8
8
  append_solution_area(I18n.t(:checkpoint), checkpoint_solutions, append_to)
9
9
 
10
- chapter.search('.section-exercises').each do |section|
11
- section_solutions = section.search('[data-type="solution"]').cut
10
+ chapter.search('section.section-exercises').each do |section|
11
+ section_solutions = section.search('div[data-type="solution"]').cut
12
12
  section_title = I18n.t(
13
13
  :section_exercises,
14
14
  number: "#{chapter.count_in(:book)}.#{section.count_in(:chapter)}"
@@ -16,8 +16,8 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
16
16
  append_solution_area(section_title, section_solutions, append_to)
17
17
  end
18
18
 
19
- chapter.search('.review-exercises').each do |section|
20
- section_solutions = section.search('[data-type="solution"]').cut
19
+ chapter.search('section.review-exercises').each do |section|
20
+ section_solutions = section.search('div[data-type="solution"]').cut
21
21
  append_solution_area(I18n.t(:review_exercises), section_solutions, append_to)
22
22
  end
23
23
  end
@@ -10,8 +10,8 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
10
10
  protected
11
11
 
12
12
  def bake_section(chapter:, append_to:)
13
- @classes.each do |klass|
14
- chapter.search(".#{klass} [data-type='solution']").each do |solution|
13
+ @selectors.each do |selector|
14
+ chapter.search("#{selector} div[data-type='solution']").each do |solution|
15
15
  append_to.add_child(solution.cut.to_s)
16
16
  end
17
17
  end
@@ -20,7 +20,7 @@ module Kitchen::Directions::MoveSolutionsToAnswerKey
20
20
  # This method helps to obtain more strategy-specific params through
21
21
  # "strategy_options: {blah1: 1, blah2: 2}"
22
22
  def initialize(strategy_options)
23
- @classes = strategy_options[:classes] || (raise 'missing classes for strategy')
23
+ @selectors = strategy_options[:selectors] || (raise 'missing selectors for strategy')
24
24
  end
25
25
  end
26
26
  end
@@ -602,9 +602,9 @@ module Kitchen
602
602
  attributes.each do |k, v|
603
603
  new_node[k.to_s.gsub(/([^_])_([^_])/, '\1-\2').gsub('__', '_')] = v
604
604
  end
605
- new_node.children = children.to_s
605
+ new_node.children = children
606
606
  yield Element.new(node: new_node, document: document, short_type: nil) if block_given?
607
- end.to_s
607
+ end
608
608
 
609
609
  self
610
610
  end
@@ -28,7 +28,7 @@ module Kitchen
28
28
  # @return [ElementEnumerator]
29
29
  #
30
30
  def titles
31
- search("span[data-type='title']")
31
+ search("[data-type='title']")
32
32
  end
33
33
 
34
34
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ # Compare one string with another
5
+ #
6
+ # Returns 0 if first string equals second,
7
+ # 1 if first string is greater than the second
8
+ # and -1 if first string is less than the second.
9
+ #
10
+ class I18nString < String
11
+
12
+ def <=>(other)
13
+ I18n.sort_strings(self, other)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Monkey patches for +Array+
4
+ #
5
+ class Array
6
+
7
+ # Receives a string to add as prefix in each item and returns
8
+ # a new array with the concatenaded strings
9
+ #
10
+ # @return [Array<String>]
11
+ #
12
+ def prefix(string)
13
+ map { |item| "#{string}#{item}" }
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ <% main_title_tag = @in_composite_chapter ? 'h3' : 'h2' %>
2
+ <div class="os-eoc os-<%=@container_class_type%>-container" data-type="composite-page" data-uuid-key="<%= @uuid_key %>">
3
+ <<%= main_title_tag %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
4
+ <span class="os-text"><%= @title %></span>
5
+ </<%= main_title_tag %>>
6
+ <div data-type="metadata" style="display: none;">
7
+ <h1 data-type="document-title" itemprop="name"><%= @title %></h1>
8
+ <%= @metadata.paste %>
9
+ </div>
10
+ <%= @content %>
11
+ </div>
@@ -0,0 +1,11 @@
1
+ <% main_title_tag = @in_composite_chapter ? 'h3' : 'h2' %>
2
+ <div class="os-eoc os-<%=@klass%>-container" data-type="composite-page" data-uuid-key="<%=@uuid_prefix%><%=@klass%>">
3
+ <<%= main_title_tag %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
4
+ <span class="os-text"><%= @title %></span>
5
+ </<%= main_title_tag %>>
6
+ <div data-type="metadata" style="display: none;">
7
+ <h1 data-type="document-title" itemprop="name"><%= @title %></h1>
8
+ <%= @metadata.paste %>
9
+ </div>
10
+ <%= @content %>
11
+ </div>
@@ -3,5 +3,5 @@
3
3
  # A library for modifying the structure of OpenStax book XML.
4
4
  #
5
5
  module Kitchen
6
- VERSION = '6.0.0'
6
+ VERSION = '9.0.0'
7
7
  end
data/lib/locales/en.yml CHANGED
@@ -18,16 +18,18 @@ en:
18
18
  references: References
19
19
  answer_key_title: Answer Key
20
20
  eoc_chapter_review: Chapter Review
21
- eoc_key_terms_title: Key Terms
22
- eoc_summary_title: Summary
23
21
  eoc_exercises_title: Exercises
24
22
  eoc_composite_metadata_title: Chapter Review
25
23
  eoc_solutions_title: Solutions
26
- eoc_key_concepts: Key Concepts
27
- eoc_key_equations: Key Equations
28
24
  eoc_suggested_reading: Suggestions for Further Study
29
- eoc_further_research_title: Further Research
30
25
  eob_index_title: Index
31
26
  eob_index_symbols_group: Symbols
32
27
  review_exercises: Review Exercises
33
28
  section_exercises: ! 'Section %{number} Exercises'
29
+ eoc:
30
+ glossary: Key Terms
31
+ key-equations: Key Equations
32
+ summary: Summary
33
+ further-research: Further Research
34
+ key-concepts: Key Concepts
35
+ references: References
data/lib/locales/es.yml CHANGED
@@ -16,18 +16,20 @@ es:
16
16
  learning_objectives: Objetivos De Aprendizaje
17
17
  stepwise_step_label: Paso
18
18
  references: Referencias
19
- answer_key_title: Respuestas Clave
19
+ answer_key_title: Clave de Respuestas
20
20
  eoc_chapter_review: Revisión Del Capítulo
21
- eoc_key_terms_title: Términos Clave
22
- eoc_summary_title: Resumen
23
21
  eoc_exercises_title: Ejercicios
24
22
  eoc_composite_metadata_title: Revisión Del Capítulo
25
23
  eoc_solutions_title: Soluciones
26
24
  eoc_key_concepts: Conceptos Clave
27
- eoc_key_equations: Ecuaciones Clave
28
25
  eoc_suggested_reading: Sugerencias Para Estudios Adicionales
29
- eoc_further_research_title: Investigación Adicional
30
26
  eob_index_title: Índice
31
27
  eob_index_symbols_group: Símbolos
32
28
  review_exercises: Ejercicios De Repaso
33
29
  section_exercises: ! 'Sección %{number} Ejercicios'
30
+ eoc:
31
+ glossary: Términos Clave
32
+ key-equations: Ecuaciones Clave
33
+ summary: Resumen
34
+ further-research: Investigación Adicional
35
+ references: Referencias
data/lib/locales/pl.yml CHANGED
@@ -16,10 +16,13 @@ pl:
16
16
  stepwise_step_label: Krok
17
17
  answer_key_title: Rozwiązania zadań
18
18
  eoc_chapter_review: Podsumowanie rozdziału
19
- key_terms_title: Kluczowe pojęcia
20
19
  eoc_solutions_title: Rozwiązania
21
- eoc_summary_title: Podsumowanie
22
- eoc_key_equations: Najważniejsze wzory
23
20
  eob_index_title: Skorowidz rzeczowy
24
21
  eob_index_symbols_group: Symbole
22
+ references: Bibliografia
23
+ eoc:
24
+ glossary: Kluczowe pojęcia
25
+ key-equations: Najważniejsze wzory
26
+ summary: Podsumowanie
27
+ references: Bibliografia
25
28
 
@@ -41,6 +41,7 @@ require 'kitchen/pantry'
41
41
  require 'kitchen/counter'
42
42
  require 'kitchen/selector'
43
43
  require 'kitchen/id_tracker'
44
+ require 'kitchen/i18n_string'
44
45
 
45
46
  require 'kitchen/element_enumerator_base'
46
47
  require 'kitchen/element_enumerator_factory'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_kitchen
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-15 00:00:00.000000000 Z
11
+ date: 2021-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -263,6 +263,7 @@ files:
263
263
  - lib/kitchen/directions/bake_checkpoint.rb
264
264
  - lib/kitchen/directions/bake_composite_chapters.rb
265
265
  - lib/kitchen/directions/bake_composite_pages.rb
266
+ - lib/kitchen/directions/bake_eoc_section_content/remove_section_title.rb
266
267
  - lib/kitchen/directions/bake_equations.rb
267
268
  - lib/kitchen/directions/bake_example.rb
268
269
  - lib/kitchen/directions/bake_figure.rb
@@ -276,6 +277,7 @@ files:
276
277
  - lib/kitchen/directions/bake_index/main.rb
277
278
  - lib/kitchen/directions/bake_index/v1.rb
278
279
  - lib/kitchen/directions/bake_index/v1.xhtml.erb
280
+ - lib/kitchen/directions/bake_inline_lists.rb
279
281
  - lib/kitchen/directions/bake_link_placeholders.rb
280
282
  - lib/kitchen/directions/bake_math_in_paragraph.rb
281
283
  - lib/kitchen/directions/bake_non_introduction_pages.rb
@@ -297,6 +299,7 @@ files:
297
299
  - lib/kitchen/directions/bake_preface/v1.rb
298
300
  - lib/kitchen/directions/bake_references/main.rb
299
301
  - lib/kitchen/directions/bake_references/v1.rb
302
+ - lib/kitchen/directions/bake_references/v2.rb
300
303
  - lib/kitchen/directions/bake_stepwise.rb
301
304
  - lib/kitchen/directions/bake_suggested_reading.rb
302
305
  - lib/kitchen/directions/bake_theorem/main.rb
@@ -311,7 +314,11 @@ files:
311
314
  - lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb
312
315
  - lib/kitchen/directions/chapter_review_container/main.rb
313
316
  - lib/kitchen/directions/chapter_review_container/v1.rb
317
+ - lib/kitchen/directions/eoc_composite_page_container/main.rb
318
+ - lib/kitchen/directions/eoc_composite_page_container/v1.rb
314
319
  - lib/kitchen/directions/eoc_section_title_link_snippet.rb
320
+ - lib/kitchen/directions/move_custom_section_to_eoc_container/main.rb
321
+ - lib/kitchen/directions/move_custom_section_to_eoc_container/v1.rb
315
322
  - lib/kitchen/directions/move_exercises_to_eoc/main.rb
316
323
  - lib/kitchen/directions/move_exercises_to_eoc/v1.rb
317
324
  - lib/kitchen/directions/move_exercises_to_eoc/v2.rb
@@ -337,6 +344,7 @@ files:
337
344
  - lib/kitchen/exercise_element_enumerator.rb
338
345
  - lib/kitchen/figure_element.rb
339
346
  - lib/kitchen/figure_element_enumerator.rb
347
+ - lib/kitchen/i18n_string.rb
340
348
  - lib/kitchen/id_tracker.rb
341
349
  - lib/kitchen/metadata_element.rb
342
350
  - lib/kitchen/metadata_element_enumerator.rb
@@ -347,6 +355,7 @@ files:
347
355
  - lib/kitchen/page_element.rb
348
356
  - lib/kitchen/page_element_enumerator.rb
349
357
  - lib/kitchen/pantry.rb
358
+ - lib/kitchen/patches/array.rb
350
359
  - lib/kitchen/patches/i18n.rb
351
360
  - lib/kitchen/patches/integer.rb
352
361
  - lib/kitchen/patches/nokogiri.rb
@@ -364,7 +373,8 @@ files:
364
373
  - lib/kitchen/table_element.rb
365
374
  - lib/kitchen/table_element_enumerator.rb
366
375
  - lib/kitchen/templates/eob_section_title_template.xhtml.erb
367
- - lib/kitchen/templates/eoc_section_title_template.xhtml.erb
376
+ - lib/kitchen/templates/eoc_section_template.xhtml.erb
377
+ - lib/kitchen/templates/eoc_section_template_old.xhtml.erb
368
378
  - lib/kitchen/term_element.rb
369
379
  - lib/kitchen/term_element_enumerator.rb
370
380
  - lib/kitchen/type_casting_element_enumerator.rb
@@ -1,10 +0,0 @@
1
- <div class="os-eoc os-<%=@klass%>-container" data-type="composite-page" data-uuid-key="<%=@uuid_prefix%><%=@klass%>">
2
- <<%= @in_composite_chapter ? 'h3' : 'h2' %> data-type="<%= @in_composite_chapter ? 'title' : 'document-title' %>">
3
- <span class="os-text"><%= @title %></span>
4
- </<%= @in_composite_chapter ? 'h3' : 'h2' %>>
5
- <div data-type="metadata" style="display: none;">
6
- <h1 data-type="document-title" itemprop="name"><%= @in_composite_chapter ? I18n.t(:eoc_composite_metadata_title) : @title %></h1>
7
- <%= @metadata.paste %>
8
- </div>
9
- <%= @content %>
10
- </div>