Skip to content

Instantly share code, notes, and snippets.

@quoideneuf
Created March 22, 2015 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quoideneuf/f8596249aaf344f82f44 to your computer and use it in GitHub Desktop.
Save quoideneuf/f8596249aaf344f82f44 to your computer and use it in GitHub Desktop.
DAO Title
with 'dao' do
# new stuff, borrowed from daogrp in the ead_converter.rb file...
title = ''
ancestor(:resource, :archival_object ) { |ao|
title << ao.title
date_label = ao.dates && ao.dates.length > 0 ?
lambda {|date|
if date['expression']
date['expression']
elsif date['begin'] and date['end']
"#{date['begin']} - #{date['end']}"
else
date['begin']
end
}.call(ao.dates.first) : false
title += ", " if (title.length > 0) && date_label
title += date_label if date_label
}
make :instance, {
:instance_type => 'digital_object'
} do |instance|
set ancestor(:resource, :archival_object), :instances, instance
end
make :digital_object, {
:digital_object_id => SecureRandom.uuid,
# more new stuff...
:title => title,
} do |obj|
obj.file_versions << {
:use_statement => att('role'),
:file_uri => att('href'),
:xlink_actuate_attribute => att('actuate'),
:xlink_show_attribute => att('show')
}
set ancestor(:instance), :digital_object, obj
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment