Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Add batch ingest functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
redlibrarian committed Aug 29, 2014
1 parent 42cf204 commit 8f1f123
Show file tree
Hide file tree
Showing 105 changed files with 4,785 additions and 1 deletion.
31 changes: 31 additions & 0 deletions lib/ingest/batch_ingest.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require_relative "./ingester.rb"

class BatchIngest

attr_writer :ingester, :root, :namespace

def from_file(file)
read file
@records.each do |record|
add record
end
end

def from_directory(dir)
Dir.foreach(dir) do |file|
next if file == "." or file == ".."
path = "#{dir}/#{file}"
from_file(path)
end
end

private

def read file
@records = Nokogiri::XML(File.open(file)).xpath(@root, @namespace)
end

def add record
@ingester.add_document(record)
end
end
2,266 changes: 2,266 additions & 0 deletions spec/fixtures/collection.xml

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions spec/fixtures/collection/0.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">
<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/homefront/</identifier>
<datestamp>2013-10-21T22:19:13Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>World War II: The Homefront in Alberta</dc:title>
<dc:description>The Homefront in Alberta Website uses words, photographs, video, and audio to tell this compelling story as it took place in communities across the province of Alberta. It is a testament to the lives of those left behind to cope, struggle, triumph, and grieve as the events of a tortured world forever changed the reality of home life and community.</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/homefront/</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
23 changes: 23 additions & 0 deletions spec/fixtures/collection/1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">
<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.abheritage.ca/abarts/index.htm</identifier>
<datestamp>2013-11-18T21:00:53Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:subject>Social History</dc:subject>
<dc:subject>Communities</dc:subject>
<dc:subject>Local History</dc:subject>
<dc:subject>History</dc:subject>
<dc:description>The Alberta's Arts Heritage website is a multimedia resource dedicated to exploring the rich history of the arts in Alberta. Keynote articles explore the performing, literary, visual, and film and media arts. Search the artists' database and listen to approximately 500 hours of CKUA Radio Network's Arts Alberta.</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:coverage>Alberta</dc:coverage>
<dc:coverage>Canada, Western</dc:coverage>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:title>Welcome to Alberta's Arts Heritage</dc:title>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.abheritage.ca/abarts/index.htm</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
24 changes: 24 additions & 0 deletions spec/fixtures/collection/10.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">

<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.abheritage.ca/stia/</identifier>
<datestamp>2013-10-21T21:42:13Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>So, This is Alberta!</dc:title>
<dc:subject>Communities</dc:subject>
<dc:subject>Social History</dc:subject>
<dc:subject>Local History</dc:subject>
<dc:subject>History</dc:subject>
<dc:description>Just in time for Alberta's Centennial comes this fun and colourful look at just about everything Albertan: So, This Is Alberta! Featuring the designs and illustrations of Alberta's own Gary Delainey and Gerry Rasmussen (writers and illustrators of the comics Bub Slug and Betty), this website follows the comic adventures of a raven and a Richardson's ground squirrel as they explore the history, natural heritage, society and culture, and innovation of the province that sits "second from the left" on the Canadian map. Read the stories! See the pictures! Hear the audio and watch the video! In the end, you'll just have to sit back and declare: So, This Is Alberta!</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:coverage>Alberta</dc:coverage>
<dc:coverage>Canada, Western</dc:coverage>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.abheritage.ca/stia/</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
24 changes: 24 additions & 0 deletions spec/fixtures/collection/11.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">

<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/treaty7/</identifier>
<datestamp>2013-10-22T16:46:03Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Treaty 7: Past and Present</dc:title>
<dc:subject>History</dc:subject>
<dc:subject>Local History</dc:subject>
<dc:subject>Communities</dc:subject>
<dc:subject>Social History</dc:subject>
<dc:description>This website explores the making of Treaty 7 through text, historic photographs, audio, video and contextual information, as well as exploring the culture and lifeways of First Nations people.</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:coverage>Alberta</dc:coverage>
<dc:coverage>Canada, Western</dc:coverage>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/treaty7/</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
24 changes: 24 additions & 0 deletions spec/fixtures/collection/12.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">

<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.albertaheritage.net/</identifier>
<datestamp>2013-10-21T21:44:39Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Alberta Heritage Online</dc:title>
<dc:subject>Social History</dc:subject>
<dc:subject>Communities</dc:subject>
<dc:subject>Local History</dc:subject>
<dc:subject>History</dc:subject>
<dc:description>Alberta Heritage Online is the gateway to Alberta's heritage resources including museums, historic sites and archives. It promotes cultural tourism through showcasing Places to Go as well as providing a directory of heritage institutions and organizations.</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:coverage>Canada, Western</dc:coverage>
<dc:coverage>Alberta</dc:coverage>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.albertaheritage.net/</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
24 changes: 24 additions & 0 deletions spec/fixtures/collection/13.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">

<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/oblatesinthewest/eng/</identifier>
<datestamp>2013-10-22T16:08:15Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Oblates in the West: The Alberta Story</dc:title>
<dc:subject>History</dc:subject>
<dc:subject>Local History</dc:subject>
<dc:subject>Communities</dc:subject>
<dc:subject>Social History</dc:subject>
<dc:description>Information about the role and impact of the Missionary Oblates of Mary Immaculate in Western Canada is important not only for a better understanding of Canada's colonial past but also of the present. Discover 100 years of Oblate history and the Order's impact on Aboriginal and Métis Peoples as well as Francophone communities on the Oblates in West Website.</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:coverage>Alberta</dc:coverage>
<dc:coverage>Canada, Western</dc:coverage>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/oblatesinthewest/eng/</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
24 changes: 24 additions & 0 deletions spec/fixtures/collection/14.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><OAI-PMH xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd" xmlns:ex="http://exslt.org/dates-and-times" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.openarchives.org/OAI/2.0/">

<record>
<header>
<identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/placenames/</identifier>
<datestamp>2013-10-22T16:25:18Z</datestamp>
<setSpec>collection:2217</setSpec>
</header>
<metadata>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:database="http://www.oclc.org/pears/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Alberta Place Names</dc:title>
<dc:subject>History</dc:subject>
<dc:subject>Local History</dc:subject>
<dc:subject>Communities</dc:subject>
<dc:subject>Social History</dc:subject>
<dc:description>The Land, the People and Their Stories is a state-of-the-art multimedia website that explores the history of naming in Alberta as well as providing a range of information about names of communities, geographical features and special areas. The study of place names is called toponymy; thus, the Place Names of Alberta Website is a toponymic resource that helps to preserve Alberta's cultural heritage.</dc:description>
<dc:publisher>Heritage Community Foundation</dc:publisher>
<dc:coverage>Alberta</dc:coverage>
<dc:coverage>Canada, Western</dc:coverage>
<dc:rights>All material on this Site ("Material"), including but not limited to text, images, illustrations, audio clips, and video clips, is protected by copyrights which are owned and controlled by us or by other parties that have licensed their material to us. Material from the Site or any web site owned, operated, licensed or controlled by us may not be copied, reproduced, republished, uploaded, posted, transmitted, or distributed in any way. Specifically, you may not link directly to our audio or video or image files, and you should not attempt to "pass off" any of the Material as your own work. Modification of the Material or use of the Material for any other purpose is a violation of the copyrights and other proprietary rights. For purposes of these Terms and Conditions, the use of any Material on any other web site or networked computer environment is prohibited.</dc:rights>
<dc:identifier>http://wayback.archive-it.org/2217/*/http://www.albertasource.ca/placenames/</dc:identifier>
</oai_dc:dc>
</metadata>
</record>
Loading

0 comments on commit 8f1f123

Please sign in to comment.