openstax_kitchen 1.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +37 -17
  3. data/.github/config.yml +14 -0
  4. data/.github/workflows/tests.yml +5 -15
  5. data/.gitignore +2 -2
  6. data/.inch.yml +6 -0
  7. data/.rubocop.yml +65 -0
  8. data/CHANGELOG.md +85 -2
  9. data/Gemfile +5 -3
  10. data/Gemfile.lock +66 -18
  11. data/README.md +69 -15
  12. data/Rakefile +5 -3
  13. data/bin/console +4 -3
  14. data/docker/Dockerfile +36 -0
  15. data/docker/Dockerfile.ci +10 -0
  16. data/docker/bash +5 -1
  17. data/docker/build +10 -0
  18. data/docker/ci +15 -0
  19. data/docker/run +9 -0
  20. data/docker/tag_and_push_latest +17 -0
  21. data/lefthook.yml +6 -0
  22. data/lib/kitchen/ancestor.rb +38 -1
  23. data/lib/kitchen/book_document.rb +20 -2
  24. data/lib/kitchen/book_element.rb +40 -5
  25. data/lib/kitchen/book_element_enumerator.rb +4 -0
  26. data/lib/kitchen/book_recipe.rb +15 -1
  27. data/lib/kitchen/chapter_element.rb +43 -6
  28. data/lib/kitchen/chapter_element_enumerator.rb +9 -1
  29. data/lib/kitchen/clipboard.rb +35 -4
  30. data/lib/kitchen/composite_chapter_element.rb +21 -6
  31. data/lib/kitchen/composite_page_element.rb +35 -7
  32. data/lib/kitchen/composite_page_element_enumerator.rb +9 -1
  33. data/lib/kitchen/config.rb +20 -6
  34. data/lib/kitchen/counter.rb +9 -2
  35. data/lib/kitchen/debug/print_recipe_error.rb +53 -35
  36. data/lib/kitchen/directions/.rubocop.yml +22 -0
  37. data/lib/kitchen/directions/bake_appendix.rb +4 -4
  38. data/lib/kitchen/directions/bake_chapter_glossary/main.rb +18 -0
  39. data/lib/kitchen/directions/bake_chapter_glossary/v1.rb +30 -0
  40. data/lib/kitchen/directions/bake_chapter_introductions.rb +7 -7
  41. data/lib/kitchen/directions/bake_chapter_key_concepts/main.rb +16 -0
  42. data/lib/kitchen/directions/bake_chapter_key_concepts/v1.rb +35 -0
  43. data/lib/kitchen/directions/bake_chapter_key_equations.rb +30 -20
  44. data/lib/kitchen/directions/bake_chapter_section_exercises/main.rb +11 -0
  45. data/lib/kitchen/directions/bake_chapter_section_exercises/v1.rb +28 -0
  46. data/lib/kitchen/directions/bake_chapter_summary.rb +45 -36
  47. data/lib/kitchen/directions/bake_chapter_title/main.rb +11 -0
  48. data/lib/kitchen/directions/bake_chapter_title/v1.rb +24 -0
  49. data/lib/kitchen/directions/bake_checkpoint.rb +44 -0
  50. data/lib/kitchen/directions/bake_composite_chapters.rb +14 -0
  51. data/lib/kitchen/directions/bake_composite_pages.rb +2 -2
  52. data/lib/kitchen/directions/bake_equations.rb +37 -0
  53. data/lib/kitchen/directions/bake_example.rb +39 -11
  54. data/lib/kitchen/directions/bake_figure.rb +8 -5
  55. data/lib/kitchen/directions/bake_first_elements.rb +16 -0
  56. data/lib/kitchen/directions/bake_footnotes/main.rb +2 -2
  57. data/lib/kitchen/directions/bake_footnotes/v1.rb +6 -5
  58. data/lib/kitchen/directions/bake_free_response/free_response.xhtml.erb +10 -0
  59. data/lib/kitchen/directions/bake_free_response/main.rb +11 -0
  60. data/lib/kitchen/directions/bake_free_response/v1.rb +29 -0
  61. data/lib/kitchen/directions/bake_further_research.rb +59 -0
  62. data/lib/kitchen/directions/bake_index/main.rb +2 -2
  63. data/lib/kitchen/directions/bake_index/v1.rb +46 -18
  64. data/lib/kitchen/directions/bake_link_placeholders.rb +24 -0
  65. data/lib/kitchen/directions/bake_math_in_paragraph.rb +5 -3
  66. data/lib/kitchen/directions/bake_non_introduction_pages.rb +26 -0
  67. data/lib/kitchen/directions/bake_notes/bake_autotitled_notes.rb +29 -0
  68. data/lib/kitchen/directions/bake_notes/bake_note_subtitle.rb +22 -0
  69. data/lib/kitchen/directions/bake_notes/bake_numbered_notes.rb +51 -0
  70. data/lib/kitchen/directions/bake_notes/bake_unclassified_notes.rb +30 -0
  71. data/lib/kitchen/directions/bake_numbered_exercise/main.rb +15 -0
  72. data/lib/kitchen/directions/bake_numbered_exercise/v1.rb +47 -0
  73. data/lib/kitchen/directions/bake_numbered_table/main.rb +4 -4
  74. data/lib/kitchen/directions/bake_numbered_table/v1.rb +37 -18
  75. data/lib/kitchen/directions/bake_page_abstracts.rb +30 -0
  76. data/lib/kitchen/directions/bake_preface/main.rb +11 -0
  77. data/lib/kitchen/directions/bake_preface/v1.rb +18 -0
  78. data/lib/kitchen/directions/bake_references/main.rb +16 -0
  79. data/lib/kitchen/directions/bake_references/v1.rb +48 -0
  80. data/lib/kitchen/directions/bake_stepwise.rb +8 -12
  81. data/lib/kitchen/directions/bake_suggested_reading.rb +31 -0
  82. data/lib/kitchen/directions/bake_theorem/main.rb +11 -0
  83. data/lib/kitchen/directions/bake_theorem/v1.rb +28 -0
  84. data/lib/kitchen/directions/bake_toc.rb +49 -22
  85. data/lib/kitchen/directions/bake_unit_title/main.rb +11 -0
  86. data/lib/kitchen/directions/bake_unit_title/v1.rb +23 -0
  87. data/lib/kitchen/directions/bake_unnumbered_tables.rb +7 -5
  88. data/lib/kitchen/directions/book_answer_key_container/eob_solutions_container.xhtml.erb +9 -0
  89. data/lib/kitchen/directions/book_answer_key_container/main.rb +11 -0
  90. data/lib/kitchen/directions/book_answer_key_container/v1.rb +13 -0
  91. data/lib/kitchen/directions/chapter_review_container/chapter_review.xhtml.erb +9 -0
  92. data/lib/kitchen/directions/chapter_review_container/main.rb +11 -0
  93. data/lib/kitchen/directions/chapter_review_container/v1.rb +13 -0
  94. data/lib/kitchen/directions/eoc_section_title_link_snippet.rb +20 -0
  95. data/lib/kitchen/directions/move_exercises_to_eoc/main.rb +27 -0
  96. data/lib/kitchen/directions/move_exercises_to_eoc/v1.rb +36 -0
  97. data/lib/kitchen/directions/move_exercises_to_eoc/v2.rb +49 -0
  98. data/lib/kitchen/directions/move_solutions_to_answer_key/main.rb +14 -0
  99. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/american_government.rb +19 -0
  100. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/calculus.rb +41 -0
  101. data/lib/kitchen/directions/move_solutions_to_answer_key/strategies/uphysics.rb +63 -0
  102. data/lib/kitchen/directions/move_solutions_to_answer_key/v1.rb +34 -0
  103. data/lib/kitchen/directions/move_title_text_into_span.rb +2 -2
  104. data/lib/kitchen/document.rb +83 -13
  105. data/lib/kitchen/element.rb +20 -3
  106. data/lib/kitchen/element_base.rb +373 -63
  107. data/lib/kitchen/element_enumerator.rb +8 -0
  108. data/lib/kitchen/element_enumerator_base.rb +297 -28
  109. data/lib/kitchen/element_enumerator_factory.rb +64 -53
  110. data/lib/kitchen/element_factory.rb +27 -12
  111. data/lib/kitchen/errors.rb +5 -0
  112. data/lib/kitchen/example_element.rb +21 -6
  113. data/lib/kitchen/example_element_enumerator.rb +9 -1
  114. data/lib/kitchen/exercise_element.rb +42 -0
  115. data/lib/kitchen/exercise_element_enumerator.rb +21 -0
  116. data/lib/kitchen/figure_element.rb +36 -5
  117. data/lib/kitchen/figure_element_enumerator.rb +9 -1
  118. data/lib/kitchen/metadata_element.rb +34 -0
  119. data/lib/kitchen/metadata_element_enumerator.rb +21 -0
  120. data/lib/kitchen/mixins/block_error_if.rb +24 -4
  121. data/lib/kitchen/note_element.rb +48 -20
  122. data/lib/kitchen/note_element_enumerator.rb +9 -1
  123. data/lib/kitchen/oven.rb +66 -15
  124. data/lib/kitchen/page_element.rb +84 -14
  125. data/lib/kitchen/page_element_enumerator.rb +9 -1
  126. data/lib/kitchen/pantry.rb +28 -1
  127. data/lib/kitchen/patches/nokogiri.rb +19 -2
  128. data/lib/kitchen/patches/renderable.rb +9 -3
  129. data/lib/kitchen/patches/string.rb +8 -0
  130. data/lib/kitchen/recipe.rb +69 -32
  131. data/lib/kitchen/reference_element.rb +27 -0
  132. data/lib/kitchen/references_element_enumerator.rb +20 -0
  133. data/lib/kitchen/search_history.rb +43 -4
  134. data/lib/kitchen/search_query.rb +106 -0
  135. data/lib/kitchen/selector.rb +24 -0
  136. data/lib/kitchen/selectors/base.rb +65 -0
  137. data/lib/kitchen/selectors/standard_1.rb +21 -0
  138. data/lib/kitchen/table_element.rb +55 -7
  139. data/lib/kitchen/table_element_enumerator.rb +9 -1
  140. data/lib/kitchen/templates/eob_section_title_template.xhtml.erb +10 -0
  141. data/lib/kitchen/templates/eoc_section_title_template.xhtml.erb +10 -0
  142. data/lib/kitchen/term_element.rb +15 -4
  143. data/lib/kitchen/term_element_enumerator.rb +9 -1
  144. data/lib/kitchen/transliterations.rb +7 -5
  145. data/lib/kitchen/type_casting_element_enumerator.rb +17 -1
  146. data/lib/kitchen/unit_element.rb +45 -0
  147. data/lib/kitchen/unit_element_enumerator.rb +20 -0
  148. data/lib/kitchen/utils.rb +10 -13
  149. data/lib/kitchen/version.rb +5 -1
  150. data/lib/locales/en.yml +18 -7
  151. data/lib/locales/pl.yml +24 -0
  152. data/lib/openstax_kitchen.rb +59 -0
  153. data/openstax_kitchen.gemspec +26 -20
  154. data/tutorials/00/solution1.rb +9 -0
  155. data/tutorials/00/solution2.rb +8 -0
  156. data/tutorials/01/solution1.rb +18 -0
  157. data/tutorials/01/solution2.rb +26 -0
  158. data/tutorials/02/solution1.rb +31 -0
  159. data/tutorials/03/{solution_1.rb → solution1.rb} +6 -4
  160. data/tutorials/03/solution2.rb +18 -0
  161. data/tutorials/04/{solution_1.rb → solution1.rb} +4 -2
  162. data/tutorials/04/{solution_2.rb → solution2.rb} +6 -4
  163. data/tutorials/05/solution1.rb +11 -0
  164. data/tutorials/check_it +16 -15
  165. data/tutorials/setup_my_recipes +7 -6
  166. metadata +148 -27
  167. data/Dockerfile +0 -19
  168. data/bin/normalize +0 -79
  169. data/books/chemistry2e/bake.rb +0 -133
  170. data/docker-compose.yml +0 -12
  171. data/docker/entrypoint +0 -9
  172. data/lib/kitchen.rb +0 -57
  173. data/lib/kitchen/directions/bake_chapter_glossary.rb +0 -34
  174. data/lib/kitchen/directions/bake_exercises.rb +0 -164
  175. data/lib/kitchen/directions/bake_notes.rb +0 -58
  176. data/tutorials/00/solution_1.rb +0 -7
  177. data/tutorials/00/solution_2.rb +0 -6
  178. data/tutorials/01/solution_1.rb +0 -16
  179. data/tutorials/01/solution_2.rb +0 -24
  180. data/tutorials/02/solution_1.rb +0 -29
  181. data/tutorials/03/solution_2.rb +0 -15
  182. data/tutorials/05/solution_1.rb +0 -9
@@ -1,9 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
4
+ # An enumerator for table elements
5
+ #
2
6
  class TableElementEnumerator < ElementEnumeratorBase
3
7
 
8
+ # Returns a factory for this enumerator
9
+ #
10
+ # @return [ElementEnumeratorFactory]
11
+ #
4
12
  def self.factory
5
13
  ElementEnumeratorFactory.new(
6
- default_css_or_xpath: "table", # TODO get from config?
14
+ default_css_or_xpath: Selector.named(:table),
7
15
  sub_element_class: TableElement,
8
16
  enumerator_class: self
9
17
  )
@@ -0,0 +1,10 @@
1
+ <div class="os-eob os-<%=@klass%>-container" data-type="composite-page" data-uuid-key="<%=@uuid_prefix%><%=@klass%>">
2
+ <h1 data-type="document-title">
3
+ <span class="os-text"><%= @title %></span>
4
+ </h1>
5
+ <div data-type="metadata" style="display: none;">
6
+ <h1 data-type="document-title" itemprop="name"><%= @title %></h1>
7
+ <%= @metadata.paste %>
8
+ </div>
9
+ <%= @content %>
10
+ </div>
@@ -0,0 +1,10 @@
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>
@@ -1,15 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
4
+ # An element for a term
5
+ #
2
6
  class TermElement < ElementBase
3
7
 
8
+ # Creates a new +TermElement+
9
+ #
10
+ # @param node [Nokogiri::XML::Node] the node this element wraps
11
+ # @param document [Document] this element's document
12
+ #
4
13
  def initialize(node:, document: nil)
5
14
  super(node: node,
6
15
  document: document,
7
- enumerator_class: TermElementEnumerator,
8
- short_type: :term)
16
+ enumerator_class: TermElementEnumerator)
9
17
  end
10
18
 
11
- def self.is_the_element_class_for?(node)
12
- node['data-type'] == "term"
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :term
13
24
  end
14
25
 
15
26
  end
@@ -1,9 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
4
+ # An enumerator for term elements
5
+ #
2
6
  class TermElementEnumerator < ElementEnumeratorBase
3
7
 
8
+ # Returns a factory for this enumerator
9
+ #
10
+ # @return [ElementEnumeratorFactory]
11
+ #
4
12
  def self.factory
5
13
  ElementEnumeratorFactory.new(
6
- default_css_or_xpath: "span[data-type='term']", # TODO get from config?
14
+ default_css_or_xpath: Selector.named(:term),
7
15
  sub_element_class: TermElement,
8
16
  enumerator_class: self
9
17
  )
@@ -1,19 +1,21 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
2
4
  # These are added to every translation locale, including the `test` locale
3
5
  # set by `stub_locales`. When we sort strings with accent marks, we use
4
6
  # `ActiveSupport::Inflector.transliterate` to ensure that the sorting is
5
7
  # sensible. This method does not know about Greek characters by default so
6
8
  # we teach it about them by adding the rules below to the i18n configuration.
7
-
9
+ #
8
10
  TRANSLITERATIONS = {
9
11
  i18n: {
10
12
  transliterate: {
11
13
  rule: {
12
- σ: "σ",
13
- Δ: "Δ",
14
- π: "π",
14
+ σ: 'σ',
15
+ Δ: 'Δ',
16
+ π: 'π'
15
17
  }
16
18
  }
17
19
  }
18
- }
20
+ }.freeze
19
21
  end
@@ -1,6 +1,15 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
4
+ # An enumerator that detects the element type as it iterates and returns specific,
5
+ # different element classes based on that type.
6
+ #
2
7
  class TypeCastingElementEnumerator < ElementEnumeratorBase
3
8
 
9
+ # Returns a factory for this enumerator
10
+ #
11
+ # @return [ElementEnumeratorFactory]
12
+ #
4
13
  def self.factory
5
14
  ElementEnumeratorFactory.new(
6
15
  enumerator_class: self,
@@ -8,12 +17,19 @@ module Kitchen
8
17
  )
9
18
  end
10
19
 
20
+ # Returns a new enumerator that returns only the specified element classes within the
21
+ # scope of this enumerator.
22
+ #
23
+ # @param element_classes [Array<ElementBase>] the element classes to limit iteration to
24
+ # @return [TypeCastingElementEnumerator]
25
+ #
11
26
  def only(*element_classes)
12
27
  element_classes.flatten!
13
28
 
14
29
  TypeCastingElementEnumerator.new do |block|
15
- self.each do |element|
30
+ each do |element|
16
31
  next unless element_classes.include?(element.class)
32
+
17
33
  block.yield(element)
18
34
  end
19
35
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ # An element for a unit
5
+ #
6
+ class UnitElement < ElementBase
7
+
8
+ # Creates a new +UnitElement+
9
+ #
10
+ # @param node [Nokogiri::XML::Node] the node this element wraps
11
+ # @param document [Document] this element's document
12
+ #
13
+ def initialize(node:, document: nil)
14
+ super(node: node,
15
+ document: document,
16
+ enumerator_class: UnitElementEnumerator)
17
+ end
18
+
19
+ # Returns the short type
20
+ # @return [Symbol]
21
+ #
22
+ def self.short_type
23
+ :unit
24
+ end
25
+
26
+ # Get the title in the immediate children, not the one in the metadata. Could use
27
+ # CSS of ":not([data-type='metadata']) >
28
+ # [data-type='document-title'], [data-type='document-title']"
29
+ # but xpath is shorter
30
+ # @return [Element]
31
+ #
32
+ def title
33
+ first!("./*[@data-type = 'document-title']")
34
+ end
35
+
36
+ # Returns the title's text regardless of whether the title has been baked
37
+ #
38
+ # @return [String]
39
+ #
40
+ def title_text
41
+ title.children.one? ? title.text : title.first('.os-text').text
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kitchen
4
+ # An enumerator for unit elements
5
+ #
6
+ class UnitElementEnumerator < 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(:unit),
15
+ sub_element_class: UnitElement,
16
+ enumerator_class: self
17
+ )
18
+ end
19
+ end
20
+ end
data/lib/kitchen/utils.rb CHANGED
@@ -1,19 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Kitchen
4
+ # Utility methods
5
+ #
2
6
  module Utils
3
-
7
+ # A standard way to convert a search path to an element type
8
+ #
9
+ # @param search_path [String, Array<String>] selectors
10
+ # @return [String]
11
+ #
4
12
  def self.search_path_to_type(search_path)
5
- [search_path].flatten.join(",")
13
+ [search_path].flatten.join(',')
6
14
  end
7
-
8
- def self.normalized_xhtml_string(xml_thing_with_to_s)
9
- doc = Nokogiri::XML(xml_thing_with_to_s.to_s) do |config|
10
- config.noblanks
11
- end
12
-
13
- doc.alphabetize_attributes!
14
-
15
- doc.to_xhtml(indent: 2)
16
- end
17
-
18
15
  end
19
16
  end
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A library for modifying the structure of OpenStax book XML.
4
+ #
1
5
  module Kitchen
2
- VERSION = "1.0.0"
6
+ VERSION = '4.0.0'
3
7
  end
data/lib/locales/en.yml CHANGED
@@ -2,20 +2,31 @@ en:
2
2
  figure: Figure
3
3
  table_label: Table
4
4
  appendix: Appendix
5
+ theorem: Theorem
6
+ solution: Solution
7
+ chapter_outline: Chapter Outline
8
+ toc_title: Contents
5
9
  example_label: Example
6
10
  exercise_label: Exercise
11
+ equation: Equation
12
+ chapter: Chapter
13
+ unit: Unit
14
+ checkpoint: Checkpoint
15
+ chapter_review: Chapter Review
16
+ learning_objectives: Learning Objectives
7
17
  stepwise_step_label: Step
18
+ references: References
19
+ eoc_chapter_review: Chapter Review
8
20
  eoc_key_terms_title: Key Terms
9
21
  eoc_summary_title: Summary
10
22
  eoc_exercises_title: Exercises
23
+ eoc_composite_metadata_title: Chapter Review
11
24
  eoc_answer_key_title: Answer Key
25
+ eoc_key_concepts: Key Concepts
12
26
  eoc_key_equations: Key Equations
27
+ eoc_suggested_reading: Suggestions for Further Study
28
+ eoc_further_research_title: Further Research
13
29
  eob_index_title: Index
14
30
  eob_index_symbols_group: Symbols
15
- notes:
16
- link-to-learning: Link to Learning
17
- sciences-interconnect: How Sciences Interconnect
18
- chemistry:
19
- link-to-learning: Link to Learning
20
- everyday-life: Chemistry in Everyday Life
21
- chemist-portrait: Portrait of a Chemist
31
+ review_exercises: Review Exercises
32
+ section_exercises: ! 'Section %{number} Exercises'
@@ -0,0 +1,24 @@
1
+ pl:
2
+ figure: Rysunek
3
+ table_label: Tabela
4
+ appendix: Dodatek
5
+ theorem: Twierdzenie
6
+ solution: Rozwiązanie
7
+ chapter_outline: Treść rozdziału
8
+ toc_title: Spis treści
9
+ example_label: Przykład
10
+ exercise_label: Ćwiczenie
11
+ equation: Równanie
12
+ chapter: Rozdział
13
+ unit: Część
14
+ chapter_review: Podsumowanie rozdziału
15
+ learning_objectives: Cel dydaktyczny
16
+ stepwise_step_label: Krok
17
+ eoc_chapter_review: Podsumowanie rozdziału
18
+ eoc_key_terms_title: Kluczowe pojęcia
19
+ eoc_summary_title: Podsumowanie
20
+ eoc_answer_key_title: Rozwiązania zadań
21
+ eoc_key_equations: Najważniejsze wzory
22
+ eob_index_title: Skorowidz rzeczowy
23
+ eob_index_symbols_group: Symbole
24
+
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kitchen/version'
4
+
5
+ require 'nokogiri'
6
+ require 'active_support/all'
7
+
8
+ module Kitchen
9
+ # Contains snippets of recipes that accomplish a certain medium-sized task
10
+ module Directions; end
11
+ end
12
+
13
+ def file_glob(relative_folder_and_extension)
14
+ Dir[File.expand_path("#{__dir__}/#{relative_folder_and_extension}")]
15
+ end
16
+
17
+ def require_all(relative_folder, file_matcher='**/*.rb')
18
+ file_glob(relative_folder + "/#{file_matcher}").each { |f| require f }
19
+ end
20
+
21
+ require_all('kitchen/patches')
22
+ require_all('kitchen/mixins')
23
+
24
+ require 'kitchen/selectors/base'
25
+ require_all('kitchen/selectors')
26
+
27
+ require 'kitchen/utils'
28
+ require 'kitchen/transliterations'
29
+ require 'kitchen/errors'
30
+ require 'kitchen/ancestor'
31
+ require 'kitchen/search_query'
32
+ require 'kitchen/search_history'
33
+ require 'kitchen/config'
34
+ require 'kitchen/document'
35
+ require 'kitchen/book_document'
36
+ require 'kitchen/debug/print_recipe_error'
37
+ require 'kitchen/recipe'
38
+ require 'kitchen/book_recipe'
39
+ require 'kitchen/oven'
40
+ require 'kitchen/clipboard'
41
+ require 'kitchen/pantry'
42
+ require 'kitchen/counter'
43
+ require 'kitchen/selector'
44
+
45
+ require 'kitchen/element_enumerator_base'
46
+ require 'kitchen/element_enumerator_factory'
47
+ require_all('kitchen', '*enumerator.rb')
48
+
49
+ require 'kitchen/element_base'
50
+ require_all('kitchen', '*element.rb')
51
+ require 'kitchen/element_factory'
52
+
53
+ require_all('kitchen/directions')
54
+
55
+ I18n.backend.load_translations(file_glob('/locales/*.yml'))
56
+
57
+ I18n.available_locales.each do |available_locale|
58
+ I18n.backend.store_translations(available_locale, Kitchen::TRANSLITERATIONS)
59
+ end
@@ -1,39 +1,45 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'lib/kitchen/version'
2
4
 
