Skip to content

Commit

Permalink
add support for Rails 6, Hyrax 4, and Blacklight 7 (#782)
Browse files Browse the repository at this point in the history
* add support for Rails 6, Hyrax 4, and Blacklight 7

this makes no attempt to ensure UI-layer support for BL7 and whatever bootstrap
versions it requires (excepting whatever is tested by RSpec). the scope here is
simply to make it *possible* for a Hyrax 4 application to install and use
Bulkrax.

* include current Hyrax CSS class and onclick in sidebar additions

* change `.hidden` css classes to `.d-none`

* bootstrap upgrade nav-link classes

* update dry-monads to ~> 1.5.0

* re-run rubocop

* begin testing on ruby 3, drop support for 2.6

* no more auto foreign key

* update schema in test app

* add support for Rails 6, Hyrax 4, and Blacklight 7

this makes no attempt to ensure UI-layer support for BL7 and whatever bootstrap
versions it requires (excepting whatever is tested by RSpec). the scope here is
simply to make it *possible* for a Hyrax 4 application to install and use
Bulkrax.

* include current Hyrax CSS class and onclick in sidebar additions

* change `.hidden` css classes to `.d-none`

* bootstrap upgrade nav-link classes

* update dry-monads to ~> 1.5.0

* re-run rubocop

* begin testing on ruby 3, drop support for 2.6

* no more auto foreign key

* update schema in test app

* trying to talk ci in to passing

* add support for Rails 6, Hyrax 4, and Blacklight 7

this makes no attempt to ensure UI-layer support for BL7 and whatever bootstrap
versions it requires (excepting whatever is tested by RSpec). the scope here is
simply to make it *possible* for a Hyrax 4 application to install and use
Bulkrax.

* include current Hyrax CSS class and onclick in sidebar additions

* change `.hidden` css classes to `.d-none`

* bootstrap upgrade nav-link classes

* update dry-monads to ~> 1.5.0

* re-run rubocop

* begin testing on ruby 3, drop support for 2.6

* no more auto foreign key

* update schema in test app

* trying to talk ci in to passing

* deal with differences in rails spec db handling for rails 6

---------

Co-authored-by: Alexandra Dunn <dunn.alex@gmail.com>
Co-authored-by: Rob Kaufman <rob@notch8.com>
  • Loading branch information
3 people authored Oct 31, 2023
1 parent 1c39f9f commit 657c6fe
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 138 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
uses: actions/cache@v2.1.3
with:
path: vendor/bundle
key: 2.6.5
key: 2.7.2

- name: Setup Ruby
uses: ruby/setup-ruby@v1.59.1
uses: ruby/setup-ruby@v1.159.0
with:
ruby-version: 2.6.5
ruby-version: 2.7.2

- name: Install dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['2.6', '2.7'] # TODO add 3.0 compat , '3.0']
ruby: ['2.7', '3.0']
name: Run specs with ruby ${{ matrix.ruby }}
steps:
- uses: actions/checkout@v2
Expand All @@ -24,7 +24,7 @@ jobs:
key: ${{ matrix.ruby }}

- name: Setup Ruby
uses: ruby/setup-ruby@v1.59.1
uses: ruby/setup-ruby@v1.159.0
with:
ruby-version: ${{ matrix.ruby }}

Expand All @@ -37,10 +37,10 @@ jobs:
bundle install
- name: Migrate test database
run: bin/rails db:migrate RAILS_ENV=test
run: bundle exec rake db:migrate db:test:prepare

- name: Run rspec
run: bin/rspec
run: bundle exec rake

- name: Upload coverage results
uses: actions/upload-artifact@v2
Expand Down
98 changes: 8 additions & 90 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,13 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'app/jobs/bulkrax/import_file_set_job.rb'
- 'app/models/bulkrax/entry.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Exclude:
- 'spec/rails_helper.rb'

# Offense count: 3
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'app/parsers/bulkrax/csv_parser.rb'
- 'spec/models/bulkrax/rdf_entry_spec.rb'
- 'spec/models/bulkrax/xml_entry_spec.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'spec/rails_helper.rb'

# Offense count: 8
# Offense count: 5
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 301

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'app/parsers/bulkrax/csv_parser.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Layout/RescueEnsureAlignment:
Exclude:
- 'spec/rails_helper.rb'

# Offense count: 7
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Exclude:
- 'app/models/bulkrax/csv_entry.rb'
- 'app/parsers/bulkrax/csv_parser.rb'
- 'spec/models/bulkrax/rdf_entry_spec.rb'
- 'spec/models/bulkrax/xml_entry_spec.rb'
- 'spec/rails_helper.rb'

# Offense count: 16
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Expand All @@ -81,24 +21,24 @@ Metrics/AbcSize:
# Offense count: 4
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 201
Max: 140

# Offense count: 13
# Offense count: 12
# Configuration parameters: IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 19

# Offense count: 32
# Offense count: 28
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
Metrics/MethodLength:
Max: 26

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ModuleLength:
Max: 131
Max: 130

# Offense count: 9
# Offense count: 10
# Configuration parameters: IgnoredMethods.
Metrics/PerceivedComplexity:
Max: 19
Expand All @@ -110,30 +50,8 @@ Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/concerns/bulkrax/status_info.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
# Configuration parameters: Keywords, RequireColon.
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW, NOTE
Style/CommentAnnotation:
Exclude:
- 'app/models/bulkrax/xml_entry.rb'
- 'spec/models/bulkrax/oai_entry_spec.rb'

# Offense count: 2
# This cop supports safe auto-correction (--auto-correct).
Style/IfUnlessModifier:
Exclude:
- 'app/models/bulkrax/csv_entry.rb'
- 'lib/generators/bulkrax/templates/config/initializers/bulkrax.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Style/MultilineIfModifier:
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
Style/GuardClause:
Exclude:
- 'app/models/bulkrax/csv_entry.rb'

# Offense count: 1
# This cop supports safe auto-correction (--auto-correct).
Style/RedundantBegin:
Exclude:
- 'spec/rails_helper.rb'
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ gemspec
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

gem 'blacklight', '~> 6.25.0'
gem 'blacklight'
gem 'bootstrap-sass', '~> 3.4.1'
gem 'coderay'
gem 'factory_bot_rails'
gem 'hyrax', '>= 2.3'
gem 'hyrax', '>= 2.3', '< 4.999'
gem 'oai'
gem 'rsolr', '>= 1.0'
gem 'rspec-rails'
Expand All @@ -29,6 +29,7 @@ group :development, :test do
gem 'pry-byebug'
gem 'solargraph'
gem 'solr_wrapper', '>= 0.3'
gem 'sqlite3', '~> 1.4'
end

group :lint do
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Once your the exporter has run, a download icon will appear on the exporters men

## Compatibility

* Ruby 2.6 or 2.7 is required
* Ruby 2.7 or newer is required
* Hyrax 2.3 or newer is required

## Contributing
Expand Down
10 changes: 5 additions & 5 deletions app/assets/javascripts/bulkrax/exporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function hideUnhide(field) {
}
};

function addRequired(selectedSource) {
function addRequired(selectedSource) {
selectedSource.addClass('required').attr('required', 'required');
selectedSource.parent().addClass('required');
}
Expand All @@ -26,14 +26,14 @@ function removeRequired(allSources) {

// hide all export_source
function hide(allSources) {
allSources.addClass('hidden');
allSources.find('#exporter_export_source').addClass('hidden').attr('type', 'hidden');
allSources.addClass('d-none');
allSources.find('#exporter_export_source').addClass('.d-none').attr('type', 'd-none');
}

// unhide selected export_source
function unhideSelected(selectedSource) {
selectedSource.removeClass('hidden').removeAttr('type');
selectedSource.parent().removeClass('hidden').removeAttr('type');
selectedSource.removeClass('d-none').removeAttr('type');
selectedSource.parent().removeClass('d-none').removeAttr('type');
};

// add the autocomplete javascript
Expand Down
2 changes: 1 addition & 1 deletion app/factories/bulkrax/object_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def search_by_identifier
def create
attrs = transform_attributes
@object = klass.new
object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if object.respond_to?(:reindex_extent)
object.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if defined?(Hyrax::Adapters::NestingIndexAdapter) && object.respond_to?(:reindex_extent)
run_callbacks :save do
run_callbacks :create do
if klass == Collection
Expand Down
3 changes: 2 additions & 1 deletion app/jobs/bulkrax/create_relationships_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def process(relationship:, importer_run_id:, parent_record:, ability:)
end

def add_to_collection(child_record, parent_record)
parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX)
parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if
defined?(Hyrax::Adapters::NestingIndexAdapter)
child_record.member_of_collections << parent_record
child_record.save!
end
Expand Down
6 changes: 4 additions & 2 deletions app/models/bulkrax/csv_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ def build_metadata

def validate_record
raise StandardError, 'Record not found' if record.nil?
raise StandardError, "Missing required elements, missing element(s) are: "\
"#{importerexporter.parser.missing_elements(record).join(', ')}" unless importerexporter.parser.required_elements?(record)
unless importerexporter.parser.required_elements?(record)
raise StandardError, "Missing required elements, missing element(s) are: "\
"#{importerexporter.parser.missing_elements(record).join(', ')}"
end
end

def add_identifier
Expand Down
3 changes: 2 additions & 1 deletion app/services/bulkrax/remove_relationships_for_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def break_relationships!
remove_relationships_from_work(obj)
end

obj.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if defined?(Hyrax)
obj.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX) if
defined?(Hyrax::Adapters::NestingIndexAdapter)
obj.save!
end
end
Expand Down
20 changes: 10 additions & 10 deletions app/views/bulkrax/exporters/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
label: t('bulkrax.exporter.labels.importer'),
required: true,
prompt: 'Select from the list',
label_html: { class: 'importer export-source-option hidden' },
input_html: { class: 'importer export-source-option hidden form-control' },
label_html: { class: 'importer export-source-option d-none' },
input_html: { class: 'importer export-source-option d-none form-control' },
collection: form.object.importers_list.sort %>

<%= form.input :export_source_collection,
prompt: 'Start typing ...',
label: t('bulkrax.exporter.labels.collection'),
required: true,
placeholder: @collection&.title&.first,
label_html: { class: 'collection export-source-option hidden' },
label_html: { class: 'collection export-source-option d-none' },
input_html: {
class: 'collection export-source-option hidden form-control',
class: 'collection export-source-option d-none form-control',
data: {
'autocomplete-url' => '/authorities/search/collections',
'autocomplete' => 'collection'
Expand All @@ -56,8 +56,8 @@
label: t('bulkrax.exporter.labels.worktype'),
required: true,
prompt: 'Select from the list',
label_html: { class: 'worktype export-source-option hidden' },
input_html: { class: 'worktype export-source-option hidden form-control' },
label_html: { class: 'worktype export-source-option d-none' },
input_html: { class: 'worktype export-source-option d-none form-control' },
collection: Bulkrax.curation_concerns.map { |cc| [cc.to_s, cc.to_s] } %>

<%= form.input :limit,
Expand All @@ -80,7 +80,7 @@
as: :boolean,
label: t('bulkrax.exporter.labels.filter_by_date') %>

<div id="date_filter_picker" class="hidden">
<div id="date_filter_picker" class="d-none">
<%= form.input :start_date,
as: :date,
label: t('bulkrax.exporter.labels.start_date'),
Expand Down Expand Up @@ -136,13 +136,13 @@
// get the date filter option and show the corresponding date selectors
$('.exporter_date_filter').change(function () {
if ($('.exporter_date_filter').find(".boolean").is(":checked"))
$('#date_filter_picker').removeClass('hidden');
$('#date_filter_picker').removeClass('d-none');
else
$('#date_filter_picker').addClass('hidden');
$('#date_filter_picker').addClass('d-none');
});

if ($('.exporter_date_filter').find(".boolean").is(":checked"))
$('#date_filter_picker').removeClass('hidden');
$('#date_filter_picker').removeClass('d-none');
});
});
</script>
6 changes: 3 additions & 3 deletions app/views/bulkrax/exporters/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@
<div class="bulkrax-nav-tab-bottom-margin">
<!-- Nav tabs -->
<ul class="bulkrax-nav-tab-top-margin tab-nav nav nav-tabs" role="tablist">
<li role="presentation" class='active'><a href="#work-entries" aria-controls="work-entries" role="tab" data-toggle="tab"><%= t('bulkrax.exporter.labels.work_entries') %></a></li>
<li role="presentation"><a href="#collection-entries" aria-controls="collection-entries" role="tab" data-toggle="tab"><%= t('bulkrax.exporter.labels.collection_entries') %></a></li>
<li role="presentation"><a href="#file-set-entries" aria-controls="file-set-entries" role="tab" data-toggle="tab"><%= t('bulkrax.exporter.labels.file_set_entries') %></a></li>
<li role="presentation" class="nav-link active"><a href="#work-entries" aria-controls="work-entries" role="tab" data-toggle="tab"><%= t('bulkrax.exporter.labels.work_entries') %></a></li>
<li role="presentation" class="nav-link"><a href="#collection-entries" aria-controls="collection-entries" role="tab" data-toggle="tab"><%= t('bulkrax.exporter.labels.collection_entries') %></a></li>
<li role="presentation" class="nav-link"><a href="#file-set-entries" aria-controls="file-set-entries" role="tab" data-toggle="tab"><%= t('bulkrax.exporter.labels.file_set_entries') %></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content outline">
Expand Down
6 changes: 3 additions & 3 deletions app/views/bulkrax/importers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
<div class="bulkrax-nav-tab-bottom-margin">
<!-- Nav tabs -->
<ul class="bulkrax-nav-tab-top-margin tab-nav nav nav-tabs" role="tablist">
<li role="presentation" class='active'><a href="#work-entries" aria-controls="work-entries" role="tab" data-toggle="tab"><%= t('bulkrax.importer.labels.work_entries') %></a></li>
<li role="presentation"><a href="#collection-entries" aria-controls="collection-entries" role="tab" data-toggle="tab"><%= t('bulkrax.importer.labels.collection_entries') %></a></li>
<li role="presentation"><a href="#file-set-entries" aria-controls="file-set-entries" role="tab" data-toggle="tab"><%= t('bulkrax.importer.labels.file_set_entries') %></a></li>
<li role="presentation" class="nav-link active"><a href="#work-entries" aria-controls="work-entries" role="tab" data-toggle="tab"><%= t('bulkrax.importer.labels.work_entries') %></a></li>
<li role="presentation" class="nav-link"><a href="#collection-entries" aria-controls="collection-entries" role="tab" data-toggle="tab"><%= t('bulkrax.importer.labels.collection_entries') %></a></li>
<li role="presentation" class="nav-link"><a href="#file-set-entries" aria-controls="file-set-entries" role="tab" data-toggle="tab"><%= t('bulkrax.importer.labels.file_set_entries') %></a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content outline">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<% if current_ability.can_import_works? %>
<%= menu.nav_link(bulkrax.importers_path,
title: t('bulkrax.admin.sidebar.importers')) do %>
<%= menu.nav_link(
bulkrax.importers_path,
title: t('bulkrax.admin.sidebar.importers'),
class: "nav-link",
onclick: "dontChangeAccordion(event);")
) do %>
<span class="fa fa-cloud-upload" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.importers') %></span>
<% end %>
<% end %>
<% if current_ability.can_export_works? %>
<%= menu.nav_link(bulkrax.exporters_path,
title: t('bulkrax.admin.sidebar.exporters')) do %>
<%= menu.nav_link(
bulkrax.exporters_path,
title: t('bulkrax.admin.sidebar.exporters'),
class: "nav-link",
onclick: "dontChangeAccordion(event);")
) do %>
<span class="fa fa-cloud-download" aria-hidden="true"></span> <span class="sidebar-action-text"><%= t('bulkrax.admin.sidebar.exporters') %></span>
<% end %>
<% end %>
Loading

0 comments on commit 657c6fe

Please sign in to comment.