sul-dlss/traject_plus

Name: traject_plus

Owner: Stanford University Digital Library

Description: Traject extensions for non-MARC formats

Created: 2017-10-18 08:40:30.0

Updated: 2017-11-06 19:26:59.0

Pushed: 2017-12-21 17:53:04.0

Homepage:

Size: 25

Language: Ruby

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

TrajectPlus

TrajectPlus is a number of useful additions to Traject

Features
New readers:
TrajectPlus::JsonReader
ide 'reader_class_name', 'TrajectPlus::JsonReader'
ield 'title', extract_json('$.label')
TrajectPlus::CSVReader
ide 'reader_class_name', 'TrajectPlus::CSVReader'
ield 'title', column('Record Title')
TrajectPlus::XMLReader
ide 'reader_class_name', 'TrajectPlus::XMLReader'
ield 'title', extract_xml('/*/mods:language/mods:scriptTerm',
                          { 'mods' => 'http://www.loc.gov/mods/v3' })

There are also XML macros for specific formats (MODS, TEI, FGCD):

For example:

ield 'title', extract_mods('/*/mods:language/mods:scriptTerm')
ield 'cho_description', extract_tei("/*/tei:teiHeader/tei:fileDesc/tei:sourceDesc/tei:msDesc/tei:msContents/tei:summary")
act_fgdc('/*/idinfo/citation/citeinfo/geoform')
New macros:
ield 'x', accumulate { |record, context| record.values }
ield 'x', copy('y')
ose do
_field 'x', accumulate { |record, context| record.x }


 { 'x' => [1, 2, 3]}
uby
ose('subfield') do
_field 'x', accumulate { |record, context| record.x }


 { 'subfield' => [{ 'x' => [1, 2, 3]} ]}
uby
ose ->(record, accumulator, context) { record.subfield } do
_field 'x', accumulate { |subfield, context| subfield.x }

 { 'x' => [1, 2, 3]}

These can be applied to any extract function:

ield 'title', extract: extract_xml('title'), transform: transform(gsub: ['|', ' - '])
Installation

Add this line to your application's Gemfile:

'traject_plus'

And then execute:

$ bundle

Or install it yourself as:

$ gem install traject_plus
Usage

TODO: Write usage instructions here

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/traject_plus. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the TrajectPlus project?s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.