The purpose of this application is to sync ArchivesSpace records to FOLIO. It automates retrieving unsuppressed resources from ArchivesSpace that were modified in the last 25 hours and syncing them to FOLIO. This ensures that FOLIO always has up-to-date records from ArchivesSpace.
-
Install the required gems:
bundle install
-
Create a configuration file for ArchivesSpace credentials:
cp config/templates/archivesspace.yml config/archivesspace.yml
Edit
config/archivesspace.yml
to include your ArchivesSpace API credentials. The script supports multiple instances.development: instance1: base_url: "https://your-archivesspace-instance1/api" username: "your-username-1" password: "your-password-1" timeout: 60 instance2: base_url: "https://your-archivesspace-instance2/api" username: "your-username-2" password: "your-password-2" timeout: 60
-
Create a configuration file for FOLIO API credentials:
cp config/templates/folio.yml config/folio.yml
Edit
config/folio.yml
to include your FOLIO API credentials:development: base_url: "https://your-folio-instance" username: "your-username" password: "your-password" tenant: "your-tenant" timeout: 30
-
Create a configuration file for script-specific settings:
cp config/templates/folio_sync.yml config/folio_sync.yml
Edit
config/folio_sync.yml
to include settings specific to the script. The script supports multiple instances.development: default_sender_email_address: "[email protected]" aspace_to_folio: marc_download_base_directory: <%= Rails.root.join('tmp/development/downloaded_files') %> developer_email_address: [email protected] aspace_instances: instance1: marc_sync_email_addresses: - "[email protected]" instance2: marc_sync_email_addresses: - "[email protected]" - "[email protected]"
Most tasks require you to specify the instance_key
(e.g., instance1
or instance2
) as an environment variable:
bundle exec rake folio_sync:aspace_to_folio:run instance_key=instance1
Fetches ArchivesSpace MARC resources and syncs them to FOLIO. If any errors occur during downloading or syncing, an email is sent to the configured recipients.
modified_since
: Accepts an integer representing the lastx
hours. Resources modified within the lastx
hours will be retrieved. If not supplied, all resources are retrieved regardless of their modification date.clear_downloads
: If set totrue
, the downloads folder is cleared before processing. If set tofalse
, the folder is not cleared. By default,clear_downloads
istrue
.
bundle exec rake folio_sync:aspace_to_folio:run instance_key=instance1 modified_since=25 clear_downloads=false
Syncs already downloaded MARC XML files from the directory specified in folio_sync.yml
to FOLIO. If any errors occur during syncing, an email is sent to the configured recipients.
bundle exec rake folio_sync:aspace_to_folio:sync_exported_resources instance_key=instance1
This task allows you to test the processing of a MARC XML file for a specific bib_id
. It reads the MARC XML file from the marc_download_base_directory
specified in folio_sync.yml
file, processes it, and applies the necessary transformations.
bundle exec rake folio_sync:aspace_to_folio:process_marc_xml bib_id=<bib_id> instance_key=instance1
bundle exec rake folio_sync:aspace_to_folio:process_marc_xml bib_id=123456789 instance_key=instance1
Performs a health check on the FOLIO API to ensure it is reachable and functioning correctly.
bundle exec rake folio_sync:aspace_to_folio:folio_health_check
Sends a test email to the configured recipients to verify the email functionality.
bundle exec rake folio_sync:aspace_to_folio:email_test instance_key=instance1
This application was created using rails new
. However, since we're using it as a script for now, we're not using Rails' MVC (Model-View-Controller) structure. For clarity, the app folder was kept but it's empty as we don't need its content.
Some of the default Rails setup was skipped during the initialization:
rails new folio_sync --skip-action-mailer --skip-action-mailbox --skip-action-text --skip-active-record --skip-active-storage --skip-action-cable --skip-sprockets --skip-javascript --skip-hotwire --skip-jbuilder --skip-test --skip-system-test --skip-bootsnap
Run the test suite using RSpec:
bundle exec rspec
Run Rubocop:
bundle exec rubocop