cul-fedora 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ private
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 James Stuart
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = cul-fedora
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 James Stuart. See LICENSE for details.
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "cul-fedora"
8
+ gem.summary = %Q{Columbia University Fedora Hooks}
9
+ gem.description = %Q{Columbia-specific Fedora libraries}
10
+ gem.email = "tastyhat@jamesstuart.org"
11
+ gem.homepage = "http://github.com/tastyhat/cul-fedora"
12
+ gem.authors = ["James Stuart"]
13
+ gem.add_development_dependency "shoulda", ">= 0"
14
+ gem.add_development_dependency "mocha", ">=0.9.8"
15
+ gem.add_dependency "nokogiri"
16
+ gem.add_dependency "httpclient"
17
+ gem.add_dependency "active_support"
18
+ gem.add_dependency "rsolr"
19
+ gem.add_dependency "rsolr-ext"
20
+
21
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
22
+ end
23
+ Jeweler::GemcutterTasks.new
24
+ rescue LoadError
25
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
26
+ end
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ begin
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ end
42
+ rescue LoadError
43
+ task :rcov do
44
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
45
+ end
46
+ end
47
+
48
+ task :test => :check_dependencies
49
+
50
+ task :default => :test
51
+
52
+ require 'rake/rdoctask'
53
+ Rake::RDocTask.new do |rdoc|
54
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
55
+
56
+ rdoc.rdoc_dir = 'rdoc'
57
+ rdoc.title = "cul-fedora #{version}"
58
+ rdoc.rdoc_files.include('README*')
59
+ rdoc.rdoc_files.include('lib/**/*.rb')
60
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,85 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cul-fedora}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["James Stuart"]
12
+ s.date = %q{2010-09-21}
13
+ s.description = %q{Columbia-specific Fedora libraries}
14
+ s.email = %q{tastyhat@jamesstuart.org}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "cul-fedora.gemspec",
27
+ "lib/cul-fedora.rb",
28
+ "lib/cul-fedora/item.rb",
29
+ "lib/cul-fedora/server.rb",
30
+ "lib/cul-fedora/solr.rb",
31
+ "test/data/125467_get_index.xml",
32
+ "test/data/125467_solr_doc.xml",
33
+ "test/data/example_server_requests.yml",
34
+ "test/helper.rb",
35
+ "test/test_cul-fedora.rb",
36
+ "test/test_fedora_item.rb",
37
+ "test/test_fedora_server.rb",
38
+ "test/test_fedora_solr.rb",
39
+ "test_fedora_item.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/tastyhat/cul-fedora}
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.3.7}
45
+ s.summary = %q{Columbia University Fedora Hooks}
46
+ s.test_files = [
47
+ "test/helper.rb",
48
+ "test/test_cul-fedora.rb",
49
+ "test/test_fedora_item.rb",
50
+ "test/test_fedora_server.rb",
51
+ "test/test_fedora_solr.rb"
52
+ ]
53
+
54
+ if s.respond_to? :specification_version then
55
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
56
+ s.specification_version = 3
57
+
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
59
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
60
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
61
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
62
+ s.add_runtime_dependency(%q<httpclient>, [">= 0"])
63
+ s.add_runtime_dependency(%q<active_support>, [">= 0"])
64
+ s.add_runtime_dependency(%q<rsolr>, [">= 0"])
65
+ s.add_runtime_dependency(%q<rsolr-ext>, [">= 0"])
66
+ else
67
+ s.add_dependency(%q<shoulda>, [">= 0"])
68
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
69
+ s.add_dependency(%q<nokogiri>, [">= 0"])
70
+ s.add_dependency(%q<httpclient>, [">= 0"])
71
+ s.add_dependency(%q<active_support>, [">= 0"])
72
+ s.add_dependency(%q<rsolr>, [">= 0"])
73
+ s.add_dependency(%q<rsolr-ext>, [">= 0"])
74
+ end
75
+ else
76
+ s.add_dependency(%q<shoulda>, [">= 0"])
77
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
78
+ s.add_dependency(%q<nokogiri>, [">= 0"])
79
+ s.add_dependency(%q<httpclient>, [">= 0"])
80
+ s.add_dependency(%q<active_support>, [">= 0"])
81
+ s.add_dependency(%q<rsolr>, [">= 0"])
82
+ s.add_dependency(%q<rsolr-ext>, [">= 0"])
83
+ end
84
+ end
85
+
@@ -0,0 +1,9 @@
1
+ require "httpclient"
2
+ require "nokogiri"
3
+ require "active_support"
4
+ require "rsolr"
5
+ require "rsolr-ext"
6
+
7
+ require "cul-fedora/item"
8
+ require "cul-fedora/server"
9
+ require "cul-fedora/solr"
@@ -0,0 +1,189 @@
1
+ module Cul
2
+ module Fedora
3
+ class Item
4
+ attr_reader :server, :pid
5
+
6
+ URI_TO_PID = 'info:fedora/'
7
+
8
+
9
+
10
+ def initialize(*args)
11
+ options = args.extract_options!
12
+ @server = options[:server] || Server.new(options[:server_config])
13
+ @pid = options[:pid] || options[:uri] || raise(ArgumentError, "requires uri or pid")
14
+ @pid = @pid.to_s.sub(URI_TO_PID, "")
15
+ end
16
+
17
+ def ==(other)
18
+ self.server == other.server
19
+ self.pid == other.pid
20
+ end
21
+
22
+ def request(options = {})
23
+ @server.request(options.merge(:pid => @pid))
24
+ end
25
+
26
+ def request_path(options = {})
27
+ @server.request_path(options.merge(:pid => @pid))
28
+ end
29
+
30
+ def getIndex(profile = "raw")
31
+ Nokogiri::XML(request(:request => "getIndex", :sdef => "ldpd:sdef.Core", :profile => profile))
32
+ end
33
+
34
+ def datastream(name)
35
+ request(:request => name.to_s.upcase)
36
+ end
37
+
38
+
39
+ def listMembers
40
+ results = JSON::parse(@server.request(:method => "", :request => "risearch", :format => "json", :lang => "itql", :query => sprintf(@server.riquery, @pid)))["results"]
41
+
42
+ results.collect { |r| @server.item(r["member"]) }
43
+
44
+ end
45
+
46
+
47
+ def describedBy
48
+ begin
49
+ result = request(:request => "describedBy", :sdef => "ldpd:sdef.Core")
50
+ Nokogiri::XML(result).css("sparql>results>result>description").collect do |metadata|
51
+ @server.item(metadata.attributes["uri"].value)
52
+ end
53
+ rescue
54
+ []
55
+ end
56
+ end
57
+
58
+ def belongsTo
59
+ begin
60
+ result = Nokogiri::XML(datastream("RELS-EXT"))
61
+ result.xpath("/rdf:RDF/rdf:Description/*[local-name()='memberOf']").collect do |member|
62
+ @server.item(member.attributes["resource"].value)
63
+ end
64
+ rescue
65
+ []
66
+ end
67
+ end
68
+
69
+ def index_for_ac2
70
+ results = Hash.new { |h,k| h[k] = [] }
71
+ normalize_space = lambda { |s| s.to_s.strip.gsub(/\s{2,}/," ") }
72
+ search_to_content = lambda { |x| x.kind_of?(Nokogiri::XML::Element) ? x.content : x.to_s }
73
+ add_field = lambda { |name, value| results[name] << search_to_content.call(value) }
74
+
75
+ get_fullname = lambda { |node| node.nil? ? nil : (node.css("namePart[@type='family']").collect(&:content) | node.css("namePart[@type='given']").collect(&:content)).join(", ") }
76
+
77
+ roles = ["Author","author","Creator","Thesis Advisor","Collector","Owner","Speaker","Seminar Chairman","Secretary","Rapporteur","Committee Member","Degree Grantor","Moderator","Editor","Interviewee","Interviewer","Organizer of Meeting","Originator","Teacher"]
78
+
79
+ collections = self.belongsTo
80
+ meta = describedBy.first
81
+
82
+ meta = Nokogiri::XML(meta.datastream("CONTENT")) if meta
83
+ mods = meta.at_css("mods") if meta
84
+
85
+ return {} unless mods
86
+ # baseline blacklight fields: id is the unique identifier, format determines by default, what partials get called
87
+ add_field.call("id", @pid)
88
+ add_field.call("internal_h", collections.first.to_s + "/")
89
+ add_field.call("pid", @pid)
90
+ collections.each do |collection|
91
+ add_field.call("member_of", collection)
92
+ end
93
+
94
+
95
+
96
+ title = normalize_space.call(mods.css("titleInfo>nonSort,title").collect(&:content).join(" "))
97
+ add_field.call("title_display", title)
98
+ add_field.call("title_search", title)
99
+
100
+ all_names = []
101
+ mods.css("name[@type='personal']").each do |name_node|
102
+ if name_node.css("role>roleTerm[@type='text']").collect(&:content).any? { |role| roles.include?(role) }
103
+
104
+ fullname = get_fullname.call(name_node)
105
+
106
+ all_names << fullname
107
+
108
+ add_field.call("author_search", fullname.downcase)
109
+ add_field.call("author_facet", fullname)
110
+
111
+ end
112
+
113
+ end
114
+
115
+ add_field.call("authors_display",all_names.join("; "))
116
+ add_field.call("date", mods.at_css("*[@keyDate='yes']"))
117
+
118
+ mods.css("genre").each do |genre_node|
119
+ add_field.call("genre_facet", genre_node)
120
+ add_field.call("genre_search", genre_node)
121
+
122
+ end
123
+
124
+
125
+ add_field.call("abstract", mods.at_css("abstract"))
126
+ add_field.call("handle", mods.at_css("identifier[@type='hdl']"))
127
+
128
+ mods.css("subject:not([@authority='local'])>topic").each do |topic_node|
129
+ add_field.call("keyword_search", topic_node.content.downcase)
130
+ add_field.call("keyword_facet", topic_node)
131
+ end
132
+
133
+ mods.css("subject[@authority='local']>topic").each do |topic_node|
134
+ add_field.call("subject", topic_node)
135
+ add_field.call("subject_search", topic_node)
136
+ end
137
+
138
+
139
+ add_field.call("tableOfContents", mods.at_css("tableOfContents"))
140
+
141
+ mods.css("note").each { |note| add_field.call("notes", note) }
142
+
143
+ if (related_host = mods.at_css("relatedItem[@type='host']"))
144
+ book_journal_title = related_host.at_css("titleInfo>title")
145
+
146
+ if book_journal_title
147
+ book_journal_subtitle = mods.at_css("name>titleInfo>subTitle")
148
+
149
+ book_journal_title = book_journal_title.content + ": " + book_journal_subtitle.content.to_s if book_journal_subtitle
150
+
151
+ end
152
+
153
+ add_field.call("book_journal_title", book_journal_title)
154
+
155
+ add_field.call("book_author", get_fullname.call(related_host.at_css("name")))
156
+
157
+ add_field.call("issn", related_host.at_css("identifier[@type='issn']"))
158
+ end
159
+
160
+ add_field.call("publisher", mods.at_css("relatedItem>originInfo>publisher"))
161
+ add_field.call("publisher_location", mods.at_css("relatedItem > originInfo>place>placeTerm[@type='text']"))
162
+ add_field.call("isbn", mods.at_css("relatedItem>identifier[@type='isbn']"))
163
+ add_field.call("doi", mods.at_css("identifier[@type='doi'][@displayLabel='Published version']"))
164
+
165
+ mods.css("physicalDescription>internetMediaType").each { |mt| add_field.call("media_type_facet", mt) }
166
+
167
+ mods.css("typeOfResource").each { |tr| add_field.call("type_of_resource_facet", tr)}
168
+ mods.css("subject>geographic").each do |geo|
169
+ add_field.call("geographic_area", geo)
170
+ add_field.call("geographic_area_search", geo)
171
+ end
172
+
173
+
174
+
175
+
176
+
177
+ listMembers.each_with_index do |member, i|
178
+ add_field.call("ac.fulltext_#{i}", "")
179
+ end
180
+
181
+ return results
182
+ end
183
+
184
+ def to_s
185
+ @pid
186
+ end
187
+ end
188
+ end
189
+ end
@@ -0,0 +1,54 @@
1
+ module Cul
2
+ module Fedora
3
+ class Server
4
+ attr_reader :riurl, :riquery
5
+
6
+ def initialize(*args)
7
+ options = args.extract_options!
8
+ @riurl = options["riurl"] || raise(ArgumentError, "Must provide riurl argument")
9
+ @riquery = options["riquery"] || raise(ArgumentError, "Must provide riquery argument")
10
+ @hc = options[:http_client]
11
+ end
12
+
13
+ def item(uri)
14
+ Item.new(:server => self, :uri => uri)
15
+ end
16
+
17
+
18
+
19
+ def request(options= {})
20
+ http_client.get_content(*request_path(options))
21
+ end
22
+
23
+ def request_path(options = {})
24
+ sdef = options.delete(:sdef).to_s
25
+ pid = options.delete(:pid).to_s
26
+ request = options.delete(:request).to_s
27
+ method = (options.delete(:method) || "/get").to_s
28
+ raise(ArgumentError, "request necessary") if request.empty?
29
+
30
+ sdef = "/" + sdef unless sdef.empty?
31
+ pid = "/" + pid unless pid.empty?
32
+ request = "/" + request.to_s
33
+
34
+
35
+ uri = @riurl + method + pid + sdef + request
36
+ query = options
37
+
38
+ return [uri, query]
39
+ end
40
+
41
+ def inspect
42
+ '#<Cul::Fedora::Server:' + self.object_id.to_s + ' @riurl="' + @riurl + '">'
43
+ end
44
+
45
+ private
46
+
47
+ def http_client
48
+ @hc ||= HTTPClient.new()
49
+ @hc
50
+ end
51
+ end
52
+ end
53
+ end
54
+
@@ -0,0 +1,36 @@
1
+ module Cul
2
+ module Fedora
3
+ class Solr
4
+ attr_reader :url
5
+ def initialize(config = {})
6
+ @url = config["url"] || raise(ArgumentError, "must provide url")
7
+
8
+ end
9
+
10
+ def rsolr
11
+ @rsolr ||= RSolr.connect(:url => @url)
12
+ end
13
+
14
+ def ingest(options = {})
15
+ format = options.delete(:format) || raise(ArgumentError, "needs format")
16
+ items = options.delete(:items) || []
17
+ items = [items] unless items.kind_of?(Array)
18
+
19
+ collections = options.delete(:collections) || []
20
+ collections = [collections] unless collections.kind_of?(Array)
21
+ collections.each do |collection|
22
+ items |= collection.listMembers
23
+ end
24
+
25
+
26
+
27
+ rsolr.add(items.collect { |i| i.send("index_for_#{format}")}.reject { |doc| doc == {}})
28
+
29
+ rsolr.commit
30
+ end
31
+
32
+ end
33
+
34
+
35
+ end
36
+ end
@@ -0,0 +1,130 @@
1
+ <index:allMetadata xmlns:index="http://repository.cul.columbia.edu/namespace/index/1_0/" pid="ac:125467" fedora="https://repository2.cul.columbia.edu:8443/fedora"><index:overrides><index:format>Collection</index:format></index:overrides><index:hierarchies><index:collection>/Academic Commons</index:collection><index:collection>/David Freedberg Papers</index:collection><index:internal>/collection:3/ac:125467</index:internal><index:internal>/ac:59/ac:125467</index:internal><index:format>collection/</index:format></index:hierarchies><index:description containerPid="ac:125467" src="https://repository2.cul.columbia.edu:8443/fedora/get/ac:125467/DC" >
2
+ <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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
3
+ <dc:title>Generic Content Aggregator</dc:title>
4
+ <dc:creator>BATCH</dc:creator>
5
+ <dc:type>InteractiveResource</dc:type>
6
+ <dc:identifier>AC:P:8619</dc:identifier>
7
+ <dc:identifier>ac:125467</dc:identifier>
8
+ </oai_dc:dc>
9
+ </index:description><index:description containerPid="ac:125469" src="https://repository2.cul.columbia.edu:8443/fedora/get/ac:125469/CONTENT" >
10
+ <mods xmlns="http://www.loc.gov/mods/v3" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:copyrightMD="http://www.cdlib.org/inside/diglib/copyrightMD" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd">
11
+
12
+ <titleInfo>
13
+ <title>A Source for Rubens&apos;s Modello of the Assumption and Coronation of the Virgin in Leningrad: A Case Study in the Response to Images</title>
14
+ <subTitle></subTitle>
15
+ </titleInfo>
16
+ <name type="personal">
17
+ <namePart type="family">Freedberg</namePart>
18
+ <namePart type="given">David</namePart>
19
+ <role>
20
+ <roleTerm type="text">Author</roleTerm>
21
+ </role>
22
+ <affiliation type="email">daf5@columbia.edu</affiliation>
23
+ <affiliation type="department.other"></affiliation>
24
+ <affiliation type="department">Art History and Archaeology, Department of</affiliation>
25
+ <affiliation type="organization">Columbia University</affiliation>
26
+ <affiliation type="country">United States</affiliation>
27
+ <authorID type="institution">daf5</authorID>
28
+ <authorID type="repository">NNC2010.04.016</authorID>
29
+ <authorID type="naf">n81029377</authorID>
30
+ </name>
31
+ <typeOfResource>text</typeOfResource>
32
+ <genre>Articles</genre>
33
+
34
+ <originInfo>
35
+ <dateCreated encoding="w3cdtf" keyDate="yes">1978</dateCreated>
36
+ </originInfo>
37
+
38
+ <language>
39
+ <languageTerm type="text">English</languageTerm>
40
+ </language>
41
+
42
+ <physicalDescription>
43
+ <internetMediaType>application/pdf</internetMediaType>
44
+ <extent type="totalpages"></extent>
45
+ <extent type="filesize">1.79 MB</extent>
46
+ </physicalDescription>
47
+ <abstract></abstract>
48
+ <note></note>
49
+
50
+ <subject>
51
+ <topic></topic>
52
+ <geographic></geographic>
53
+ </subject>
54
+ <subject authority="local">
55
+ <topic>Fine arts</topic>
56
+ </subject>
57
+ <relatedItem type="host">
58
+ <titleInfo>
59
+ <title>Burlington Magazine</title>
60
+ </titleInfo>
61
+ <part>
62
+ <detail type="volume">
63
+ <number>120</number>
64
+ <caption>vol. </caption>
65
+ </detail>
66
+ <detail type="issue">
67
+ <number>904</number>
68
+ <caption>no. </caption>
69
+ </detail>
70
+ <extent unit="page">
71
+ <start>432</start>
72
+ <end>441</end>
73
+ </extent>
74
+ <date>July 1978</date>
75
+ </part>
76
+ <identifier type="issn"></identifier>
77
+ </relatedItem>
78
+ <identifier type="local">dept_freed_source_for_rubens_modello</identifier>
79
+ <identifier type="doi" displayLabel="Published version"></identifier>
80
+ <identifier type="uri" displayLabel="Published version"></identifier>
81
+ <identifier type="hdl">http://hdl.handle.net/10022/AC:P:8619</identifier>
82
+
83
+ <location>
84
+ <physicalLocation authority="marcorg">NNC</physicalLocation>
85
+ <url></url>
86
+ </location>
87
+
88
+ <accessCondition>
89
+ <copyrightMD:copyright copyright.status="copyrighted" publication.status="published">
90
+ <copyrightMD:creation>
91
+ <copyrightMD:year.creation>1978</copyrightMD:year.creation>
92
+ <copyrightMD:country.creation></copyrightMD:country.creation>
93
+ </copyrightMD:creation>
94
+ <copyrightMD:rights.holder>
95
+ <copyrightMD:name></copyrightMD:name>
96
+ <copyrightMD:contact></copyrightMD:contact>
97
+ <copyrightMD:note></copyrightMD:note>
98
+ </copyrightMD:rights.holder>
99
+ <copyrightMD:notice></copyrightMD:notice>
100
+ <copyrightMD:general.note></copyrightMD:general.note>
101
+ </copyrightMD:copyright>
102
+ <embargo>
103
+ <levelOfAccess>pubAccess</levelOfAccess>
104
+ <issuedBy></issuedBy>
105
+ <dateEmbargo point="start"></dateEmbargo>
106
+ <dateEmbargo point="end"></dateEmbargo>
107
+ <note type="embargo"></note>
108
+ </embargo>
109
+
110
+ </accessCondition>
111
+
112
+ <extension>
113
+ <authorRights>1</authorRights>
114
+
115
+ </extension>
116
+
117
+ <recordInfo>
118
+ <recordContentSource authority="marcorg">NNC</recordContentSource>
119
+ <recordCreationDate encoding="w3cdtf">2010-04-06 19:17:55 UTC</recordCreationDate>
120
+ <recordChangeDate encoding="w3cdtf">2010-04-16 16:29:58 UTC</recordChangeDate>
121
+ <recordIdentifier>1062</recordIdentifier>
122
+ <recordOrigin>Will Andersen; wla2103@columbia.edu</recordOrigin>
123
+ <languageOfCataloging>
124
+ <languageTerm authority="iso639-2b">eng</languageTerm>
125
+ </languageOfCataloging>
126
+ </recordInfo>
127
+
128
+ </mods>
129
+ </index:description></index:allMetadata>
130
+
@@ -0,0 +1,40 @@
1
+ <add>
2
+ <doc>
3
+ <field name="id">ac:125467</field>
4
+ <field name="format">Object</field>
5
+ <field name="pid">ac:125467</field>
6
+ <field name="internal_h">collection:3/</field>
7
+ <field name="member_of">collection:3</field>
8
+ <field name="member_of">ac:59</field>
9
+ <field name="title_display">A Source for Rubens's Modello of the Assumption and Coronation of the Virgin in Leningrad: A Case Study in the Response to Images Burlington Magazine</field>
10
+ <field name="title_search">A Source for Rubens's Modello of the Assumption and Coronation of the Virgin in Leningrad: A Case Study in the Response to Images Burlington Magazine</field>
11
+ <field name="author_search">freedberg, david</field>
12
+ <field name="author_facet">Freedberg, David</field>
13
+ <field name="authors_display">Freedberg, David</field>
14
+ <field name="date">1978</field>
15
+ <field name="genre_facet">Articles</field>
16
+ <field name="genre_search">Articles</field>
17
+ <field name="abstract"></field>
18
+ <field name="handle">http://hdl.handle.net/10022/AC:P:8619</field>
19
+ <field name="keyword_search"></field>
20
+ <field name="keyword_facet"></field>
21
+ <field name="subject">Fine arts</field>
22
+ <field name="subject_search">Fine arts</field>
23
+ <field name="tableOfContents"></field>
24
+ <field name="notes"></field>
25
+ <field name="notes"></field>
26
+ <field name="book_journal_title">Burlington Magazine</field>
27
+ <field name="book_author"></field>
28
+ <field name="issn"></field>
29
+ <field name="publisher"></field>
30
+ <field name="publisher_location"></field>
31
+ <field name="isbn"></field>
32
+ <field name="doi"></field>
33
+ <field name="media_type_facet">application/pdf</field>
34
+ <field name="type_of_resource_facet">text</field>
35
+ <field name="geographic_area"></field>
36
+ <field name="geographic_area_search"></field>
37
+ <field name="ac.fulltext_0"></field>
38
+ </doc>
39
+ </add>
40
+
@@ -0,0 +1,19 @@
1
+ - params:
2
+ :request: RELS-EXT
3
+ :pid: ac:4
4
+ uri: /get/ac:4/RELS-EXT
5
+ query: {}
6
+ - params:
7
+ :request: listMembers
8
+ :pid: ac:5
9
+ :sdef: ldpd:sdef.Aggregator
10
+ uri: /get/ac:5/ldpd:sdef.Aggregator/listMembers
11
+ query: {}
12
+ - params:
13
+ :request: getIndex
14
+ :pid: ac:6
15
+ :sdef: ldpd:sdef.Core
16
+ :profile: raw
17
+ uri: /get/ac:6/ldpd:sdef.Core/getIndex
18
+ query:
19
+ :profile: raw
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
8
+
9
+ require 'cul-fedora'
10
+ require "ruby-debug"
11
+
12
+ include Cul::Fedora
13
+
14
+ class Test::Unit::TestCase
15
+ end
@@ -0,0 +1,9 @@
1
+ require 'helper'
2
+
3
+ class TestCulFedora < Test::Unit::TestCase
4
+ should "run tests successfully" do
5
+ assert true
6
+ end
7
+
8
+
9
+ end
@@ -0,0 +1,62 @@
1
+ require "helper"
2
+
3
+ class TestFedoraItem < Test::Unit::TestCase
4
+ context "given a server" do
5
+ setup do
6
+ @config = YAML.load_file("private/config.yml")
7
+ @riurl = @config["fedora"]["riurl"]
8
+ @hc = HTTPClient.new()
9
+ @server = Server.new(@config["fedora"].merge(:http_client => @hc))
10
+ @item = Item.new(:server => @server, :uri => "info:fedora/ac:3")
11
+ end
12
+
13
+ should "initialize properly with a server and pid" do
14
+ assert @item
15
+
16
+ end
17
+
18
+ should "initialize properly with a server config and pid" do
19
+ assert Item.new(:server_config => @config["fedora"], :uri => "info:fedora/ac:3")
20
+ end
21
+
22
+ should "require a server and pid" do
23
+ assert_raise ArgumentError do
24
+ Item.new(:server => @server)
25
+ end
26
+ end
27
+
28
+ should "properly parse uris into pids" do
29
+ assert_equal @item.pid, "ac:3"
30
+ assert_equal Item.new(:server => @server, :pid => "ac:5").pid, "ac:5"
31
+
32
+ end
33
+
34
+ should "be able to compare" do
35
+
36
+ assert_equal @item, Item.new(:server => @server, :pid => "ac:3")
37
+ assert_equal @item, Item.new(:server => @server, :uri => "info:fedora/ac:3")
38
+ assert_equal @item, Item.new(:server_config => @config["fedora"], :pid => "ac:3")
39
+ end
40
+
41
+
42
+ should "be able to make requests" do
43
+
44
+ @server.expects(:request).with(:pid => "ac:3", :request => "RELS-EXT")
45
+
46
+ @item.request(:request => "RELS-EXT")
47
+ end
48
+
49
+ should "be able to call getIndex" do
50
+ @hc.expects(:get_content).with(@riurl + "/get/ac:3/ldpd:sdef.Core/getIndex", :profile => "raw").returns(nil)
51
+
52
+ @item.getIndex("raw")
53
+ end
54
+
55
+
56
+
57
+
58
+ end
59
+
60
+
61
+
62
+ end
@@ -0,0 +1,52 @@
1
+ require "helper"
2
+
3
+
4
+ class TestFedoraServer < Test::Unit::TestCase
5
+ context "given a fedora server" do
6
+
7
+ setup do
8
+ @config = YAML.load_file("private/config.yml")
9
+ @examples = YAML.load_file("test/data/example_server_requests.yml")
10
+ @riurl = @config["fedora"]["riurl"]
11
+ @server = Server.new(@config["fedora"])
12
+ end
13
+
14
+ should "require a riurl" do
15
+ assert_raise ArgumentError do
16
+ Server.new()
17
+ end
18
+ end
19
+
20
+ should "initialize properly" do
21
+ assert @server
22
+ end
23
+
24
+ should "be able to create an item from a uri or pid" do
25
+ item = Item.new(:server => @server, :pid => "ac:4")
26
+
27
+ assert_equal @server.item("ac:4"), item
28
+ assert_equal @server.item("info:fedora/ac:4"), item
29
+
30
+ end
31
+
32
+ should "be be able to generate paths out of sample requests" do
33
+ @examples.each do |test|
34
+ assert_equal @server.request_path(test["params"]), [@riurl + test["uri"], test["query"]]
35
+ end
36
+
37
+ end
38
+
39
+ should "be able to make httpclient calls from sample requests" do
40
+ mock_hc = mock()
41
+ server_with_hc = Server.new(@config["fedora"].merge(:http_client => mock_hc))
42
+
43
+
44
+ @examples.each do |test|
45
+ mock_hc.expects(:get_content).with(@riurl + test["uri"], test["query"]).returns(nil)
46
+
47
+ server_with_hc.request(test["params"])
48
+ end
49
+ end
50
+ end
51
+ end
52
+
@@ -0,0 +1,29 @@
1
+ require "helper"
2
+
3
+
4
+ class TestFedoraSolr < Test::Unit::TestCase
5
+ context "given a fedora server" do
6
+
7
+ setup do
8
+ @config = YAML.load_file("private/config.yml")
9
+ @solr = Solr.new(@config["solr"])
10
+ end
11
+
12
+ should "require a url" do
13
+ assert_raise ArgumentError do
14
+ Solr.new()
15
+ end
16
+ end
17
+
18
+ should "initialize properly" do
19
+ assert @solr
20
+ end
21
+
22
+ should "return an rsolr" do
23
+ assert_kind_of RSolr::Client, @solr.rsolr
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+
@@ -0,0 +1,17 @@
1
+ require 'helper'
2
+
3
+ class TestFedoraItem < Test::Unit::TestCase
4
+ context "given a fedora item" do
5
+ setup do
6
+ @fobj = Cul::Fedora::Item.new
7
+ end
8
+
9
+ should "initialize properly" do
10
+ assert @fobj
11
+
12
+ end
13
+
14
+
15
+ end
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cul-fedora
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - James Stuart
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-21 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: shoulda
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 43
44
+ segments:
45
+ - 0
46
+ - 9
47
+ - 8
48
+ version: 0.9.8
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: nokogiri
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: httpclient
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ hash: 3
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ type: :runtime
78
+ version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: active_support
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ type: :runtime
92
+ version_requirements: *id005
93
+ - !ruby/object:Gem::Dependency
94
+ name: rsolr
95
+ prerelease: false
96
+ requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ type: :runtime
106
+ version_requirements: *id006
107
+ - !ruby/object:Gem::Dependency
108
+ name: rsolr-ext
109
+ prerelease: false
110
+ requirement: &id007 !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ type: :runtime
120
+ version_requirements: *id007
121
+ description: Columbia-specific Fedora libraries
122
+ email: tastyhat@jamesstuart.org
123
+ executables: []
124
+
125
+ extensions: []
126
+
127
+ extra_rdoc_files:
128
+ - LICENSE
129
+ - README.rdoc
130
+ files:
131
+ - .document
132
+ - .gitignore
133
+ - LICENSE
134
+ - README.rdoc
135
+ - Rakefile
136
+ - VERSION
137
+ - cul-fedora.gemspec
138
+ - lib/cul-fedora.rb
139
+ - lib/cul-fedora/item.rb
140
+ - lib/cul-fedora/server.rb
141
+ - lib/cul-fedora/solr.rb
142
+ - test/data/125467_get_index.xml
143
+ - test/data/125467_solr_doc.xml
144
+ - test/data/example_server_requests.yml
145
+ - test/helper.rb
146
+ - test/test_cul-fedora.rb
147
+ - test/test_fedora_item.rb
148
+ - test/test_fedora_server.rb
149
+ - test/test_fedora_solr.rb
150
+ - test_fedora_item.rb
151
+ has_rdoc: true
152
+ homepage: http://github.com/tastyhat/cul-fedora
153
+ licenses: []
154
+
155
+ post_install_message:
156
+ rdoc_options:
157
+ - --charset=UTF-8
158
+ require_paths:
159
+ - lib
160
+ required_ruby_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ hash: 3
175
+ segments:
176
+ - 0
177
+ version: "0"
178
+ requirements: []
179
+
180
+ rubyforge_project:
181
+ rubygems_version: 1.3.7
182
+ signing_key:
183
+ specification_version: 3
184
+ summary: Columbia University Fedora Hooks
185
+ test_files:
186
+ - test/helper.rb
187
+ - test/test_cul-fedora.rb
188
+ - test/test_fedora_item.rb
189
+ - test/test_fedora_server.rb
190
+ - test/test_fedora_solr.rb