dor-services 8.5.0 → 8.6.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
  SHA256:
3
- metadata.gz: 61f15c16dd2f9137b47772916d0a6e44cbb374c88e4370e891ff51e8338feaf3
4
- data.tar.gz: fe8b53c9d1f31e4dd3e1f3ab91878a4d2f8e2cd999332e31d2d4004e4e4f152f
3
+ metadata.gz: a4ca8c1eccdd421044aafd1d3eee2de4e7492ca0c66f30e25bfd5befac06e832
4
+ data.tar.gz: b231f5ec8b86bfcc3160359911005b10f65bb5696f8b0428bdd554c7fcf113f6
5
5
  SHA512:
6
- metadata.gz: 1abaab49ac04961de4ee7a95ef5e3b9c10cb0fe331da1c88f20989c11cda7705878deb346bd7d1c16aac1ded1e0b2564138a3a043ad0a0d7c5931a76cf800b95
7
- data.tar.gz: 06f071e7d3e82b8bd2bac465b3667a2b09a010160f0cfe4ca847af56b906d5bcccb4a5c8eafe19ef0b470a73f3e62e7fc7b09ec981dc9be7144429fca5f9b0e3
6
+ metadata.gz: def0a4ffb45a50adcd1c805a55b9902ea86770838567eebf2b010bc01d4bf67e959c250589d0b74893c644c0c15737f6ba3d65e64012bc0fa4e7c2ed6f21cfa4
7
+ data.tar.gz: 929a1adcd6f2743f0666198429bd66b576a9e8ce52a95b2793f54fd7305cb725f537c42f0f415072a90299eded2bf4148c9a83b997f3be0462eddb5f59e58863
@@ -154,6 +154,22 @@ module Dor
154
154
  otherId(PREVIOUS_CATKEY_TYPE_ID)
155
155
  end
156
156
 
157
+ # Helper method to get the release tags as a nodeset
158
+ # @return [Nokogiri::XML::NodeSet] all release tags and their attributes
159
+ def release_tags
160
+ release_tags = ng_xml.xpath('//release')
161
+ return_hash = {}
162
+ release_tags.each do |release_tag|
163
+ hashed_node = release_tag_node_to_hash(release_tag)
164
+ if !return_hash[hashed_node[:to]].nil?
165
+ return_hash[hashed_node[:to]] << hashed_node[:attrs]
166
+ else
167
+ return_hash[hashed_node[:to]] = [hashed_node[:attrs]]
168
+ end
169
+ end
170
+ return_hash
171
+ end
172
+
157
173
  def to_solr(solr_doc = {}, *args)
158
174
  solr_doc = super(solr_doc, *args)
159
175
 
@@ -208,5 +224,29 @@ module Dor
208
224
  def prefix
209
225
  ''
210
226
  end
227
+
228
+ private
229
+
230
+ # Convert one release element into a Hash
231
+ # @param rtag [Nokogiri::XML::Element] the release tag element
232
+ # @return [Hash{:to, :attrs => String, Hash}] in the form of !{:to => String :attrs = Hash}
233
+ def release_tag_node_to_hash(rtag)
234
+ to = 'to'
235
+ release = 'release'
236
+ when_word = 'when' # TODO: Make to and when_word load from some config file instead of hardcoded here
237
+ attrs = rtag.attributes
238
+ return_hash = { to: attrs[to].value }
239
+ attrs.tap { |a| a.delete(to) }
240
+ attrs[release] = rtag.text.casecmp('true') == 0 # save release as a boolean
241
+ return_hash[:attrs] = attrs
242
+
243
+ # convert all the attrs beside :to to strings, they are currently Nokogiri::XML::Attr
244
+ (return_hash[:attrs].keys - [to]).each do |a|
245
+ return_hash[:attrs][a] = return_hash[:attrs][a].to_s if a != release
246
+ end
247
+
248
+ return_hash[:attrs][when_word] = Time.parse(return_hash[:attrs][when_word]) # convert when to a datetime
249
+ return_hash
250
+ end
211
251
  end # class
212
252
  end
@@ -121,7 +121,7 @@ module Dor
121
121
  delegate :catkey, :catkey=, :source_id, :source_id=,
122
122
  :objectId, :objectId=, :objectCreator, :objectCreator=,
123
123
  :objectLabel, :objectLabel=, :objectType, :objectType=,
124
- :other_ids=, :otherId, :tag=, :tags,
124
+ :other_ids=, :otherId, :tag=, :tags, :release_tags,
125
125
  :previous_catkeys, :content_type_tag, to: :identityMetadata
126
126
 
127
127
  def read_rights=(rights)
@@ -56,22 +56,6 @@ module Dor
56
56
  return_tags
57
57
  end
58
58
 
59
- # Helper method to get the release tags as a nodeset
60
- # @return [Nokogiri::XML::NodeSet] all release tags and their attributes
61
- def release_tags
62
- release_tags = item.identityMetadata.ng_xml.xpath('//release')
63
- return_hash = {}
64
- release_tags.each do |release_tag|
65
- hashed_node = release_tag_node_to_hash(release_tag)
66
- if !return_hash[hashed_node[:to]].nil?
67
- return_hash[hashed_node[:to]] << hashed_node[:attrs]
68
- else
69
- return_hash[hashed_node[:to]] = [hashed_node[:attrs]]
70
- end
71
- end
72
- return_hash
73
- end
74
-
75
59
  # Take a hash of tags as obtained via Dor::Item.release_tags and returns the newest tag for each namespace
76
60
  # @param tags [Hash] a hash of tags obtained via Dor::Item.release_tags or matching format
77
61
  # @return [Hash] a hash of latest tags for each to value
@@ -81,27 +65,7 @@ module Dor
81
65
 
82
66
  private
83
67
 
84
- # Convert one release element into a Hash
85
- # @param rtag [Nokogiri::XML::Element] the release tag element
86
- # @return [Hash{:to, :attrs => String, Hash}] in the form of !{:to => String :attrs = Hash}
87
- def release_tag_node_to_hash(rtag)
88
- to = 'to'
89
- release = 'release'
90
- when_word = 'when' # TODO: Make to and when_word load from some config file instead of hardcoded here
91
- attrs = rtag.attributes
92
- return_hash = { to: attrs[to].value }
93
- attrs.tap { |a| a.delete(to) }
94
- attrs[release] = rtag.text.casecmp('true') == 0 # save release as a boolean
95
- return_hash[:attrs] = attrs
96
-
97
- # convert all the attrs beside :to to strings, they are currently Nokogiri::XML::Attr
98
- (return_hash[:attrs].keys - [to]).each do |a|
99
- return_hash[:attrs][a] = return_hash[:attrs][a].to_s if a != release
100
- end
101
-
102
- return_hash[:attrs][when_word] = Time.parse(return_hash[:attrs][when_word]) # convert when to a datetime
103
- return_hash
104
- end
68
+ delegate :release_tags, to: :item
105
69
 
106
70
  # Take a hash of tags as obtained via Dor::Item.release_tags and returns all self tags
107
71
  # @param tags [Hash] a hash of tags obtained via Dor::Item.release_tags or matching format
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dor
4
- VERSION = '8.5.0'
4
+ VERSION = '8.6.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.5.0
4
+ version: 8.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein
@@ -20,7 +20,7 @@ authors:
20
20
  autorequire:
21
21
  bindir: bin
22
22
  cert_chain: []
23
- date: 2020-02-06 00:00:00.000000000 Z
23
+ date: 2020-02-13 00:00:00.000000000 Z
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: active-fedora