-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enhancements for Onix 3 support #108
base: master
Are you sure you want to change the base?
Conversation
@@ -6,7 +6,7 @@ | |||
module ONIX | |||
class Contributor < SubsetDSL | |||
element "SequenceNumber", :integer, :cardinality => 0..1 | |||
element "ContributorRole", :subset, :shortcut => :role, :cardinality => 1..n | |||
elements "ContributorRole", :subset, :shortcut => :roles, :cardinality => 1..n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid API break, it would be nice to add a singular role
method like for place
https://github.com/immateriel/im_onix/blob/master/lib/onix/contributor.rb#L49
Hi, Nice contribution ! Just be careful not to break the API so we can integrate it in main branch. |
end | ||
|
||
def each(&block) | ||
@reader.each do |node| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add
return unless @reader
before the iteration to avoid an exception if reader
has not been called ?
I wanted to open a PR from a fork (https://github.com/BookBub/im_onix) in case it's helpful, feel free to dismiss.
SimpleDelegator
)Nokogiri::XML::Reader
rather than a fullNokogiri::XML.parse
- the latter pulls the entire onix file into memory first, while theReader
will stream each node into memory, so is overall less memory intensive. This matches Cacofonix's strategy as well, which under benchmarking was faster than im_onix.