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.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -1
- data/.env.docker +1 -1
- data/.rubocop.yml +8 -7
- data/.ruby-version +1 -1
- data/CHANGELOG.md +16 -1
- data/Dockerfile +1 -1
- data/Gemfile.lock +223 -184
- data/README.md +3 -2
- data/app/controllers/concerns/lcms/engine/reimportable.rb +11 -1
- data/app/controllers/lcms/engine/admin/admin_controller.rb +1 -1
- data/app/controllers/lcms/engine/admin/documents_controller.rb +19 -4
- data/app/controllers/lcms/engine/admin/materials_controller.rb +12 -3
- data/app/controllers/lcms/engine/admin/standards_controller.rb +6 -1
- data/app/controllers/lcms/engine/admin/users_controller.rb +6 -1
- data/app/entities/lcms/engine/grades.rb +17 -6
- data/app/entities/lcms/engine/media_embed.rb +1 -1
- data/app/entities/lcms/engine/roman_numerals.rb +1 -1
- data/app/forms/lcms/engine/document_form.rb +19 -14
- data/app/forms/lcms/engine/material_form.rb +3 -2
- data/app/helpers/admin/components_helper.rb +2 -2
- data/app/helpers/lcms/engine/view_helper.rb +1 -1
- data/app/interactors/lcms/engine/explore_curriculum_interactor.rb +1 -1
- data/app/javascript/components/admin/ImportStatus.jsx +7 -3
- data/app/javascript/components/admin/MultiSelectedOperation.jsx +1 -0
- data/app/javascript/components/admin/association-picker/AssociationPicker.jsx +1 -0
- data/app/javascript/components/admin/association-picker/AssociationPickerResults.jsx +1 -0
- data/app/javascript/components/admin/association-picker/AssociationPickerWindow.jsx +1 -0
- data/app/javascript/components/admin/curriculum/CurriculumEditor.jsx +1 -0
- data/app/javascript/components/admin/resource-picker/ResourcePicker.jsx +1 -0
- data/app/jobs/concerns/lcms/engine/nested_resque_job.rb +1 -4
- data/app/jobs/lcms/engine/document_generate_gdoc_job.rb +2 -2
- data/app/jobs/lcms/engine/document_generate_job.rb +1 -1
- data/app/jobs/lcms/engine/document_parse_job.rb +1 -1
- data/app/models/lcms/engine/component.rb +3 -3
- data/app/models/lcms/engine/download.rb +1 -1
- data/app/models/lcms/engine/search/document.rb +4 -3
- data/app/presenters/lcms/engine/document_presenter.rb +2 -2
- data/app/queries/lcms/engine/admin_documents_query.rb +1 -1
- data/app/serializers/lcms/engine/previews_material_serializer.rb +1 -0
- data/app/services/lcms/engine/document_build_service.rb +4 -0
- data/app/services/lcms/engine/html_sanitizer.rb +5 -5
- data/app/services/lcms/engine/lessons_gdoc_bundler.rb +1 -1
- data/app/services/lcms/engine/material_build_service.rb +6 -2
- data/app/services/lcms/engine/material_preview_generator.rb +2 -2
- data/app/services/lcms/engine/react_materials_resolver.rb +3 -2
- data/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/curriculums/edit.html.erb +1 -3
- data/app/views/lcms/engine/admin/documents/_materials_links.html.erb +2 -2
- data/app/views/lcms/engine/admin/documents/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/documents/index.html.erb +2 -2
- data/app/views/lcms/engine/admin/documents/new.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/admin/materials/index.html.erb +4 -4
- data/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +1 -1
- data/app/views/lcms/engine/admin/resources/_fields.html.erb +3 -0
- data/app/views/lcms/engine/admin/resources/_search_form.html.erb +1 -1
- data/app/views/lcms/engine/documents/gdoc/_agenda.html.erb +1 -1
- data/app/views/lcms/engine/documents/show.html.erb +1 -1
- data/app/views/lcms/engine/materials/show.html.erb +1 -1
- data/app/views/lcms/engine/resources/_download.html.erb +2 -2
- data/app/views/lcms/engine/resources/_unit_bundles.html.erb +2 -2
- data/config/locales/admin/en.yml +1 -1
- data/db/schema.rb +1 -1
- data/lcms-engine.gemspec +12 -10
- data/lib/doc_template.rb +1 -1
- data/lib/doc_template/objects/agenda_metadata.rb +1 -1
- data/lib/doc_template/objects/metadata_helpers.rb +1 -1
- data/lib/doc_template/objects/toc_metadata.rb +2 -2
- data/lib/doc_template/tables/base.rb +3 -2
- data/lib/doc_template/tags/activity_metadata_type_tag.rb +1 -1
- data/lib/doc_template/tags/answer_space_tag.rb +1 -1
- data/lib/doc_template/tags/base_tag.rb +3 -3
- data/lib/doc_template/tags/columns_tag.rb +1 -1
- data/lib/doc_template/tags/def_tag.rb +1 -1
- data/lib/doc_template/tags/expand_tag.rb +1 -0
- data/lib/doc_template/tags/heading_tag.rb +1 -1
- data/lib/doc_template/tags/inset_tag.rb +2 -2
- data/lib/doc_template/tags/latex_tag.rb +1 -1
- data/lib/doc_template/tags/page_break_tag.rb +1 -1
- data/lib/doc_template/tags/pd_tag.rb +4 -4
- data/lib/doc_template/tags/section_tag.rb +2 -2
- data/lib/doc_template/tags/standard_tag.rb +3 -3
- data/lib/doc_template/tags/table_preserve_alignment_tag.rb +1 -1
- data/lib/document_exporter/gdoc/base.rb +1 -1
- data/lib/document_renderer/part.rb +3 -3
- data/lib/elasticsearch/persistence/repository/response/results.rb +1 -1
- data/lib/lcms/engine/engine.rb +1 -1
- data/lib/lcms/engine/version.rb +1 -1
- data/lib/lt/lcms/metadata/base_service.rb +2 -1
- data/lib/lt/lcms/metadata/context.rb +2 -2
- data/lib/lt/lcms/metadata/service.rb +3 -1
- data/lib/resque_job.rb +3 -6
- data/lib/standard_importer.rb +4 -4
- data/lib/tasks/cloud66.rake +6 -4
- data/lib/tasks/document.rake +3 -3
- data/lib/tasks/google.rake +1 -1
- data/package.json +1 -0
- data/spec/controllers/admin/association_picker_controller_spec.rb +6 -8
- data/spec/controllers/admin/documents_controller_spec.rb +3 -1
- data/spec/controllers/admin/materials_controller_spec.rb +1 -1
- data/spec/controllers/admin/resources_controller_spec.rb +2 -2
- data/spec/dummy/.env.docker +5 -0
- data/spec/dummy/config/environments/production.rb +1 -1
- data/spec/dummy/config/puma.rb +3 -3
- data/spec/entities/grades_spec.rb +12 -0
- data/spec/features/admin/lessons/add_lesson_spec.rb +3 -3
- data/spec/features/admin/materials/add_material_spec.rb +3 -3
- data/spec/forms/document_form_spec.rb +11 -1
- data/spec/lib/doc_template/tables/shared_examples/remove_table.rb +1 -1
- data/spec/rails_helper.rb +19 -2
- data/spec/services/document_build_service_spec.rb +1 -1
- data/yarn.lock +145 -170
- 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="
|
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
|
-
|
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="
|
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="
|
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="
|
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="
|
17
|
+
<i class="fab fa-google"></i>
|
18
18
|
<% end %>
|
19
19
|
<% else %>
|
20
20
|
<span class="o-unit-bundles__item--placeholder"></span>
|
data/config/locales/admin/en.yml
CHANGED
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.
|
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 '
|
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', '
|
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.
|
56
|
-
s.add_dependency 'lt-lcms', '~> 0.
|
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.
|
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.
|
100
|
-
s.add_development_dependency '
|
101
|
-
s.add_development_dependency '
|
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(., "[")]'
|
@@ -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
|
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
|
|
@@ -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}[[
|
19
|
+
@tag_with_html_regexp ||= /\[[^\]]*#{self::TAG_NAME}[[^:,;.]]*:?\s?[^\]]*\]/i
|
20
20
|
end
|
21
21
|
|
22
22
|
def template_path_for(name)
|
@@ -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)
|
@@ -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']
|
32
|
-
el['class'] = el['class']
|
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,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)\.[^\]]+)
|
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
|
@@ -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
|
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
|
|
data/lib/lcms/engine/engine.rb
CHANGED
@@ -67,7 +67,7 @@ module Lcms
|
|
67
67
|
next unless ActiveRecord::Base.connection
|
68
68
|
|
69
69
|
Dir
|
70
|
-
.glob(Rails.root
|
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!'
|
data/lib/lcms/engine/version.rb
CHANGED
@@ -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
|
|