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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fdef7b50871ffde537ec7625ce858bf30a780bd
4
- data.tar.gz: d54d41cc1719a04954100e77f789f97c02033107
3
+ metadata.gz: fac4816cdbd0c90b954d357444668ccce88ff511
4
+ data.tar.gz: b9a2fb99788ffa1b4f6be8dc95bbe59da4ee20a3
5
5
  SHA512:
6
- metadata.gz: 4e1344df2d9ba2880aa8f5fb1feeea3acb9cc36fbd6a3d00dda3866a55488757e333fe32b19cc9e8b07c718cc5980935f319836e48ddfa1ab28bb8e17d930113
7
- data.tar.gz: 0121dea63780951b4395a9d4c4510aa025cd39414c417aed19b10b30411901d191a0eb2b96d0f6c40e414dedcbf0369e95d75e00077ff0c7c226e96681c5b753
6
+ metadata.gz: 93fcefab8ff1af3447e6c7da861d22f10d92696b0d1865c0f57fe70f01b0a395f1adcfa4f12c0e05035124c238c4b4fbb3697a76fe2e2a45e4bb218559b802c2
7
+ data.tar.gz: 63f11b18aa234f899dec25b16bb295bcb505895a2789f2e31512603ac7f2e754d043dc3f2930d3380448d37f6014d08817bbd5e3512f687da708eefd2bc8565f
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0
4
3
  - 2.1
5
4
  - 2.2
6
5
  - 2.2.7
@@ -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
- addl_fields["id"] = [node.xpath("//eadid").text, node.attr("id")].join
71
- addl_fields[Solrizer.solr_name("ead", :stored_sortable)] = node.xpath("//eadid").text
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)] = parent_id_list(node)
74
- addl_fields[Solrizer.solr_name("parent_unittitles", :displayable)] = parent_unittitle_list(node)
75
- addl_fields[Solrizer.solr_name("parent_unittitles", :searchable)] = parent_unittitle_list(node)
76
- addl_fields[Solrizer.solr_name("component_level", :type => :integer)] = parent_id_list(node).length + 1
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.xpath("//archdesc/did/unittitle").text
79
- addl_fields[Solrizer.solr_name("collection", :displayable)] = node.xpath("//archdesc/did/unittitle").text
80
- addl_fields[Solrizer.solr_name("repository", :facetable)] = node.xpath("//archdesc/did/repository").text.strip
81
- addl_fields[Solrizer.solr_name("repository", :displayable)] = node.xpath("//archdesc/did/repository").text.strip
82
- return addl_fields
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
- part = Nokogiri::XML(parent.to_xml)
106
- results << get_title(part)
125
+ results << get_title(parent)
107
126
  node = parent
108
127
  end
109
- return results.reverse
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 get_title(xml)
113
- title = xml.at("/c/did/unittitle")
114
- date = xml.at("/c/did/unitdate")
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?
@@ -1,3 +1,3 @@
1
1
  module SolrEad
2
- VERSION = "0.7.5"
2
+ VERSION = "0.8.0"
3
3
  end
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.7.5
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-05-11 00:00:00.000000000 Z
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.10
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: