Skip to content

Commit

Permalink
update with latest from hyku_knapsack
Browse files Browse the repository at this point in the history
Ran `git merge prime/main` and resolved merge conflicts
  • Loading branch information
bkiahstroud committed Feb 13, 2025
1 parent d50af95 commit 6003b66
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-test-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
uses: scientist-softserv/actions/.github/workflows/[email protected]
with:
confdir: '/app/samvera/hyrax-webapp/solr/conf'
webTarget: hyku-web
workerTarget: hyku-worker
rspec_cmd: "cd .. && gem install semaphore_test_boosters && bundle && rspec_booster --job $CI_NODE_INDEX/$CI_NODE_TOTAL"

lint:
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ Theme files (views, css, etc) can be added in the the Knapsack. We recommend add

### Gems

It can be useful to add additional gems to the bundle. This can be done w/o editing Hyku by adding them to the [./bundler.d/example.rb](./bundler.d/example.rb]. [See the bundler-inject documentation for more details] on overriding and adding gems.
It can be useful to add additional gems to the bundle. This can be done w/o editing Hyku by adding them to the [./bundler.d/example.rb](./bundler.d/example.rb]. [See the bundler-inject documentation for more details](https://github.com/kbrock/bundler-inject/) on overriding and adding gems.

**NOTE:** Do not add gems to the gemspec nor Gemfile. When you add to the knapsack Gemfile/gemspec, when you bundle, you'll update the Hyku Gemfile; which will mean you might be updating Hyku prime with knapsack installation specific dependencies. Instead add gems to `./bundler.d/example.rb`.

## Converting a Fork of Hyku Prime to a Knapsack

Expand Down
1 change: 1 addition & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby

# frozen_string_literal: true
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot'
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/hyrax.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

# Use this to override any Hyrax configuration from the Knapsack

Rails.application.config.after_initialize do
Hyrax.config do |config|
config.register_curation_concern :mobius_work
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def banner
end

def create_controller
return if class_name.ends_with? "Resource"

template('controller.rb.erb', File.join('../app/controllers/hyrax', class_path, "#{plural_file_name}_controller.rb"))
end

Expand Down Expand Up @@ -119,15 +121,17 @@ def insert_hyku_works_controller_behavior
end
end

# rubocop:disable Metrics/MethodLength
def insert_hyku_extra_includes_into_model
model = File.join('../app/models/', class_path, "#{file_name}.rb")
af_model = class_name.to_s.gsub('Resource', '')&.safe_constantize if class_name.end_with?('Resource')
insert_into_file model, before: "end" do
<<-RUBY.gsub(/^ {8}/, ' ')
include Hyrax::Schema(:with_pdf_viewer)
include Hyrax::Schema(:with_video_embed)
include Hyrax::ArResource
include Hyrax::NestedWorks
#{"\n Hyrax::ValkyrieLazyMigration.migrating(self, from: #{af_model})\n" if af_model}
include IiifPrint.model_configuration(
pdf_split_child_model: GenericWorkResource,
pdf_splitter_service: IiifPrint::TenantConfig::PdfSplitter
Expand Down Expand Up @@ -161,6 +165,22 @@ def insert_hyku_extra_includes_into_indexer
end
end

def change_inheritance_of_form
form = File.join('../app/forms/', class_path, "#{file_name}_form.rb")
gsub_file form, 'Hyrax::Forms::PcdmObjectForm', 'Hyrax::Forms::ResourceForm'
end

def change_inheritance_of_indexer
indexer = File.join('../app/indexers/', class_path, "#{file_name}_indexer.rb")
gsub_file indexer, "Hyrax::Indexers::PcdmObjectIndexer(#{class_name})", 'Hyrax::ValkyrieWorkIndexer'
end

def modifiy_indexer_spec
indexer_spec = File.join('../spec/indexers/', class_path, "#{file_name}_indexer_spec.rb")
# remove the let(:resource) { WorkType.new } line
gsub_file indexer_spec, /let\(:resource\) { #{class_name}\.new }\n/, "let!(:resource) { Hyrax.persister.save(resource: #{class_name}.new) }\n"
end

private

def rspec_installed?
Expand Down
2 changes: 2 additions & 0 deletions rspec.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# this file is needed to pass the pipeline since there aren't enough specs to run
# that would generate this file. Without this file, the Move Test action step fails.
29 changes: 29 additions & 0 deletions spec/hyku_knapsack/application_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Hyku::Application do
let(:rails_root) { Rails.root }
let(:hyku_knapsack_root) { HykuKnapsack::Engine.root }

describe '.theme_view_path_roots' do
it 'includes the Rails root and the Hyku Knapsack root' do
expect(described_class.theme_view_path_roots).to eq([rails_root.to_s, hyku_knapsack_root.to_s])
end
end

describe '.path_for' do
context 'when relative path does not exist in the knapsack' do
it 'returns the fall back path' do
expect(described_class.path_for('foo')).to eq(rails_root.join('foo').to_s)
end
end

context 'when relative path exists in the knapsack' do
it 'returns the relative path' do
path = 'app/models/hyku_knapsack/application_record.rb'
expect(described_class.path_for(path)).to eq(hyku_knapsack_root.join(path).to_s)
end
end
end
end

0 comments on commit 6003b66

Please sign in to comment.