3
5
  Gem::Specification.new do |spec|
4
- spec.name = "openstax_kitchen"
6
+ spec.name = 'openstax_kitchen'
5
7
  spec.version = Kitchen::VERSION
6
- spec.authors = ["JP Slavinsky"]
7
- spec.email = ["jpslav@gmail.com"]
8
+ spec.authors = ['JP Slavinsky']
9
+ spec.email = ['jpslav@gmail.com']
8
10
 
9
- spec.summary = %q{OpenStax content baking library}
10
- spec.description = %q{OpenStax content baking library}
11
- spec.homepage = "https://github.com/openstax/kitchen"
12
- spec.license = "MIT"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
11
+ spec.summary = 'OpenStax content baking library'
12
+ spec.description = 'OpenStax content baking library'
13
+ spec.homepage = 'https://github.com/openstax/kitchen'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
14
16
 
15
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
16
18
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/openstax/kitchen"
19
- spec.metadata["changelog_uri"] = "https://github.com/openstax/kitchen/CHANGELOG.md"
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/openstax/kitchen'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/openstax/kitchen/CHANGELOG.md'
20
22
 
21
23
  # Specify which files should be added to the gem when it is released.
22
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
25
27
  end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
28
+ spec.bindir = 'exe'
29
+ spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
30
+ spec.require_paths = ['lib']
29
31
 
30
- spec.add_dependency 'nokogiri'
31
- spec.add_dependency 'rainbow'
32
32
  spec.add_dependency 'activesupport'
33
33
  spec.add_dependency 'i18n'
34
+ spec.add_dependency 'nokogiri'
35
+ spec.add_dependency 'rainbow'
34
36
 
35
37
  spec.add_development_dependency 'byebug'
36
- spec.add_development_dependency 'yard'
38
+ spec.add_development_dependency 'inch'
37
39
  spec.add_development_dependency 'nokogiri-diff'
38
40
  spec.add_development_dependency 'rainbow'
41
+ spec.add_development_dependency 'rubocop'
42
+ spec.add_development_dependency 'rubocop-rake'
43
+ spec.add_development_dependency 'rubocop-rspec'
44
+ spec.add_development_dependency 'yard'
39
45
  end