Skip to content

Commit

Permalink
Merge pull request #12 from samvera-labs/update-work-resource-generator
Browse files Browse the repository at this point in the history
Update `HykuKnapsack::WorkResourceGenerator`
  • Loading branch information
kirkkwang authored Mar 18, 2024
2 parents 031f11f + c07a2af commit 0bdd510
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def banner
end

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

def create_metadata_config
Expand All @@ -57,7 +57,7 @@ def create_model

def create_model_spec
return unless rspec_installed?
filepath = File.join('../../spec/models/', class_path, "#{file_name}_spec.rb")
filepath = File.join('../spec/models/', class_path, "#{file_name}_spec.rb")
template('work_spec.rb.erb', filepath)
return if attributes.blank?
inject_into_file filepath, after: /it_behaves_like 'a Hyrax::Work'\n/ do
Expand Down Expand Up @@ -111,6 +111,32 @@ def create_view_spec
File.join('../spec/views/', class_path, "#{plural_file_name}/_#{file_name}.html.erb_spec.rb"))
end

def insert_hyku_works_controller_behavior
controller = File.join('../app/controllers/hyrax', class_path, "#{plural_file_name}_controller.rb")
insert_into_file controller, after: "include Hyrax::WorksControllerBehavior\n" do
" include Hyku::WorksControllerBehavior\n"
end
end

def insert_hyku_extra_includes_into_model
model = File.join('../app/models/', class_path, "#{file_name}.rb")
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
include IiifPrint.model_configuration(
pdf_split_child_model: GenericWorkResource,
pdf_splitter_service: IiifPrint::TenantConfig::PdfSplitter
)
prepend OrderAlready.for(:creator)
RUBY
end
end

private

def rspec_installed?
Expand Down

0 comments on commit 0bdd510

Please sign in to comment.