solr_ead 0.7.5 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/lib/solr_ead/behaviors.rb +42 -18
- data/lib/solr_ead/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fac4816cdbd0c90b954d357444668ccce88ff511
|
4
|
+
data.tar.gz: b9a2fb99788ffa1b4f6be8dc95bbe59da4ee20a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93fcefab8ff1af3447e6c7da861d22f10d92696b0d1865c0f57fe70f01b0a395f1adcfa4f12c0e05035124c238c4b4fbb3697a76fe2e2a45e4bb218559b802c2
|
7
|
+
data.tar.gz: 63f11b18aa234f899dec25b16bb295bcb505895a2789f2e31512603ac7f2e754d043dc3f2930d3380448d37f6014d08817bbd5e3512f687da708eefd2bc8565f
|
data/.travis.yml
CHANGED
data/lib/solr_ead/behaviors.rb
CHANGED
@@ -67,19 +67,39 @@ module SolrEad::Behaviors
|
|
67
67
|
# These fields are used so that we may reconstruct placement of a single component
|
68
68
|
# within the hierarchy of the original ead.
|
69
69
|
def additional_component_fields(node, addl_fields = Hash.new)
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
# Clear or create the cache
|
72
|
+
@cache = {}
|
73
|
+
|
74
|
+
p_ids = parent_id_list(node)
|
75
|
+
p_unittitles = parent_unittitle_list(node)
|
76
|
+
|
77
|
+
addl_fields["id"] = [eadid(node), node.attr("id")].join
|
78
|
+
addl_fields[Solrizer.solr_name("ead", :stored_sortable)] = eadid(node)
|
72
79
|
addl_fields[Solrizer.solr_name("parent", :stored_sortable)] = node.parent.attr("id") unless node.parent.attr("id").nil?
|
73
|
-
addl_fields[Solrizer.solr_name("parent", :displayable)] =
|
74
|
-
addl_fields[Solrizer.solr_name("parent_unittitles", :displayable)] =
|
75
|
-
addl_fields[Solrizer.solr_name("parent_unittitles", :searchable)] =
|
76
|
-
addl_fields[Solrizer.solr_name("component_level", :type => :integer)] =
|
80
|
+
addl_fields[Solrizer.solr_name("parent", :displayable)] = p_ids
|
81
|
+
addl_fields[Solrizer.solr_name("parent_unittitles", :displayable)] = p_unittitles
|
82
|
+
addl_fields[Solrizer.solr_name("parent_unittitles", :searchable)] = p_unittitles
|
83
|
+
addl_fields[Solrizer.solr_name("component_level", :type => :integer)] = p_ids.length + 1
|
77
84
|
addl_fields[Solrizer.solr_name("component_children", :type => :boolean)] = component_children?(node)
|
78
|
-
addl_fields[Solrizer.solr_name("collection", :facetable)] = node
|
79
|
-
addl_fields[Solrizer.solr_name("collection", :displayable)] = node
|
80
|
-
addl_fields[Solrizer.solr_name("repository", :facetable)] = node
|
81
|
-
addl_fields[Solrizer.solr_name("repository", :displayable)] = node
|
82
|
-
|
85
|
+
addl_fields[Solrizer.solr_name("collection", :facetable)] = collection(node)
|
86
|
+
addl_fields[Solrizer.solr_name("collection", :displayable)] = collection(node)
|
87
|
+
addl_fields[Solrizer.solr_name("repository", :facetable)] = repository(node)
|
88
|
+
addl_fields[Solrizer.solr_name("repository", :displayable)] = repository(node)
|
89
|
+
addl_fields
|
90
|
+
end
|
91
|
+
|
92
|
+
# can these be made to use absolute xpaths?
|
93
|
+
def repository(node)
|
94
|
+
@cache[:repo] ||= node.xpath("/ead/archdesc/did/repository").text.strip
|
95
|
+
end
|
96
|
+
|
97
|
+
def collection(node)
|
98
|
+
@cache[:collection] ||= node.xpath("/ead/archdesc/did/unittitle").text
|
99
|
+
end
|
100
|
+
|
101
|
+
def eadid(node)
|
102
|
+
@cache[:eadid] ||= node.xpath("/ead/eadheader/eadid").text
|
83
103
|
end
|
84
104
|
|
85
105
|
# Array of all id attributes from the component's parent <c> nodes, sorted in descending order
|
@@ -99,19 +119,23 @@ module SolrEad::Behaviors
|
|
99
119
|
# the correct order, ex:
|
100
120
|
# ["Series I", "Subseries a", "Sub-subseries 1"]
|
101
121
|
# From there, you can assemble and display as you like.
|
102
|
-
def parent_unittitle_list(node, results = Array.new)
|
122
|
+
def parent_unittitle_list(node, results = ::Array.new)
|
103
123
|
while node.parent.name == "c"
|
104
124
|
parent = node.parent
|
105
|
-
|
106
|
-
results << get_title(part)
|
125
|
+
results << get_title(parent)
|
107
126
|
node = parent
|
108
127
|
end
|
109
|
-
|
128
|
+
results.reverse
|
129
|
+
end
|
130
|
+
|
131
|
+
def get_title(node)
|
132
|
+
@memtitle ||= Hash.new {|h, node| h[node.object_id] = _get_title(node)}
|
133
|
+
@memtitle[node]
|
110
134
|
end
|
111
135
|
|
112
|
-
def
|
113
|
-
title =
|
114
|
-
date =
|
136
|
+
def _get_title(node)
|
137
|
+
title = node.at_xpath("./did/unittitle")
|
138
|
+
date = node.at_xpath("./did/unitdate")
|
115
139
|
if !title.nil? and !title.content.empty?
|
116
140
|
return ead_to_html(title.content)
|
117
141
|
elsif !date.nil? and !date.content.empty?
|
data/lib/solr_ead/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solr_ead
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Wead
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: om
|
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
240
240
|
version: '0'
|
241
241
|
requirements: []
|
242
242
|
rubyforge_project:
|
243
|
-
rubygems_version: 2.6.
|
243
|
+
rubygems_version: 2.6.11
|
244
244
|
signing_key:
|
245
245
|
specification_version: 4
|
246
246
|
summary: A gem for indexing ead into solr using OM
|
@@ -259,4 +259,3 @@ test_files:
|
|
259
259
|
- spec/formatting_spec.rb
|
260
260
|
- spec/indexer_spec.rb
|
261
261
|
- spec/spec_helper.rb
|
262
|
-
has_rdoc:
|