lcms-engine 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (374) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -1
  3. data/.dockerignore +25 -0
  4. data/.env.docker +1 -1
  5. data/.eslintignore +2 -1
  6. data/.eslintrc +23 -73
  7. data/.nvmrc +1 -1
  8. data/.overcommit.yml +8 -2
  9. data/.prettierrc +7 -0
  10. data/.rubocop.yml +12 -8
  11. data/.ruby-version +1 -1
  12. data/.stylelintignore +9 -0
  13. data/.stylelintrc +8 -0
  14. data/CHANGELOG.md +50 -1
  15. data/Dockerfile +3 -3
  16. data/Gemfile.lock +408 -322
  17. data/README.md +20 -17
  18. data/app/assets/config/lcms_engine_manifest.js +4 -2
  19. data/app/assets/javascripts/lcms/engine/admin/{application.js → lcms_engine_application.js} +1 -3
  20. data/app/assets/javascripts/lcms/engine/initializers/foundation.js +1 -1
  21. data/app/assets/javascripts/lcms/engine/{application.js → lcms_engine_application.js} +0 -0
  22. data/app/assets/stylesheets/lcms/engine/admin/collections.scss +2 -1
  23. data/app/assets/stylesheets/lcms/engine/admin/components.scss +60 -19
  24. data/app/assets/stylesheets/lcms/engine/admin/curriculums.scss +12 -10
  25. data/app/assets/stylesheets/lcms/engine/admin/lessons.scss +21 -15
  26. data/app/assets/stylesheets/lcms/engine/admin/materials.scss +25 -17
  27. data/app/assets/stylesheets/lcms/engine/admin/resources.scss +8 -7
  28. data/app/assets/stylesheets/lcms/engine/admin/standards.scss +4 -1
  29. data/app/assets/stylesheets/lcms/engine/admin/users.scss +1 -1
  30. data/app/assets/stylesheets/lcms/engine/base/_colors.scss +8 -10
  31. data/app/assets/stylesheets/lcms/engine/base/_ld-colors.scss +10 -10
  32. data/app/assets/stylesheets/lcms/engine/components/_assoc-picker.scss +4 -5
  33. data/app/assets/stylesheets/lcms/engine/components/lesson/_activity.scss +6 -2
  34. data/app/assets/stylesheets/lcms/engine/components/lesson/_callout.scss +19 -5
  35. data/app/assets/stylesheets/lcms/engine/components/lesson/_columns.scss +4 -3
  36. data/app/assets/stylesheets/lcms/engine/components/lesson/_curriculum-map.scss +16 -7
  37. data/app/assets/stylesheets/lcms/engine/components/lesson/_def.scss +2 -2
  38. data/app/assets/stylesheets/lcms/engine/components/lesson/_expand.scss +9 -9
  39. data/app/assets/stylesheets/lcms/engine/components/lesson/_foundational-divider.scss +0 -1
  40. data/app/assets/stylesheets/lcms/engine/components/lesson/_group.scss +3 -1
  41. data/app/assets/stylesheets/lcms/engine/components/lesson/_icons.scss +1 -1
  42. data/app/assets/stylesheets/lcms/engine/components/lesson/_image-wrap.scss +2 -2
  43. data/app/assets/stylesheets/lcms/engine/components/lesson/_inset.scss +7 -2
  44. data/app/assets/stylesheets/lcms/engine/components/lesson/_materials.scss +1 -1
  45. data/app/assets/stylesheets/lcms/engine/components/lesson/_multiple-choice.scss +4 -1
  46. data/app/assets/stylesheets/lcms/engine/components/lesson/_override.scss +28 -9
  47. data/app/assets/stylesheets/lcms/engine/components/lesson/_pd.scss +7 -7
  48. data/app/assets/stylesheets/lcms/engine/components/lesson/_pv.scss +5 -4
  49. data/app/assets/stylesheets/lcms/engine/components/lesson/_section.scss +10 -3
  50. data/app/assets/stylesheets/lcms/engine/components/lesson/_selection-control.scss +14 -8
  51. data/app/assets/stylesheets/lcms/engine/components/lesson/_sidebar.scss +25 -10
  52. data/app/assets/stylesheets/lcms/engine/components/lesson/_title.scss +3 -1
  53. data/app/assets/stylesheets/lcms/engine/components/lesson/_unit-map.scss +1 -1
  54. data/app/assets/stylesheets/lcms/engine/components/material/_material.scss +3 -3
  55. data/app/assets/stylesheets/lcms/engine/components/material/_overlay.scss +12 -4
  56. data/app/assets/stylesheets/lcms/engine/components/material/_preview.scss +1 -1
  57. data/app/assets/stylesheets/lcms/engine/components/support/_survey.scss +3 -1
  58. data/app/assets/stylesheets/lcms/engine/layout/_footer.scss +29 -11
  59. data/app/assets/stylesheets/lcms/engine/layout/_header.scss +5 -5
  60. data/app/assets/stylesheets/lcms/engine/layout/_navigation.scss +4 -6
  61. data/app/assets/stylesheets/lcms/engine/layout/_page.scss +2 -2
  62. data/app/assets/stylesheets/lcms/engine/{admin.scss → lcms_engine_admin.scss} +26 -15
  63. data/app/assets/stylesheets/lcms/engine/lcms_engine_application.scss +9 -0
  64. data/app/assets/stylesheets/lcms/engine/pdf.scss +5 -26
  65. data/app/assets/stylesheets/lcms/engine/pdf_plain.scss +5 -23
  66. data/app/assets/stylesheets/lcms/engine/print/_base.scss +41 -12
  67. data/app/assets/stylesheets/lcms/engine/print/_cover.scss +12 -12
  68. data/app/assets/stylesheets/lcms/engine/print/_footer.scss +8 -3
  69. data/app/assets/stylesheets/lcms/engine/print/_gdoc-base.scss +10 -37
  70. data/app/assets/stylesheets/lcms/engine/print/_helpers.scss +5 -2
  71. data/app/assets/stylesheets/lcms/engine/print/_lesson-base.scss +2 -14
  72. data/app/assets/stylesheets/lcms/engine/print/_material-base.scss +1 -3
  73. data/app/assets/stylesheets/lcms/engine/print/_print.scss +15 -8
  74. data/app/assets/stylesheets/lcms/engine/print/_toc.scss +24 -9
  75. data/app/assets/stylesheets/lcms/engine/print/gdoc/_base-typography.scss +24 -6
  76. data/app/assets/stylesheets/lcms/engine/print/gdoc/_base.scss +10 -3
  77. data/app/assets/stylesheets/lcms/engine/print/gdoc/_colors.scss +3 -3
  78. data/app/assets/stylesheets/lcms/engine/print/gdoc/_header.scss +2 -2
  79. data/app/assets/stylesheets/lcms/engine/print/gdoc/_helpers.scss +1 -0
  80. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_activity.scss +1 -1
  81. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_agenda.scss +8 -2
  82. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_callout.scss +16 -6
  83. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_def.scss +1 -1
  84. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_dialogue.scss +3 -1
  85. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_expand.scss +5 -2
  86. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image-wrap.scss +5 -3
  87. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_image.scss +1 -1
  88. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_optbreak.scss +1 -0
  89. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_section.scss +4 -1
  90. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_smp.scss +1 -0
  91. data/app/assets/stylesheets/lcms/engine/print/gdoc/lesson/_tables.scss +11 -3
  92. data/app/assets/stylesheets/lcms/engine/print/gdoc/material/_header.scss +5 -2
  93. data/app/assets/stylesheets/lcms/engine/print/lesson/_base-typography.scss +33 -9
  94. data/app/assets/stylesheets/lcms/engine/print/lesson/_group.scss +3 -1
  95. data/app/assets/stylesheets/lcms/engine/print/lesson/_image.scss +3 -1
  96. data/app/assets/stylesheets/lcms/engine/print/lesson/_materials.scss +1 -1
  97. data/app/assets/stylesheets/lcms/engine/print/lesson/_pd.scss +8 -4
  98. data/app/assets/stylesheets/lcms/engine/print/lesson/_section.scss +1 -1
  99. data/app/assets/stylesheets/lcms/engine/print/material/_header.scss +4 -1
  100. data/app/assets/stylesheets/lcms/engine/themes/_material.scss +11 -11
  101. data/app/assets/stylesheets/lcms/engine/utils/_colorcodes.scss +15 -5
  102. data/app/assets/stylesheets/lcms/engine/utils/_functions.scss +1 -1
  103. data/app/assets/stylesheets/lcms/engine/utils/_helpers.scss +23 -11
  104. data/app/assets/stylesheets/lcms/engine/utils/_placeholders.scss +1 -1
  105. data/app/assets/stylesheets/lcms/engine/utils/_variables.scss +11 -11
  106. data/app/assets/stylesheets/lcms/engine/vendors/{mathjax.css → mathjax.scss} +0 -0
  107. data/app/assets/stylesheets/lcms/engine/vendors/react-tagsinput.css +48 -0
  108. data/app/controllers/concerns/lcms/engine/reimportable.rb +12 -2
  109. data/app/controllers/lcms/engine/admin/access_codes_controller.rb +8 -3
  110. data/app/controllers/lcms/engine/admin/admin_controller.rb +6 -40
  111. data/app/controllers/lcms/engine/admin/association_picker_controller.rb +4 -1
  112. data/app/controllers/lcms/engine/admin/batch_reimports_controller.rb +2 -2
  113. data/app/controllers/lcms/engine/admin/curriculums_controller.rb +21 -2
  114. data/app/controllers/lcms/engine/admin/documents_controller.rb +41 -14
  115. data/app/controllers/lcms/engine/admin/materials_controller.rb +32 -13
  116. data/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb +2 -2
  117. data/app/controllers/lcms/engine/admin/resources_controller.rb +9 -7
  118. data/app/controllers/lcms/engine/admin/settings_controller.rb +1 -1
  119. data/app/controllers/lcms/engine/admin/standards_controller.rb +7 -2
  120. data/app/controllers/lcms/engine/admin/users_controller.rb +15 -7
  121. data/app/controllers/lcms/engine/application_controller.rb +1 -1
  122. data/app/controllers/lcms/engine/resources_controller.rb +5 -5
  123. data/app/controllers/lcms/engine/welcome_controller.rb +11 -0
  124. data/app/entities/lcms/engine/grades.rb +17 -6
  125. data/app/entities/lcms/engine/hierarchical_position.rb +1 -2
  126. data/app/entities/lcms/engine/media_embed.rb +2 -2
  127. data/app/entities/lcms/engine/pagination.rb +14 -10
  128. data/app/entities/lcms/engine/roman_numerals.rb +2 -2
  129. data/app/exceptions/lcms/engine/document_error.rb +8 -0
  130. data/app/exceptions/lcms/engine/material_error.rb +8 -0
  131. data/app/forms/lcms/engine/document_form.rb +19 -14
  132. data/app/forms/lcms/engine/material_form.rb +3 -2
  133. data/app/helpers/admin/components_helper.rb +3 -3
  134. data/app/helpers/lcms/engine/path_helper.rb +32 -0
  135. data/app/helpers/lcms/engine/resource_helper.rb +1 -1
  136. data/app/helpers/lcms/engine/view_helper.rb +1 -9
  137. data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +2 -2
  138. data/app/javascript/components/admin/ImportStatus.jsx +90 -56
  139. data/app/javascript/components/admin/Initializer.jsx +33 -35
  140. data/app/javascript/components/admin/MultiSelectedOperation.jsx +43 -18
  141. data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +68 -47
  142. data/app/javascript/components/admin/association-picker/AssociationPickerItem.jsx +18 -7
  143. data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +42 -17
  144. data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +47 -27
  145. data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +54 -32
  146. data/app/javascript/components/admin/curriculum/DirectoryPicker.jsx +80 -53
  147. data/app/javascript/components/admin/picker/PickerButton.jsx +16 -11
  148. data/app/javascript/components/admin/picker/pickerModal.jsx +6 -6
  149. data/app/javascript/components/admin/picker/pickerWindowWrapper.jsx +61 -40
  150. data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +54 -39
  151. data/app/javascript/components/admin/resource-picker/ResourcePickerResource.jsx +14 -3
  152. data/app/javascript/components/admin/resource-picker/ResourcePickerWindow.jsx +50 -21
  153. data/app/javascript/components/paginate/PageView.jsx +20 -8
  154. data/app/javascript/components/paginate/PaginationBoxView.jsx +78 -66
  155. data/app/javascript/components/paginate/PaginationListView.jsx +59 -45
  156. data/app/javascript/packs/lcms_engine_admin.js +15 -0
  157. data/app/javascript/packs/{application.js → lcms_engine_application.js} +5 -4
  158. data/app/javascript/packs/server_rendering.js +1 -0
  159. data/app/javascript/vendor/jstree/jstree.min.js +6 -0
  160. data/app/javascript/vendor/jstree/themes/default/32px.png +0 -0
  161. data/app/javascript/vendor/jstree/themes/default/40px.png +0 -0
  162. data/app/javascript/vendor/jstree/themes/default/style.css +1106 -0
  163. data/app/javascript/vendor/jstree/themes/default/style.min.css +1 -0
  164. data/app/javascript/vendor/jstree/themes/default/throbber.gif +0 -0
  165. data/app/javascript/vendor/jstree/themes/default-dark/32px.png +0 -0
  166. data/app/javascript/vendor/jstree/themes/default-dark/40px.png +0 -0
  167. data/app/javascript/vendor/jstree/themes/default-dark/style.css +1150 -0
  168. data/app/javascript/vendor/jstree/themes/default-dark/style.min.css +1 -0
  169. data/app/javascript/vendor/jstree/themes/default-dark/throbber.gif +0 -0
  170. data/app/jobs/concerns/lcms/engine/nested_resque_job.rb +1 -4
  171. data/app/jobs/lcms/engine/document_generate_gdoc_job.rb +2 -2
  172. data/app/jobs/lcms/engine/document_generate_job.rb +2 -2
  173. data/app/jobs/lcms/engine/document_generate_pdf_job.rb +5 -5
  174. data/app/jobs/lcms/engine/document_parse_job.rb +1 -1
  175. data/app/jobs/lcms/engine/material_generate_pdf_job.rb +4 -4
  176. data/app/models/concerns/lcms/engine/navigable.rb +6 -10
  177. data/app/models/concerns/lcms/engine/searchable.rb +7 -0
  178. data/app/models/lcms/engine/document.rb +1 -1
  179. data/app/models/lcms/engine/download.rb +1 -1
  180. data/app/models/lcms/engine/resource.rb +1 -1
  181. data/app/models/lcms/engine/search/document.rb +4 -3
  182. data/app/models/lcms/engine/search/repository.rb +1 -1
  183. data/app/presenters/lcms/engine/content_presenter.rb +1 -1
  184. data/app/presenters/lcms/engine/curriculum_presenter.rb +21 -18
  185. data/app/presenters/lcms/engine/document_presenter.rb +5 -3
  186. data/app/presenters/lcms/engine/resource_presenter.rb +6 -3
  187. data/app/queries/lcms/engine/admin_documents_query.rb +2 -2
  188. data/app/queries/lcms/engine/admin_materials_query.rb +11 -2
  189. data/app/queries/lcms/engine/base_query.rb +1 -1
  190. data/app/serializers/lcms/engine/previews_material_serializer.rb +1 -0
  191. data/app/services/lcms/engine/document_build_service.rb +6 -0
  192. data/app/services/lcms/engine/document_generator.rb +2 -2
  193. data/app/services/lcms/engine/google/drive_service.rb +7 -15
  194. data/app/services/lcms/engine/google/script_service.rb +7 -3
  195. data/app/services/lcms/engine/html_sanitizer.rb +6 -6
  196. data/app/services/lcms/engine/lessons_gdoc_bundler.rb +1 -1
  197. data/app/services/lcms/engine/lti_exporter.rb +1 -1
  198. data/app/services/lcms/engine/material_build_service.rb +6 -2
  199. data/app/services/lcms/engine/material_preview_generator.rb +3 -3
  200. data/app/services/lcms/engine/react_materials_resolver.rb +3 -2
  201. data/app/services/lcms/engine/s3_service.rb +14 -2
  202. data/app/tasks/resource_tasks.rb +2 -2
  203. data/app/views/layouts/lcms/engine/admin.html.erb +3 -3
  204. data/app/views/layouts/lcms/engine/application.html.erb +2 -2
  205. data/app/views/layouts/lcms/engine/lti.html.erb +1 -1
  206. data/app/views/lcms/engine/admin/access_codes/_form.html.erb +1 -1
  207. data/app/views/lcms/engine/admin/access_codes/index.html.erb +3 -3
  208. data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +2 -2
  209. data/app/views/lcms/engine/admin/curriculums/edit.html.erb +5 -5
  210. data/app/views/lcms/engine/admin/documents/_materials_links.html.erb +2 -2
  211. data/app/views/lcms/engine/admin/documents/_reimport.html.erb +1 -1
  212. data/app/views/lcms/engine/admin/documents/_search_form.html.erb +2 -2
  213. data/app/views/lcms/engine/admin/documents/import.html.erb +1 -1
  214. data/app/views/lcms/engine/admin/documents/index.html.erb +7 -5
  215. data/app/views/lcms/engine/admin/documents/new.html.erb +6 -2
  216. data/app/views/lcms/engine/admin/materials/_reimport.html.erb +1 -1
  217. data/app/views/lcms/engine/admin/materials/_search_form.html.erb +2 -2
  218. data/app/views/lcms/engine/admin/materials/import.html.erb +1 -1
  219. data/app/views/lcms/engine/admin/materials/index.html.erb +26 -22
  220. data/app/views/lcms/engine/admin/materials/new.html.erb +5 -1
  221. data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +2 -2
  222. data/app/views/lcms/engine/admin/resources/_fields.html.erb +4 -0
  223. data/app/views/lcms/engine/admin/resources/_form.html.erb +1 -1
  224. data/app/views/lcms/engine/admin/resources/_search_form.html.erb +2 -2
  225. data/app/views/lcms/engine/admin/resources/index.html.erb +7 -5
  226. data/app/views/lcms/engine/admin/shared/_header.html.erb +12 -12
  227. data/app/views/lcms/engine/admin/standards/_form.html.erb +3 -1
  228. data/app/views/lcms/engine/admin/standards/_search_form.html.erb +1 -1
  229. data/app/views/lcms/engine/admin/users/_form.html.erb +1 -1
  230. data/app/views/lcms/engine/admin/users/_search_form.html.erb +1 -1
  231. data/app/views/lcms/engine/admin/users/index.html.erb +6 -6
  232. data/app/views/lcms/engine/documents/gdoc/_agenda.html.erb +1 -1
  233. data/app/views/lcms/engine/documents/show.html.erb +1 -1
  234. data/app/views/lcms/engine/materials/show.html.erb +1 -1
  235. data/app/views/lcms/engine/pages/not_found.html.erb +5 -0
  236. data/app/views/lcms/engine/resources/_download.html.erb +2 -2
  237. data/app/views/lcms/engine/resources/_unit_bundles.html.erb +2 -2
  238. data/app/views/lcms/engine/resources/generic.html.erb +0 -4
  239. data/app/views/lcms/engine/resources/media.html.erb +0 -4
  240. data/app/views/lcms/engine/resources/show.html.erb +0 -2
  241. data/config/initializers/airbrake.rb +62 -10
  242. data/config/initializers/bitly.rb +1 -1
  243. data/config/initializers/carrier_wave.rb +6 -4
  244. data/config/initializers/ckeditor.rb +6 -0
  245. data/config/initializers/elasticsearch.rb +1 -1
  246. data/config/initializers/resque.rb +2 -2
  247. data/config/locales/admin/en.yml +1 -2
  248. data/config/locales/ui/en.yml +1 -0
  249. data/config/routes.rb +5 -2
  250. data/db/migrate/.keep +0 -0
  251. data/db/schema.rb +280 -312
  252. data/db/seeds.rb +0 -1
  253. data/docker-compose.ror4.yml +32 -0
  254. data/docker-compose.yml +6 -3
  255. data/docs/env-variables.md +40 -40
  256. data/docs/google-cloud-platform-setup.md +45 -17
  257. data/docs/how-to-build-and-publish.md +1 -0
  258. data/lcms-engine.gemspec +28 -20
  259. data/lib/doc_template/document.rb +3 -4
  260. data/lib/doc_template/document_toc.rb +2 -2
  261. data/lib/doc_template/objects/activity_metadata.rb +1 -1
  262. data/lib/doc_template/objects/agenda_metadata.rb +1 -1
  263. data/lib/doc_template/objects/metadata_helpers.rb +1 -1
  264. data/lib/doc_template/objects/toc_helpers.rb +4 -4
  265. data/lib/doc_template/objects/toc_metadata.rb +4 -6
  266. data/lib/doc_template/tables/base.rb +3 -2
  267. data/lib/doc_template/tags/activity_metadata_type_tag.rb +1 -1
  268. data/lib/doc_template/tags/answer_space_tag.rb +2 -2
  269. data/lib/doc_template/tags/base_tag.rb +5 -5
  270. data/lib/doc_template/tags/block_tag.rb +1 -1
  271. data/lib/doc_template/tags/columns_tag.rb +1 -1
  272. data/lib/doc_template/tags/def_tag.rb +1 -1
  273. data/lib/doc_template/tags/expand_tag.rb +1 -0
  274. data/lib/doc_template/tags/heading_tag.rb +1 -1
  275. data/lib/doc_template/tags/inset_tag.rb +2 -2
  276. data/lib/doc_template/tags/latex_tag.rb +1 -1
  277. data/lib/doc_template/tags/page_break_tag.rb +1 -1
  278. data/lib/doc_template/tags/pd_tag.rb +4 -4
  279. data/lib/doc_template/tags/section_tag.rb +2 -2
  280. data/lib/doc_template/tags/standard_tag.rb +3 -3
  281. data/lib/doc_template/tags/table_preserve_alignment_tag.rb +1 -1
  282. data/lib/doc_template/tags/table_tag.rb +1 -1
  283. data/lib/doc_template/template.rb +1 -1
  284. data/lib/doc_template.rb +9 -9
  285. data/lib/document_exporter/gdoc/base.rb +6 -3
  286. data/lib/document_exporter/pdf/base.rb +1 -1
  287. data/lib/document_exporter/pdf/document.rb +2 -2
  288. data/lib/document_exporter/pdf/material.rb +2 -2
  289. data/lib/document_exporter/pdf/student_material.rb +2 -2
  290. data/lib/document_exporter/pdf/teacher_material.rb +2 -2
  291. data/lib/document_renderer/part.rb +4 -6
  292. data/lib/elasticsearch/persistence/repository/response/results.rb +1 -1
  293. data/lib/lcms/engine/engine.rb +10 -9
  294. data/lib/lcms/engine/version.rb +1 -1
  295. data/lib/lcms/engine.rb +0 -1
  296. data/lib/lt/lcms/metadata/base_service.rb +2 -1
  297. data/lib/lt/lcms/metadata/context.rb +58 -54
  298. data/lib/lt/lcms/metadata/service.rb +6 -3
  299. data/lib/resque_job.rb +3 -6
  300. data/lib/standard_importer.rb +4 -4
  301. data/lib/tasks/cloud66.rake +8 -6
  302. data/lib/tasks/document.rake +7 -7
  303. data/lib/tasks/google.rake +29 -14
  304. data/lib/tasks/lcms/engine_tasks.rake +1 -1
  305. data/package.json +31 -9
  306. data/postcss.config.js +12 -0
  307. data/spec/controllers/admin/association_picker_controller_spec.rb +6 -8
  308. data/spec/controllers/admin/curriculums_controller_spec.rb +23 -0
  309. data/spec/controllers/admin/documents_controller_spec.rb +25 -3
  310. data/spec/controllers/admin/materials_controller_spec.rb +17 -4
  311. data/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +1 -1
  312. data/spec/controllers/admin/resources_controller_spec.rb +3 -3
  313. data/spec/controllers/admin/settings_controller_spec.rb +1 -1
  314. data/spec/controllers/admin/standards_controller_spec.rb +1 -1
  315. data/spec/controllers/admin/welcome_controller_spec.rb +12 -10
  316. data/spec/controllers/resources_controller_spec.rb +3 -3
  317. data/spec/controllers/welcome_controller_spec.rb +38 -0
  318. data/spec/dummy/.env.docker +5 -0
  319. data/spec/dummy/.traceroute.yaml +0 -2
  320. data/spec/dummy/bin/webpack +18 -0
  321. data/spec/dummy/bin/webpack-dev-server +18 -0
  322. data/spec/dummy/config/application.rb +1 -1
  323. data/spec/dummy/config/environments/production.rb +1 -1
  324. data/spec/dummy/config/environments/test.rb +1 -1
  325. data/spec/dummy/config/initializers/assets.rb +6 -0
  326. data/spec/dummy/config/lcms-admin.yml +3 -7
  327. data/spec/dummy/config/puma.rb +3 -3
  328. data/spec/dummy/config/routes.rb +6 -0
  329. data/spec/dummy/db/schema.rb +5 -5
  330. data/spec/entities/grades_spec.rb +12 -0
  331. data/spec/factories/documents.rb +1 -0
  332. data/spec/factories/downloads.rb +1 -1
  333. data/spec/factories/resources.rb +2 -2
  334. data/spec/features/admin/lessons/add_lesson_spec.rb +3 -3
  335. data/spec/features/admin/materials/add_material_spec.rb +5 -3
  336. data/spec/features/admin/users_spec.rb +2 -2
  337. data/spec/forms/document_form_spec.rb +11 -1
  338. data/spec/{controllers/admin/admin_controller_spec.rb → helpers/path_helper_spec.rb} +6 -6
  339. data/spec/lib/doc_template/objects/activity_metadata_spec.rb +1 -1
  340. data/spec/lib/doc_template/objects/agenda_metadata_spec.rb +2 -0
  341. data/spec/lib/doc_template/objects/toc_metadata_spec.rb +1 -1
  342. data/spec/lib/doc_template/tables/shared_examples/remove_table.rb +1 -1
  343. data/spec/lib/doc_template/tags/page_break_tag_spec.rb +1 -1
  344. data/spec/lib/doc_template/tags/pd_tag_spec.rb +1 -1
  345. data/spec/models/document_spec.rb +1 -1
  346. data/spec/models/standard_spec.rb +2 -0
  347. data/spec/queries/lcms/engine/admin_materials_query_spec.rb +34 -0
  348. data/spec/rails_helper.rb +8 -2
  349. data/spec/services/document_build_service_spec.rb +4 -11
  350. data/spec/services/s3_service_spec.rb +31 -0
  351. data/spec/support/concerns/navigable.rb +2 -0
  352. data/spec/support/routes.rb +4 -0
  353. data/spec/support/shared_examples/content_tag.rb +4 -4
  354. data/templates/routes.rb +0 -1
  355. data/yarn.lock +3447 -2993
  356. metadata +208 -303
  357. data/app/assets/stylesheets/lcms/engine/application.scss +0 -36
  358. data/app/assets/stylesheets/lcms/engine/vendors/jquery.tagsinput.css +0 -1
  359. data/app/exceptions/components_api_error.rb +0 -4
  360. data/app/exceptions/document_error.rb +0 -4
  361. data/app/exceptions/material_error.rb +0 -4
  362. data/app/javascript/packs/admin.js +0 -14
  363. data/app/models/lcms/engine/component.rb +0 -88
  364. data/app/presenters/lcms/engine/social_media_presenter.rb +0 -83
  365. data/app/views/lcms/engine/shared/_social_sharing.html.erb +0 -22
  366. data/db/migrate/20200217160930_change_document_parts_to_polymorphic.rb +0 -36
  367. data/db/migrate/20200218144849_drop_material_parts_table.rb +0 -7
  368. data/db/migrate/20200422130652_add_reimported_at_to_documents.rb +0 -7
  369. data/db/migrate/20200429130353_drop_pages.rb +0 -13
  370. data/db/seeds/pages.seeds.rb +0 -26
  371. data/lib/document_exporter.rb +0 -6
  372. data/lib/lcms/engine/migration.rb +0 -16
  373. data/spec/models/component_spec.rb +0 -60
  374. data/vendor/assets/javascripts/jquery.tagsinput.js +0 -1
@@ -8,7 +8,7 @@ module DocTemplate
8
8
  def no_end_tag_for(node)
9
9
  msg = "No tag with END value for: #{self.class::TAG_NAME.upcase}<br>" \
10
10
  "<em>#{node.parent.try(:inner_html)}</em>"
11
- raise DocumentError, msg
11
+ raise Lcms::Engine::DocumentError, msg
12
12
  end
13
13
 
14
14
  #
@@ -5,7 +5,7 @@ module DocTemplate
5
5
  class ColumnsTag < BlockTag
6
6
  include ERB::Util
7
7
 
8
- ALIGNMENT_RE = /^align-right\s/i
8
+ ALIGNMENT_RE = /^align-right\s/i.freeze
9
9
  SPLIT_SYMBOL = ';'
10
10
  TAG_NAME = 'columns'
11
11
  TEMPLATE = 'columns.html.erb'
@@ -5,7 +5,7 @@ module DocTemplate
5
5
  class DefTag < BaseTag
6
6
  include ERB::Util
7
7
 
8
- STYLE_RE = /<span (style=[^.>]*)>[^<]*$/i
8
+ STYLE_RE = /<span (style=[^.>]*)>[^<]*$/i.freeze
9
9
  TAG_NAME = 'def'
10
10
  TAG_SEPARATOR = '[separator]'
11
11
  TEMPLATES = {
@@ -27,6 +27,7 @@ module DocTemplate
27
27
  # iterates over all child nodes looking for break tag
28
28
  node.at_xpath('.//tr[2]/td').children.each do |child|
29
29
  (broken = true) && next if child.text.index("[#{BREAK_TAG_NAME}]")
30
+
30
31
  child.remove_attribute('class')
31
32
  child.children.each { |x| x.remove_attribute('class') }
32
33
  broken ? content_hidden.push(child) : content_visible.push(child)
@@ -25,7 +25,7 @@ module DocTemplate
25
25
  end
26
26
 
27
27
  def heading(value)
28
- value.include?(prefix + ':') ? value : "#{prefix}: #{value}"
28
+ value.include?("#{prefix}:") ? value : "#{prefix}: #{value}"
29
29
  end
30
30
  end
31
31
 
@@ -28,8 +28,8 @@ module DocTemplate
28
28
  def preserve_styles(node, opts)
29
29
  add_css_class(node, 'o-ld-inset') if gdoc?(opts)
30
30
  node.children.each do |el|
31
- el['class'] = el['class'].to_s + ' text-bold' if el['style'] =~ STYLES_REGEXP[:bold]
32
- el['class'] = el['class'].to_s + ' text-italic' if el['style'] =~ STYLES_REGEXP[:italic]
31
+ el['class'] = "#{el['class']} text-bold" if el['style'] =~ STYLES_REGEXP[:bold]
32
+ el['class'] = "#{el['class']} text-italic" if el['style'] =~ STYLES_REGEXP[:italic]
33
33
  end
34
34
  node
35
35
  end
@@ -5,7 +5,7 @@ require 'doc_template'
5
5
  module DocTemplate
6
6
  module Tags
7
7
  class LatexTag < BaseTag
8
- SPACE_RE = /[[:space:]]/
8
+ SPACE_RE = /[[:space:]]/.freeze
9
9
  TAG_NAME = 'latex'
10
10
 
11
11
  def self.s3_folder
@@ -4,7 +4,7 @@ module DocTemplate
4
4
  module Tags
5
5
  class PageBreakTag < BaseTag
6
6
  CSS_CLASS = 'u-pdf-alwaysbreak'
7
- TAG_NAME = /page(-|\s*)break/
7
+ TAG_NAME = /page(-|\s*)break/.freeze
8
8
  TAG_SUB = '<p>--GDOC-PAGE-BREAK--</p>'
9
9
 
10
10
  def parse(node, opts)
@@ -5,10 +5,10 @@ module DocTemplate
5
5
  class PdTag < BaseTag
6
6
  include Rails.application.routes.url_helpers
7
7
 
8
- CG_RE = %r{/content_guides/(\d+)/}i
9
- PDF_HTTP_RE = %r{^https?://}i
10
- PDF_HTTP_REPLACE_RE = /^http:/i
11
- PDF_RE = /\.pdf$/i
8
+ CG_RE = %r{/content_guides/(\d+)/}i.freeze
9
+ PDF_HTTP_RE = %r{^https?://}i.freeze
10
+ PDF_HTTP_REPLACE_RE = /^http:/i.freeze
11
+ PDF_RE = /\.pdf$/i.freeze
12
12
  TAG_NAME = 'pd'
13
13
  TEMPLATES = {
14
14
  default: 'pd.html.erb',
@@ -5,9 +5,9 @@ module DocTemplate
5
5
  class SectionTag < BaseTag
6
6
  include DocTemplate::Tags::Helpers
7
7
 
8
- STUDENT_RE = /^\s*student\s*resources\s*$/i
8
+ STUDENT_RE = /^\s*student\s*resources\s*$/i.freeze
9
9
  TAG_NAME = 'section'
10
- SECTION_REMOVE_RE = /\[#{TAG_NAME}:[^\]]*\]/i
10
+ SECTION_REMOVE_RE = /\[#{TAG_NAME}:[^\]]*\]/i.freeze
11
11
  TEMPLATES = {
12
12
  default: 'section.html.erb',
13
13
  gdoc: 'gdoc/section.html.erb'
@@ -5,9 +5,9 @@ module DocTemplate
5
5
  class StandardTag < BaseTag
6
6
  include ERB::Util
7
7
 
8
- STANDARD_RE = /[^\[\]]*\[(ela\.)?((rl|ri|rf|w|sl|l)\.[^\]]+)\]/i # [rl.2.2a.2]
9
- TAG_NAME = /(ela\.)?((rl|ri|rf|w|sl|l)\.[^\]]+)/ # RL.2.4 or ELA.RL.2.4
10
- TAG_RE = /\[[^\]]*\]/
8
+ STANDARD_RE = /[^\[\]]*\[(ela\.)?((rl|ri|rf|w|sl|l)\.[^\]]+)\]/i.freeze # [rl.2.2a.2]
9
+ TAG_NAME = /(ela\.)?((rl|ri|rf|w|sl|l)\.[^\]]+)/.freeze # RL.2.4 or ELA.RL.2.4
10
+ TAG_RE = /\[[^\]]*\]/.freeze
11
11
  TAG_SEPARATOR = '[separator]'
12
12
  TEMPLATES = { default: 'standard.html.erb',
13
13
  gdoc: 'gdoc/standard.html.erb' }.freeze
@@ -3,7 +3,7 @@
3
3
  module DocTemplate
4
4
  module Tags
5
5
  class TablePreserveAlignmentTag < BaseTag
6
- STYLE_RE = /text-align:(left|center|right)/i
6
+ STYLE_RE = /text-align:(left|center|right)/i.freeze
7
7
  TAG_NAME = 'table-preserve-alignment'
8
8
 
9
9
  def parse(node, _options = {})
@@ -5,7 +5,7 @@ module DocTemplate
5
5
  class TableTag < BaseTag
6
6
  def parse(node, opts = {})
7
7
  unless (table = node.ancestors('table').first)
8
- raise ::DocumentError, "Tag #{self.class::TAG_NAME.upcase} placed outside table"
8
+ raise ::Lcms::Engine::DocumentError, "Tag #{self.class::TAG_NAME.upcase} placed outside table"
9
9
  end
10
10
 
11
11
  @opts = opts
@@ -101,7 +101,7 @@ module DocTemplate
101
101
  placeholder: nil
102
102
  }
103
103
 
104
- @toc ||= ::DocTemplate::DocumentTOC.parse(options) unless material?
104
+ @toc ||= ::DocTemplate::DocumentToc.parse(options) unless material?
105
105
  end
106
106
 
107
107
  self
data/lib/doc_template.rb CHANGED
@@ -19,7 +19,7 @@ module DocTemplate
19
19
  sanitizer: 'Lcms::Engine::HtmlSanitizer'
20
20
  }.freeze
21
21
 
22
- FULL_TAG ||= /\[([^\]:\s]*)?\s*:?\s*([^\]]*?)?\]/mo
22
+ FULL_TAG ||= /\[([^\]:\s]*)?\s*:?\s*([^\]]*?)?\]/mo.freeze
23
23
  START_TAG ||= '\[[^\]]*'
24
24
 
25
25
  STARTTAG_XPATH ||= 'span[contains(., "[")]'
@@ -60,12 +60,12 @@ module DocTemplate
60
60
  end
61
61
  end
62
62
 
63
- require_dependency 'doc_template/template'
64
- require_dependency 'doc_template/document'
65
- require_dependency 'doc_template/tags'
66
- require_dependency 'doc_template/document_toc'
67
- require_dependency 'doc_template/xpath_functions'
63
+ require 'doc_template/template'
64
+ require 'doc_template/document'
65
+ require 'doc_template/tags'
66
+ require 'doc_template/document_toc'
67
+ require 'doc_template/xpath_functions'
68
68
 
69
- Dir["#{__dir__}/doc_template/tables/*.rb"].each(&method(:require_dependency))
70
- Dir["#{__dir__}/doc_template/tags/*.rb"].each(&method(:require_dependency))
71
- Dir["#{__dir__}/doc_template/objects/*.rb"].each(&method(:require_dependency))
69
+ Dir["#{__dir__}/doc_template/tables/*.rb"].sort.each(&method(:require))
70
+ Dir["#{__dir__}/doc_template/tags/*.rb"].sort.each(&method(:require))
71
+ Dir["#{__dir__}/doc_template/objects/*.rb"].sort.each(&method(:require))
@@ -16,7 +16,7 @@ module DocumentExporter
16
16
  send_timeout_sec: GOOGLE_API_CLIENT_UPLOAD_TIMEOUT
17
17
  }
18
18
  }.freeze
19
- VERSION_RE = /_v\d+$/i
19
+ VERSION_RE = /_v\d+$/i.freeze
20
20
 
21
21
  attr_reader :document, :options
22
22
 
@@ -108,7 +108,8 @@ module DocumentExporter
108
108
  # Deletes files of previous versions
109
109
  #
110
110
  def delete_previous_versions_from(folder)
111
- drive_service.service.list_files(q: "'#{folder}' in parents").files.each do |file|
111
+ files = drive_service.service.list_files(q: "'#{folder}' in parents")&.files
112
+ Array.wrap(files).each do |file|
112
113
  next unless file.name =~ VERSION_RE
113
114
 
114
115
  drive_service.service.delete_file file.id
@@ -136,7 +137,9 @@ module DocumentExporter
136
137
  end
137
138
 
138
139
  def post_processing
139
- Lcms::Engine::Google::ScriptService.new(document).execute(@id)
140
+ Retriable.retriable(base_interval: 5, tries: 10) do
141
+ Lcms::Engine::Google::ScriptService.new(document).execute(@id)
142
+ end
140
143
  end
141
144
  end
142
145
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
4
+ module Pdf
5
5
  class Base < DocumentExporter::Base
6
6
  def self.s3_folder
7
7
  @s3_folder ||= ENV.fetch('SWAP_DOCS', 'documents')
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class Document < PDF::Base
4
+ module Pdf
5
+ class Document < Pdf::Base
6
6
  def export
7
7
  content = super
8
8
  pdf = CombinePDF.parse(content)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class Material < PDF::Base
4
+ module Pdf
5
+ class Material < Pdf::Base
6
6
  private
7
7
 
8
8
  def template_path(name)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class StudentMaterial < PDF::Base
4
+ module Pdf
5
+ class StudentMaterial < Pdf::Base
6
6
  def export
7
7
  pdf = CombinePDF.new
8
8
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DocumentExporter
4
- module PDF
5
- class TeacherMaterial < PDF::Base
4
+ module Pdf
5
+ class TeacherMaterial < Pdf::Base
6
6
  def export
7
7
  content = super
8
8
  pdf = CombinePDF.parse(content)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DocumentRenderer
4
4
  class Part
5
- PART_RE = /{{[^}]+}}/
5
+ PART_RE = /{{[^}]+}}/.freeze
6
6
 
7
7
  class << self
8
8
  def call(content, options)
@@ -11,7 +11,7 @@ module DocumentRenderer
11
11
  next unless placeholder
12
12
  next unless (part = options[:parts_index][placeholder])
13
13
  next unless (subpart = part[:content])
14
- next unless should_render?(part, !options[:with_optional])
14
+ next unless should_render?(part, omit_optional: !options[:with_optional])
15
15
 
16
16
  call subpart.to_s, options
17
17
  end
@@ -26,13 +26,11 @@ module DocumentRenderer
26
26
  # If part is not optional:
27
27
  # - just ignore it if it has been turned OFF
28
28
  #
29
- def should_render?(part, omit_optional = true)
29
+ def should_render?(part, omit_optional: true)
30
30
  if part[:optional] && omit_optional
31
31
  false unless @excludes.include?(part[:anchor])
32
- elsif @excludes.include?(part[:anchor])
33
- false
34
32
  else
35
- true
33
+ !@excludes.include?(part[:anchor])
36
34
  end
37
35
  end
38
36
  end
@@ -20,7 +20,7 @@ module Elasticsearch
20
20
  results.respond_to?(method_name) ? results.__send__(method_name, *arguments, &block) : super
21
21
  end
22
22
 
23
- def respond_to?(method_name, include_private = false)
23
+ def respond_to?(method_name, include_private = false) # rubocop:disable Style/OptionalBooleanParameter
24
24
  results.respond_to?(method_name) || super
25
25
  end
26
26
 
@@ -66,9 +66,16 @@ module Lcms
66
66
  # Check if the DB exists
67
67
  next unless ActiveRecord::Base.connection
68
68
 
69
+ # Possible decorators
70
+ decorators = %W[
71
+ #{Rails.root}/app/decorators/**/*_decorator*.rb
72
+ #{Rails.root}/app/**/lcms/engine/*_decorator*.rb
73
+ ]
74
+
69
75
  Dir
70
- .glob(Rails.root + 'app/decorators/**/*_decorator*.rb')
71
- .each(&method(:require_dependency))
76
+ .glob(decorators)
77
+ .sort
78
+ .each(&method(:require))
72
79
  rescue ActiveRecord::NoDatabaseError
73
80
  puts 'ActiveRecord::NoDatabaseError thrown!'
74
81
  end
@@ -88,13 +95,7 @@ module Lcms
88
95
  end
89
96
 
90
97
  initializer 'lcms.engine.assets.precompile' do |app|
91
- app.config.assets.precompile += %w(
92
- lcms_engine_manifest.js
93
- )
94
- # app.config.assets.precompile += %w(
95
- # ckeditor/*
96
- # gdoc.css
97
- # )
98
+ app.config.assets.precompile += %w(lcms_engine_manifest.js ckeditor/config.js)
98
99
  end
99
100
 
100
101
  initializer 'webpacker.proxy' do |app|
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- VERSION = '0.3.0'
5
+ VERSION = '0.4.0'
6
6
  RAILS_5_VERSION = 5.2
7
7
  end
8
8
  end
data/lib/lcms/engine.rb CHANGED
@@ -23,4 +23,3 @@ module Lcms
23
23
  end
24
24
 
25
25
  require 'lcms/engine/engine'
26
- require 'lcms/engine/migration'
@@ -6,7 +6,7 @@ module Lt
6
6
  module Metadata
7
7
  class BaseService
8
8
  class << self
9
- attr_reader :activity_metadata, :metadata, :section_metadata
9
+ attr_reader :activity_metadata, :errors, :metadata, :section_metadata
10
10
 
11
11
  def materials_metadata
12
12
  raise NotImplementedError
@@ -22,6 +22,7 @@ module Lt
22
22
  end
23
23
 
24
24
  def parse(_content, *args)
25
+ @errors = []
25
26
  @options = args.extract_options!
26
27
  end
27
28
 
@@ -9,7 +9,7 @@ module Lt
9
9
  class Context
10
10
  attr_reader :context
11
11
 
12
- NUM_RE = /\d+/
12
+ NUM_RE = /\d+/.freeze
13
13
 
14
14
  class << self
15
15
  #
@@ -17,7 +17,7 @@ module Lt
17
17
  # Is used inside `#find_or_create_resource` method
18
18
  #
19
19
  def update_grades_level_position_for(grades)
20
- update_level_position_for(grades) { |g| ::Lcms::Engine::Grades::GRADES.index(g.metadata['grade']) }
20
+ update_level_position_for(grades) { |g| ::Lcms::Engine::Grades.grades.index(g.metadata['grade']) }
21
21
  end
22
22
 
23
23
  #
@@ -71,41 +71,45 @@ module Lt
71
71
  end
72
72
 
73
73
  def find_or_create_resource
74
- # if the resource exists, return it
75
- resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory)
76
- return update(resource) if resource
77
-
78
- # else, build missing parents until we build the resource itself.
79
- parent = nil
80
- directory.each_with_index do |name, index|
81
- resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory[0..index])
82
- if resource
83
- parent = resource
84
- next
85
- end
74
+ # rubocop:disable Metrics/BlockLength
75
+ ::Lcms::Engine::Resource.with_advisory_lock('find_or_create_resource') do
76
+ # if the resource exists, return it
77
+ resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory)
78
+ return update(resource) if resource
79
+
80
+ # else, build missing parents until we build the resource itself.
81
+ parent = nil
82
+ directory.each_with_index do |name, index|
83
+ resource = ::Lcms::Engine::Resource.tree.find_by_directory(directory[0..index])
84
+ if resource
85
+ parent = resource
86
+ next
87
+ end
86
88
 
87
- resource = build_new_resource(parent, name, index)
88
- unless last_item?(index)
89
- resource.save!
90
- unless resource.subject?
91
- self.class.send("update_#{resource.curriculum_type}s_level_position_for", resource.self_and_siblings)
89
+ resource = build_new_resource(parent, name, index)
90
+ unless last_item?(index)
91
+ resource.save!
92
+ unless resource.subject?
93
+ self.class.send("update_#{resource.curriculum_type}s_level_position_for", resource.self_and_siblings)
94
+ end
95
+ parent = resource
96
+ next
92
97
  end
93
- parent = resource
94
- next
95
- end
96
98
 
97
- if mid_assessment?
98
- set_mid_assessment_position(parent, resource)
99
- elsif prerequisite?
100
- set_prerequisite_position(parent, resource)
101
- elsif opr?
102
- set_opr_position(parent, resource)
103
- else
104
- set_lesson_position(parent, resource)
99
+ if mid_assessment?
100
+ set_mid_assessment_position(parent, resource)
101
+ elsif prerequisite?
102
+ set_prerequisite_position(parent, resource)
103
+ elsif opr?
104
+ set_opr_position(parent, resource)
105
+ else
106
+ set_lesson_position(parent, resource)
107
+ end
105
108
  end
106
- end
107
109
 
108
- update resource
110
+ update resource
111
+ end
112
+ # rubocop:enable Metrics/BlockLength
109
113
  end
110
114
 
111
115
  private
@@ -143,7 +147,7 @@ module Lt
143
147
  # ELA G1 M1 U2 Lesson 1
144
148
  curr ||= directory
145
149
  res = ::Lcms::Engine::Resource.new(metadata: metadata)
146
- ::Lcms::Engine::Breadcrumbs.new(res).title.split(' / ')[0...-1].push(curr.last.titleize).join(' ')
150
+ ::Lcms::Engine::Breadcrumbs.new(res).title.split(' / ')[0...-1].push(curr.last.to_s.titleize).join(' ')
147
151
  end
148
152
  end
149
153
 
@@ -164,7 +168,7 @@ module Lt
164
168
 
165
169
  def grade
166
170
  @grade ||= begin
167
- value = context[:grade].try(:downcase)
171
+ value = context[:grade].to_s.downcase
168
172
  value = "grade #{value.to_i}" if number?(value)
169
173
  value # if Grades::GRADES.include?(value)
170
174
  end
@@ -175,16 +179,18 @@ module Lt
175
179
  end
176
180
 
177
181
  def lesson
178
- @lesson ||= begin
179
- return nil if assessment? # assessment is a unit now, so lesson -> nil
180
-
181
- num = if ela? && prerequisite?
182
- ::Lcms::Engine::RomanNumerals.to_roman(context[:lesson].to_i)&.downcase
183
- else
184
- context[:lesson].presence
185
- end
186
- "lesson #{num}" if num.present?
187
- end
182
+ @lesson ||=
183
+ if assessment?
184
+ # assessment is a unit now, so lesson -> nil
185
+ nil
186
+ else
187
+ num = if ela? && prerequisite?
188
+ ::Lcms::Engine::RomanNumerals.to_roman(context[:lesson].to_i)&.downcase
189
+ else
190
+ context[:lesson].presence
191
+ end
192
+ "lesson #{num}" if num.present?
193
+ end
188
194
  end
189
195
 
190
196
  def mid_assessment?
@@ -240,20 +246,18 @@ module Lt
240
246
  end
241
247
 
242
248
  def unit
243
- @unit ||= begin
244
- if assessment?
245
- type # assessment-mid || assessment-end
246
- else
247
- ela? ? "unit #{context[:unit]}" : "topic #{context[:topic]}"
248
- end
249
- end
249
+ @unit ||= if assessment?
250
+ type # assessment-mid || assessment-end
251
+ else
252
+ ela? ? "unit #{context[:unit]}" : "topic #{context[:topic]}"
253
+ end
250
254
  end
251
255
 
252
- def update(resource)
256
+ def update(resource) # rubocop:disable Metrics/AbcSize
253
257
  return if resource.nil?
254
258
 
255
259
  # if resource changed to prerequisite, fix positioning
256
- prereq = context['type'].to_s.casecmp('prereq').zero?
260
+ prereq = context['type'].to_s.casecmp('prereq').to_i.zero?
257
261
  fix_prereq_position(resource) if prereq && !resource.prerequisite?
258
262
 
259
263
  # Update resource with document metadata
@@ -261,7 +265,7 @@ module Lt
261
265
  resource.teaser = context['teaser'] if context['teaser'].present?
262
266
  resource.description = context['description'] if context['description'].present?
263
267
  resource.tag_list << 'prereq' if prereq
264
- resource.tag_list << 'opr' if context['type'].to_s.casecmp('opr').zero?
268
+ resource.tag_list << 'opr' if context['type'].to_s.casecmp('opr').to_i.zero?
265
269
  resource.save
266
270
 
267
271
  resource
@@ -35,14 +35,17 @@ module Lt
35
35
  )
36
36
  end
37
37
 
38
- def parse(content, *args)
38
+ def parse(content, *args) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
39
39
  super
40
40
  if material?
41
41
  @metadata = DocTemplate::Tables::MaterialMetadata.parse content
42
- raise ::MaterialError, 'No metadata present' if !@metadata&.table_exist? || @metadata&.data&.empty?
42
+ @errors.concat @metadata.errors
43
+ raise ::Lcms::Engine::MaterialError, 'No metadata present' \
44
+ if !@metadata&.table_exist? || @metadata&.data&.empty?
43
45
  else
44
46
  @metadata = DocTemplate::Tables::Metadata.parse content
45
- raise ::DocumentError, 'No metadata present' unless @metadata&.table_exist?
47
+ @errors.concat @metadata.errors
48
+ raise ::Lcms::Engine::DocumentError, 'No metadata present' unless @metadata&.table_exist?
46
49
 
47
50
  @agenda = DocTemplate::Tables::Agenda.parse content
48
51
  @section_metadata = DocTemplate::Tables::Section.parse content,
data/lib/resque_job.rb CHANGED
@@ -17,7 +17,8 @@ module ResqueJob
17
17
  end
18
18
 
19
19
  def find_in_queue_by_payload(job_class, &block)
20
- result = Resque.peek(:default, 0, 0)
20
+ jobs = Array.wrap Resque.peek(queue_name, 0, 0)
21
+ result = jobs
21
22
  .select { |j| j['args'].first['job_class'] == job_class.to_s }
22
23
  .flat_map { |j| j['args'] }
23
24
  return result unless block_given?
@@ -46,11 +47,7 @@ module ResqueJob
46
47
  end
47
48
 
48
49
  def fetch_result(job_id)
49
- res = Resque.redis.multi do
50
- key = result_key(job_id)
51
- Resque.redis.get key
52
- Resque.redis.del key
53
- end.first
50
+ res = Resque.redis.get result_key(job_id)
54
51
  JSON.parse(res) rescue res
55
52
  end
56
53
 
@@ -20,7 +20,7 @@ class StandardImporter
20
20
 
21
21
  private
22
22
 
23
- RE_EMPHASIS = /^\(\+\)\s?/
23
+ RE_EMPHASIS = /^\(\+\)\s?/.freeze
24
24
 
25
25
  attr_reader :source_file, :subject
26
26
 
@@ -45,10 +45,10 @@ class StandardImporter
45
45
 
46
46
  return grades if to_name.blank?
47
47
 
48
- from_idx = Grades::GRADES_ABBR.index from_name
49
- to_idx = Grades::GRADES_ABBR.index from_name
48
+ from_idx = Grades.grades_abbrevs.index from_name
49
+ to_idx = Grades.grades_abbrevs.index from_name
50
50
 
51
- Grades::GRADES_ABBR.slice(from_idx..to_idx).each { |name| grades << find_grade(name) }
51
+ Grades.grades_abbrevs.slice(from_idx..to_idx).each { |name| grades << find_grade(name) }
52
52
 
53
53
  grades.compact
54
54
  end