discovery-indexer 1.0.1 → 2.0.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: 8e437973bb7eef26cf7064d979158f73eaf966ff
4
- data.tar.gz: e3ae3969e054bc29968c7b3eae6a6265408fdf07
3
+ metadata.gz: 6cda10dff64c547a94d5623b8d4eb99adc38fe55
4
+ data.tar.gz: 03f8ab54ee1cb990d54260f1d883b92869cc5d82
5
5
  SHA512:
6
- metadata.gz: 67ff874812cd6d183f98de76fb2e39eff6089bf58f9fb8ba9a45c06274f97d994adb05002fc1638049a1fb5419a87ee5f2e1d5eaca60d87e75a142054c20d779
7
- data.tar.gz: c2002f4a1d5609c76b3b1d2ff0b6082efe61e8a170d9658d8e715d210de6deeaa46f7755b62bb5ad07b6b4eb39549da132a48f0c3ff84ce2d110ade84db08db3
6
+ metadata.gz: d0ad8a756ae0904c5a9d61426a93895cbf1af6d46d4f61b36ff1ba94cf4beae0b671dcbe7e2c6ff419a811c3e71462f09db20e504e4949ee1da1075f8a16c1e4
7
+ data.tar.gz: b1c95061edb64ce7d585f583a3c932d0fc4fd220c591152decdb908ce8b1e40e9d0915cfb13ab0eaa9ab26061038b177f355fb37242700628d4e098b9ea6edf1
@@ -69,6 +69,14 @@ module DiscoveryIndexer
69
69
  # ["pc0065_b08_f10_i031.jp2","pc0065_b08_f10_i032.jp2"]
70
70
  attr_accessor :image_ids
71
71
 
72
+ # @!attribute [rw] sw_image_ids
73
+ # @return [Array] a list of the image ids and corresponding druids with %2F
74
+ # separator from the file and externalFile tags in the content_metadata
75
+ # specifically for Searchworks
76
+ # @example
77
+ # ["xx888yy9999%2Fpc0065_b08_f10_i031.jp2","aa111bb2222%2Fpc0065_b08_f10_i032.jp2"]
78
+ attr_accessor :sw_image_ids
79
+
72
80
  # @!attribute [rw] catkey
73
81
  # @return [String] the catkey attribute in identity_metadata
74
82
  attr_accessor :catkey
@@ -31,6 +31,7 @@ module DiscoveryIndexer
31
31
  purlxml_model.release_tags_hash = parse_release_tags_hash
32
32
  purlxml_model.file_ids = parse_file_ids
33
33
  purlxml_model.image_ids = parse_image_ids
34
+ purlxml_model.sw_image_ids = parse_sw_image_ids
34
35
  purlxml_model.catkey = parse_catkey
35
36
  purlxml_model.barcode = parse_barcode
36
37
  purlxml_model.label = parse_label
@@ -142,14 +143,28 @@ module DiscoveryIndexer
142
143
  dct
143
144
  end
144
145
 
145
- # the @id attribute of resource/file elements that match the image type, including extension
146
+ # the @id attribute of resource/file elements that match the image, page, or thumb resource type, including extension
146
147
  # @return [Array<String>] filenames
147
148
  def parse_image_ids
148
149
  content_md = parse_content_metadata
149
- return nil if content_md.nil?
150
+ return [] if content_md.nil?
150
151
  content_md.xpath('//resource[@type="page" or @type="image" or @type="thumb"]/file[@mimetype="image/jp2"]/@id').map(&:to_s)
151
152
  end
152
153
 
154
+ # the druid and id attribute of resource/file and objectId and fileId of the
155
+ # resource/externalFile elements that match the image, page, or thumb resource type, including extension
156
+ # Also, prepends the corresponding druid and %2F specifically for Searchworks use
157
+ # @return [Array<String>] filenames
158
+ def parse_sw_image_ids
159
+ content_md = parse_content_metadata
160
+ return [] if content_md.nil?
161
+ content_md.xpath('//resource[@type="page" or @type="image" or @type="thumb"]').map do |node|
162
+ node.xpath('./file[@mimetype="image/jp2"]/@id').map{ |x| "#{@druid}%2F" + x } << node.xpath('./externalFile[@mimetype="image/jp2"]').map do |y|
163
+ "#{y.attributes['objectId'].text.split(':').last}" + "%2F" + "#{y.attributes['fileId']}"
164
+ end
165
+ end.flatten
166
+ end
167
+
153
168
  def parse_sourceid
154
169
  get_value(@purlxml_ng_doc.css('//identityMetadata/sourceId'))
155
170
  end
@@ -165,14 +180,9 @@ module DiscoveryIndexer
165
180
  # the @id attribute of resource/file elements, including extension
166
181
  # @return [Array<String>] filenames
167
182
  def parse_file_ids
168
- ids = []
169
183
  content_md = parse_content_metadata
170
- return nil if content_md.nil?
171
- content_md.xpath('//resource/file/@id').each do |node|
172
- ids << node.text unless node.text.empty?
173
- end
174
- return nil if ids.empty?
175
- ids
184
+ return [] if content_md.nil?
185
+ content_md.xpath('//resource/file/@id').map { |x| x.text }.compact
176
186
  end
177
187
 
178
188
  # @return catkey value from the DOR identity_metadata, or nil if there is no catkey
@@ -1,3 +1,3 @@
1
1
  module DiscoveryIndexer
2
- VERSION = '1.0.1'
2
+ VERSION = '2.0.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discovery-indexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmed AlSum
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-19 00:00:00.000000000 Z
12
+ date: 2016-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri