lcms-engine 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +1 -1
  3. data/.env.docker +1 -1
  4. data/.rubocop.yml +8 -7
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +16 -1
  7. data/Dockerfile +1 -1
  8. data/Gemfile.lock +223 -184
  9. data/README.md +3 -2
  10. data/app/controllers/concerns/lcms/engine/reimportable.rb +11 -1
  11. data/app/controllers/lcms/engine/admin/admin_controller.rb +1 -1
  12. data/app/controllers/lcms/engine/admin/documents_controller.rb +19 -4
  13. data/app/controllers/lcms/engine/admin/materials_controller.rb +12 -3
  14. data/app/controllers/lcms/engine/admin/standards_controller.rb +6 -1
  15. data/app/controllers/lcms/engine/admin/users_controller.rb +6 -1
  16. data/app/entities/lcms/engine/grades.rb +17 -6
  17. data/app/entities/lcms/engine/media_embed.rb +1 -1
  18. data/app/entities/lcms/engine/roman_numerals.rb +1 -1
  19. data/app/forms/lcms/engine/document_form.rb +19 -14
  20. data/app/forms/lcms/engine/material_form.rb +3 -2
  21. data/app/helpers/admin/components_helper.rb +2 -2
  22. data/app/helpers/lcms/engine/view_helper.rb +1 -1
  23. data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +1 -1
  24. data/app/javascript/components/admin/ImportStatus.jsx +7 -3
  25. data/app/javascript/components/admin/MultiSelectedOperation.jsx +1 -0
  26. data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +1 -0
  27. data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +1 -0
  28. data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +1 -0
  29. data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +1 -0
  30. data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +1 -0
  31. data/app/jobs/concerns/lcms/engine/nested_resque_job.rb +1 -4
  32. data/app/jobs/lcms/engine/document_generate_gdoc_job.rb +2 -2
  33. data/app/jobs/lcms/engine/document_generate_job.rb +1 -1
  34. data/app/jobs/lcms/engine/document_parse_job.rb +1 -1
  35. data/app/models/lcms/engine/component.rb +3 -3
  36. data/app/models/lcms/engine/download.rb +1 -1
  37. data/app/models/lcms/engine/search/document.rb +4 -3
  38. data/app/presenters/lcms/engine/document_presenter.rb +2 -2
  39. data/app/queries/lcms/engine/admin_documents_query.rb +1 -1
  40. data/app/serializers/lcms/engine/previews_material_serializer.rb +1 -0
  41. data/app/services/lcms/engine/document_build_service.rb +4 -0
  42. data/app/services/lcms/engine/html_sanitizer.rb +5 -5
  43. data/app/services/lcms/engine/lessons_gdoc_bundler.rb +1 -1
  44. data/app/services/lcms/engine/material_build_service.rb +6 -2
  45. data/app/services/lcms/engine/material_preview_generator.rb +2 -2
  46. data/app/services/lcms/engine/react_materials_resolver.rb +3 -2
  47. data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +1 -1
  48. data/app/views/lcms/engine/admin/curriculums/edit.html.erb +1 -3
  49. data/app/views/lcms/engine/admin/documents/_materials_links.html.erb +2 -2
  50. data/app/views/lcms/engine/admin/documents/_search_form.html.erb +1 -1
  51. data/app/views/lcms/engine/admin/documents/index.html.erb +2 -2
  52. data/app/views/lcms/engine/admin/documents/new.html.erb +1 -1
  53. data/app/views/lcms/engine/admin/materials/_search_form.html.erb +1 -1
  54. data/app/views/lcms/engine/admin/materials/index.html.erb +4 -4
  55. data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +1 -1
  56. data/app/views/lcms/engine/admin/resources/_fields.html.erb +3 -0
  57. data/app/views/lcms/engine/admin/resources/_search_form.html.erb +1 -1
  58. data/app/views/lcms/engine/documents/gdoc/_agenda.html.erb +1 -1
  59. data/app/views/lcms/engine/documents/show.html.erb +1 -1
  60. data/app/views/lcms/engine/materials/show.html.erb +1 -1
  61. data/app/views/lcms/engine/resources/_download.html.erb +2 -2
  62. data/app/views/lcms/engine/resources/_unit_bundles.html.erb +2 -2
  63. data/config/locales/admin/en.yml +1 -1
  64. data/db/schema.rb +1 -1
  65. data/lcms-engine.gemspec +12 -10
  66. data/lib/doc_template.rb +1 -1
  67. data/lib/doc_template/objects/agenda_metadata.rb +1 -1
  68. data/lib/doc_template/objects/metadata_helpers.rb +1 -1
  69. data/lib/doc_template/objects/toc_metadata.rb +2 -2
  70. data/lib/doc_template/tables/base.rb +3 -2
  71. data/lib/doc_template/tags/activity_metadata_type_tag.rb +1 -1
  72. data/lib/doc_template/tags/answer_space_tag.rb +1 -1
  73. data/lib/doc_template/tags/base_tag.rb +3 -3
  74. data/lib/doc_template/tags/columns_tag.rb +1 -1
  75. data/lib/doc_template/tags/def_tag.rb +1 -1
  76. data/lib/doc_template/tags/expand_tag.rb +1 -0
  77. data/lib/doc_template/tags/heading_tag.rb +1 -1
  78. data/lib/doc_template/tags/inset_tag.rb +2 -2
  79. data/lib/doc_template/tags/latex_tag.rb +1 -1
  80. data/lib/doc_template/tags/page_break_tag.rb +1 -1
  81. data/lib/doc_template/tags/pd_tag.rb +4 -4
  82. data/lib/doc_template/tags/section_tag.rb +2 -2
  83. data/lib/doc_template/tags/standard_tag.rb +3 -3
  84. data/lib/doc_template/tags/table_preserve_alignment_tag.rb +1 -1
  85. data/lib/document_exporter/gdoc/base.rb +1 -1
  86. data/lib/document_renderer/part.rb +3 -3
  87. data/lib/elasticsearch/persistence/repository/response/results.rb +1 -1
  88. data/lib/lcms/engine/engine.rb +1 -1
  89. data/lib/lcms/engine/version.rb +1 -1
  90. data/lib/lt/lcms/metadata/base_service.rb +2 -1
  91. data/lib/lt/lcms/metadata/context.rb +2 -2
  92. data/lib/lt/lcms/metadata/service.rb +3 -1
  93. data/lib/resque_job.rb +3 -6
  94. data/lib/standard_importer.rb +4 -4
  95. data/lib/tasks/cloud66.rake +6 -4
  96. data/lib/tasks/document.rake +3 -3
  97. data/lib/tasks/google.rake +1 -1
  98. data/package.json +1 -0
  99. data/spec/controllers/admin/association_picker_controller_spec.rb +6 -8
  100. data/spec/controllers/admin/documents_controller_spec.rb +3 -1
  101. data/spec/controllers/admin/materials_controller_spec.rb +1 -1
  102. data/spec/controllers/admin/resources_controller_spec.rb +2 -2
  103. data/spec/dummy/.env.docker +5 -0
  104. data/spec/dummy/config/environments/production.rb +1 -1
  105. data/spec/dummy/config/puma.rb +3 -3
  106. data/spec/entities/grades_spec.rb +12 -0
  107. data/spec/features/admin/lessons/add_lesson_spec.rb +3 -3
  108. data/spec/features/admin/materials/add_material_spec.rb +3 -3
  109. data/spec/forms/document_form_spec.rb +11 -1
  110. data/spec/lib/doc_template/tables/shared_examples/remove_table.rb +1 -1
  111. data/spec/rails_helper.rb +19 -2
  112. data/spec/services/document_build_service_spec.rb +1 -1
  113. data/yarn.lock +145 -170
  114. metadata +81 -34
@@ -11,7 +11,7 @@
11
11
  <td class="u-text--right o-agenda__item"><p>TIME</p></td>
12
12
  </tr>
13
13
  <% document.toc.children.each do |l1| %>
14
- <% l1_excluded = l1.excluded?(excludes, document.ela?) %>
14
+ <% l1_excluded = l1.excluded?(excludes, ela: document.ela?) %>
15
15
  <% l1_time = l1_excluded ? l1.time : l1.time_with(excludes) %>
16
16
  <tr class="<%= 'u-text--strikethrough' if l1_excluded %>">
17
17
  <td colspan="3" class="u-txt--agenda-l1-title o-agenda__item">
@@ -14,7 +14,7 @@
14
14
  Go to Lessons Admin
15
15
  <% end %>
16
16
  <%= link_to @document.file_url, class: 'o-ub-ld-btn o-ub-ld-btn--bordered', target: '_blank' do %>
17
- <i class="ub-icon ub-file-gdoc"></i> Google Doc
17
+ <i class="fab fa-google"></i> Google Doc
18
18
  <% end %>
19
19
  <%= render partial: 'lcms/engine/admin/documents/reimport', locals: { lesson: @document, btn_class: 'o-ub-ld-btn o-ub-ld-btn--bordered' } %>
20
20
 
@@ -6,7 +6,7 @@
6
6
  <div>
7
7
  <%= link_to 'Go to Materials Admin', admin_materials_path(request.query_parameters), class: 'button primary u-margin-right--base' %>
8
8
  <%= link_to @material.file_url, class: 'button primary u-margin-right--base', target: '_blank' do %>
9
- <i class="ub-icon ub-file-gdoc"></i> Google Doc
9
+ <i class="fab fa-google"></i> Google Doc
10
10
  <% end %>
11
11
  <%= render partial: 'lcms/engine/admin/materials/reimport', locals: { material: @material, btn_size: 'default' } %>
12
12
  </div>
@@ -3,14 +3,14 @@
3
3
  <span>
4
4
  <%= link_to preview_download_path(id: download, slug: resource.slug), class: 'resource-attachment',
5
5
  data: { no_turbolink: true }, target: '_blank' do %>
6
- <i class="ub-icon ub-eye" aria-hidden="true"></i>
6
+ <i class="fas fa-eye" aria-hidden="true"></i>
7
7
  <% end %>
8
8
  </span>
9
9
  <% end %>
10
10
  <% id = SecureRandom.hex(4) %>
11
11
  <span data-toggle="<%= id %>">
12
12
  <%= link_to download_path(download, slug: resource.slug), class: 'resource-attachment', data: { no_turbolink: true } do %>
13
- <i class="ub-icon fa-lg file-<%= "#{file_icon(download.download.attachment_content_type)} #{indent}" %>"></i>
13
+ <i class="far fa-file-<%= "#{file_icon(download.download.attachment_content_type)} #{indent}" %>"></i>
14
14
  <%= download.download.title %>
15
15
  <% end %>
16
16
  </span>
@@ -9,12 +9,12 @@
9
9
  <li class="o-unit-bundles__item">
10
10
  <div class="o-unit-bundles__item--links">
11
11
  <%= link_to bundle.file&.url, data: { no_turbolink: true } do %>
12
- <i class="ub-icon fa-lg ub-file-zip"></i>
12
+ <i class="far fa-file-archive"></i>
13
13
  <% end %>
14
14
  <% if (gdoc_bundle = resource.document_bundles.detect { |b| b.content_type == 'gdoc' }) %>
15
15
  <% if cat == 'full' %>
16
16
  <%= link_to gdoc_bundle.url, target: '_blank', data: { no_turbolink: true } do %>
17
- <i class="ub-icon fa-lg ub-file-gdoc"></i>
17
+ <i class="fab fa-google"></i>
18
18
  <% end %>
19
19
  <% else %>
20
20
  <span class="o-unit-bundles__item--placeholder"></span>
@@ -216,7 +216,7 @@ en:
216
216
  unit_bundles: Generate Unit Bundles
217
217
  create:
218
218
  error: Error
219
- success: Lesson %{name} parsed successfully.
219
+ success: Lesson %{name} parsed successfully. %{errors}
220
220
  new:
221
221
  page_title: Add a lesson
222
222
  submit: Parse
data/db/schema.rb CHANGED
@@ -14,8 +14,8 @@
14
14
  ActiveRecord::Schema.define(version: 0) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
- enable_extension "plpgsql"
18
17
  enable_extension "hstore"
18
+ enable_extension "plpgsql"
19
19
 
20
20
  create_table "access_codes", force: :cascade do |t|
21
21
  t.string "code", null: false
data/lcms-engine.gemspec CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.files = `git ls-files`.split("\n")
20
20
  s.test_files = `git ls-files -- spec/*`.split("\n")
21
21
 
22
- s.required_ruby_version = '>= 2.5'
22
+ s.required_ruby_version = '>= 2.6'
23
23
 
24
- s.add_dependency 'active_model_serializers', '~> 0.10.10'
25
24
  s.add_dependency 'activejob-retry', '~> 0.6.3'
26
- s.add_dependency 'acts-as-taggable-on', '~> 6.5'
25
+ s.add_dependency 'active_model_serializers', '~> 0.10.10'
27
26
  s.add_dependency 'acts_as_list', '~> 1.0'
27
+ s.add_dependency 'acts-as-taggable-on', '~> 6.5'
28
28
  s.add_dependency 'addressable', '~> 2.7'
29
29
  s.add_dependency 'airbrake', '~> 10.0'
30
30
  s.add_dependency 'autoprefixer-rails', '~> 9.7'
@@ -46,14 +46,14 @@ Gem::Specification.new do |s|
46
46
  s.add_dependency 'fog-aws', '~> 3.5', '>= 3.5.2'
47
47
  s.add_dependency 'font-awesome-sass', '~> 5.12'
48
48
  s.add_dependency 'foundation-rails', '~> 6.6', '>= 6.6.1'
49
- s.add_dependency 'google-api-client', '~> 0.37.1'
49
+ s.add_dependency 'google-api-client', '< 1'
50
50
  s.add_dependency 'hiredis', '~> 0.6.3'
51
51
  s.add_dependency 'httparty', '~> 0.18'
52
52
  s.add_dependency 'jbuilder', '~> 2.10'
53
53
  s.add_dependency 'jquery-rails', '~> 4.3', '>= 4.3.5'
54
54
  s.add_dependency 'js-routes', '~> 1.4', '>= 1.4.9'
55
- s.add_dependency 'lt-google-api', '~> 0.1.1'
56
- s.add_dependency 'lt-lcms', '~> 0.3'
55
+ s.add_dependency 'lt-google-api', '~> 0.2', '>= 0.2.2'
56
+ s.add_dependency 'lt-lcms', '~> 0.4', '>= 0.4.1'
57
57
  s.add_dependency 'migration_data', '~> 0.6'
58
58
  s.add_dependency 'mini_magick', '~> 4.10', '>= 4.10.1'
59
59
  s.add_dependency 'nested_form', '~> 0.3.2'
@@ -92,13 +92,15 @@ Gem::Specification.new do |s|
92
92
  s.add_development_dependency 'email_spec', '~> 2.1'
93
93
  s.add_development_dependency 'factory_bot', '~> 5'
94
94
  s.add_development_dependency 'faker', '~> 2.1'
95
- s.add_development_dependency 'overcommit', '~> 0.49.1'
95
+ s.add_development_dependency 'overcommit', '~> 0.57'
96
96
  s.add_development_dependency 'pry-byebug', '~> 3.7'
97
97
  s.add_development_dependency 'pry-rails', '~> 0.3.5'
98
98
  s.add_development_dependency 'rspec-rails', '~> 3.8'
99
- s.add_development_dependency 'rubocop', '~> 0.59.2'
100
- s.add_development_dependency 'sdoc', '~> 1.1'
101
- s.add_development_dependency 'selenium-webdriver', '~> 3.142'
99
+ s.add_development_dependency 'rubocop', '~> 0.93.1'
100
+ s.add_development_dependency 'safe_attributes', '~> 1.0.10'
101
+ s.add_development_dependency 'sdoc', '~> 2'
102
+ s.add_development_dependency 'seedbank', '~> 0.3'
103
+ s.add_development_dependency 'selenium-webdriver', '~> 3.142', '>= 3.142.7'
102
104
  s.add_development_dependency 'shoulda-matchers', '~> 4.1'
103
105
  s.add_development_dependency 'spring', '~> 2.1'
104
106
  s.add_development_dependency 'spring-commands-rspec', '~> 1.0'
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(., "[")]'
@@ -62,7 +62,7 @@ module DocTemplate
62
62
 
63
63
  attribute :children, Array[Group]
64
64
 
65
- def self.build_from(data)
65
+ def self.build_from(data) # rubocop:disable Metrics/AbcSize
66
66
  copy = Marshal.load Marshal.dump(data)
67
67
  agenda_data =
68
68
  copy.map do |d|
@@ -3,7 +3,7 @@
3
3
  module DocTemplate
4
4
  module Objects
5
5
  module MetadataHelpers
6
- SEPARATOR = /\s*[,;]\s*/
6
+ SEPARATOR = /\s*[,;]\s*/.freeze
7
7
 
8
8
  def self.build_anchor_from(item)
9
9
  [
@@ -18,7 +18,7 @@ module DocTemplate
18
18
  attribute :time, Integer, default: 0
19
19
  attribute :title, String
20
20
 
21
- def excluded?(excludes, ela = false)
21
+ def excluded?(excludes, ela: false)
22
22
  # Do not exclude parent if all children are optional and deselected
23
23
  return false if ela && children.all?(&:optional)
24
24
  return excludes.exclude?(anchor) if optional
@@ -27,7 +27,7 @@ module DocTemplate
27
27
  children.any? && children.all? { |c| c.excluded?(excludes) }
28
28
  end
29
29
 
30
- def time_with(excludes)
30
+ def time_with(excludes) # rubocop:disable Metrics/PerceivedComplexity
31
31
  # Optional and nothing to exclude explicitly
32
32
  return excludes.include?(anchor) ? time : 0 if optional
33
33
  # General and excluded explicitly
@@ -3,9 +3,9 @@
3
3
  module DocTemplate
4
4
  module Tables
5
5
  class Base
6
- SPLIT_REGEX = /[,;\r\n]/
6
+ SPLIT_REGEX = /[,;\r\n]/.freeze
7
7
 
8
- attr_reader :data
8
+ attr_reader :errors, :data
9
9
 
10
10
  def self.parse(fragment, *args)
11
11
  new.parse(fragment, *args)
@@ -13,6 +13,7 @@ module DocTemplate
13
13
 
14
14
  def initialize
15
15
  @data = {}
16
+ @errors = []
16
17
  @table_exists = false
17
18
  end
18
19
 
@@ -7,7 +7,7 @@ module DocTemplate
7
7
  include ERB::Util
8
8
 
9
9
  TAG_NAME = 'activity-metadata-type'
10
- TASK_RE = /(\[task:\s(#)\])/i
10
+ TASK_RE = /(\[task:\s(#)\])/i.freeze
11
11
  TEMPLATES = {
12
12
  default: 'activity.html.erb',
13
13
  gdoc: 'gdoc/activity.html.erb'
@@ -6,7 +6,7 @@ module DocTemplate
6
6
  SPACE_SIZE = {
7
7
  s: 5, # small = 5 lines
8
8
  m: 10, # medium = 10 lines
9
- l: 20, # large = 20 lines
9
+ l: 20 # large = 20 lines
10
10
  }.freeze
11
11
  TAG_NAME = 'answer-space'
12
12
 
@@ -3,8 +3,8 @@
3
3
  module DocTemplate
4
4
  module Tags
5
5
  class BaseTag
6
- SOFT_RETURN_RE = /([[:graph:]]+\[|\][[:graph:]]+)/
7
- UNICODE_SPACES_RE = /(\u0020|\u00A0|\u1680|\u180E|[\u2000-\u200B]|\u202F|\u205F|\u3000|\uFEFF)/
6
+ SOFT_RETURN_RE = /([[:graph:]]+\[|\][[:graph:]]+)/.freeze
7
+ UNICODE_SPACES_RE = /(\u0020|\u00A0|\u1680|\u180E|[\u2000-\u200B]|\u202F|\u205F|\u3000|\uFEFF)/.freeze
8
8
 
9
9
  attr_reader :anchor, :content
10
10
 
@@ -16,7 +16,7 @@ module DocTemplate
16
16
  def tag_with_html_regexp
17
17
  raise NotImplementedError unless const_defined?(:TAG_NAME)
18
18
 
19
- @tag_with_html_regexp ||= /\[[^\]]*#{self::TAG_NAME}[[^\:,;.]]*:?\s?[^\]]*\]/i
19
+ @tag_with_html_regexp ||= /\[[^\]]*#{self::TAG_NAME}[[^:,;.]]*:?\s?[^\]]*\]/i
20
20
  end
21
21
 
22
22
  def template_path_for(name)
@@ -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 = {})
@@ -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
 
@@ -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,7 +26,7 @@ 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
32
  elsif @excludes.include?(part[:anchor])
@@ -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
 
@@ -67,7 +67,7 @@ module Lcms
67
67
  next unless ActiveRecord::Base.connection
68
68
 
69
69
  Dir
70
- .glob(Rails.root + 'app/decorators/**/*_decorator*.rb')
70
+ .glob("#{Rails.root}/app/decorators/**/*_decorator*.rb")
71
71
  .each(&method(:require_dependency))
72
72
  rescue ActiveRecord::NoDatabaseError
73
73
  puts 'ActiveRecord::NoDatabaseError thrown!'
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Lcms
4
4
  module Engine
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  RAILS_5_VERSION = 5.2
7
7
  end
8
8
  end
@@ -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