A small gem to help create administrative task scripts for working with the DSpace API.
Make sure you have a recent version of JRuby installed.
I'm still ironing out the implementation details. For now, the easiest way to install/use this tool is to:
Clone the repo:
git clone https://github.com/kardeiz/dscriptor.git
Bundle:
bundle
You can then run your script like:
bundle exec jruby myscript.rb
See the examples
directory for examples.
Create a new script *.rb
file.
Require the gem and any other dependencies you might have:
require 'dscriptor'
Configure the tool (add any java classes you need to the imports
list so that you can access them more conveniently):
Dscriptor.configure do |c|
c.dspace_cfg = ENV['DSPACE_CFG']
c.admin_email = ENV['ADMIN_EMAIL']
c.imports.merge %w{
org.dspace.authorize.AuthorizeManager
org.dspace.authorize.ResourcePolicy
org.dspace.storage.rdbms.TableRow
}
end
Note: I'm using an environment variable to identify my path to dspace.cfg here, but you can also just hard code it into your script.
Prepare the runtime:
Dscriptor.prepare
This starts the DSpace kernel, requires all of the core jar
files, and imports the specified java classes.
Include the tool's mixins
(optional):
include Dscriptor::Mixins
This will add a number of convenience methods to your current context (e.g., context
, which is the DSpace context for your admin user).
Note: if you have included these mixins in an IRB session, you will need to use dspace_context
rather than context
, since IRB has reserved context
for its own use.
You can then do whatever you like within your script. Remember to call context.complete
before exiting your script if you have made any changes to DSpace.
Versioning is very casual. Things will probably break between versions. Use at your own risk.
The examples here are for a DSpace 4.1 repository. It is possible that some of methods used are different for earlier or later versions.
Pull requests are more than welcome. I'll be extending the gem only in my free time.
- Fork it ( https://github.com/kardeiz/dscriptor/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request