Skip to content

Feature pdsc#35

Open
marcolarosa wants to merge 33 commits intoUTS-eResearch:masterfrom
marcolarosa:feature-pdsc
Open

Feature pdsc#35
marcolarosa wants to merge 33 commits intoUTS-eResearch:masterfrom
marcolarosa:feature-pdsc

Conversation

@marcolarosa
Copy link
Copy Markdown

@marcolarosa marcolarosa commented Dec 1, 2019

This is a total re-write of this library.

All OCFL object manipulation now happens inside the OcflObject class rather than in it and the Repository class. As a result, the Repository handler is much lighter and simpler.

Also, the API has changed significantly. There is now a single update method that can create new objects or version existing objects as required. The method can either ingest a source folder or it can be passed a writer method that will be given the deposit path to write to. It also works quite differently to the original ingestion classes when updating an existing object.

If the object exists -

  • it gets created in the deposit path
  • the original content is copied back to deposit
  • the deposit object is versioned
  • the original path is backed up
  • the deposit is moved to the original path
  • the backup and deposit are cleaned up

All of the tests have been re-written and they have been heavily commented in addition to being specific to bits of functionality so start there - they should make sense. That said, I've also updated the documentation in the README.

Also, the update method and associated helpers have been heavily commented in order to (hopefully) ease understanding what is going on inside them.

The only features that I think are missing are:

  • an OcflObject cannot be instantiated without passing in an id or path. That is, it won't auto generate an ID. Will leave that to you to consider.
  • the verify method is not yet implemented.

All of the original code still exists - it's just been commented out for now. This is true for tests also.

commit 9614de2
Author: Marco La Rosa <m@lr.id.au>
Date:   Tue Oct 15 16:01:08 2019 +1100

    bugfix tests

commit afa515b
Author: Marco La Rosa <m@lr.id.au>
Date:   Tue Oct 15 15:55:45 2019 +1100

    refactor createNewObjectContent

    First check that no new path is a child of any existing path then decide
    what to do. Further, ensure the deposit folder is removed when merging
    and bugfix the file name returned by nameVersion.
commit f6186f1
Author: Marco La Rosa <m@lr.id.au>
Date:   Tue Oct 15 16:21:30 2019 +1100

    bugfix namaste naming

    nameVersion method can't be used for both repo root and object namaste
    has they have different forms. This resolves this issue.

commit 9614de2
Author: Marco La Rosa <m@lr.id.au>
Date:   Tue Oct 15 16:01:08 2019 +1100

    bugfix tests

commit afa515b
Author: Marco La Rosa <m@lr.id.au>
Date:   Tue Oct 15 15:55:45 2019 +1100

    refactor createNewObjectContent

    First check that no new path is a child of any existing path then decide
    what to do. Further, ensure the deposit folder is removed when merging
    and bugfix the file name returned by nameVersion.
The load method attempts to load the OCFL object at this.path when the
class is instantiated. If it finds an object at the path it will attempt
to read the top level inventory.json to create the current state of the
object (stored as this.currentState) in addition to reading each version
inventory and creating the state of that version as this.versions.

Helper methods getCurrentState and getVersions return the current state
and versions respectively.
API has been totally reworked to operate around a single update method
that knows hows to create a new object or update and existing one. The
method can either be passed a source directory to use for the object
content or a function that will write content (with the deposit target
being passed to the function.

The class has a public API and a private one (methods beginning with __
are considered private and should not be used by calling class users).

Extensive usage examples are visible in ocflObject.spec.js.

Original code has been commented out for now - likewise in test script.
As most of the functionality now resides in OcflObject the repository
class is much much lighter.
If we use a path (subtree) relative to deposit or backup then cleanup
becomes really difficult as we have to walk back up the tree in order to
remove the path. So, if an id is passed in, just use that without
converting to a path. Likewise if a path is passed in - make it string
by replacing / with ''.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant