mais_person_client 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/mais_person_client/affiliations.rb +2 -2
- data/lib/mais_person_client/person.rb +27 -0
- data/lib/mais_person_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d74b15a8643908f6d602dd5db2fa546ab0164b1378d1fccd590ca01c086cd601
|
4
|
+
data.tar.gz: 4673145e20dc3a2549a9d75e94e0e11d3c0f658df789b8ae58010af62dde78dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0186d4f53e216f98ceb67a93c34417ccbe7334e76efa8505e3a20c0f69fe6c31daaec4f6ac154cc03b83d8cc55d23452ad4158fe7712ae431b8c55cf536cae6e'
|
7
|
+
data.tar.gz: f20445c33c14650a3b82093ab5c8f5909ecc1c6f7412c121eb6e86641161059ac43b729610857c5395d2038716936dc9688eddb90a6771a24cdab6b992e6efbe
|
data/Gemfile.lock
CHANGED
@@ -77,10 +77,10 @@ class MaisPersonClient
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def org_ids
|
80
|
-
xml.xpath('//organization/@adminid').map(&:value)
|
80
|
+
xml.xpath('//organization/@adminid').map(&:value).uniq.compact
|
81
81
|
end
|
82
82
|
|
83
|
-
def
|
83
|
+
def primary_org_code
|
84
84
|
org_node = xml.at_xpath("//affiliation[@affnum='1']//organization")
|
85
85
|
org_node ? org_node['adminid'] : nil
|
86
86
|
end
|
@@ -178,6 +178,33 @@ class MaisPersonClient
|
|
178
178
|
xml.xpath('//affiliation').map { |aff_node| build_affiliation(aff_node) }
|
179
179
|
end
|
180
180
|
|
181
|
+
# returns the primary role/type for the person (from affiliation with affnum 1)
|
182
|
+
def primary_role
|
183
|
+
affiliations.find { |aff| aff.affnum == '1' }&.type
|
184
|
+
end
|
185
|
+
|
186
|
+
# returns the org_id for the primary affiliation (affnum == '1')
|
187
|
+
def primary_org_code
|
188
|
+
# Find the affiliation with affnum == '1' and return the department's organization adminid
|
189
|
+
aff = affiliations.find { |a| a.affnum == '1' }
|
190
|
+
return nil unless aff
|
191
|
+
|
192
|
+
# department may be nil; department.adminid holds the org code
|
193
|
+
aff.department&.adminid
|
194
|
+
end
|
195
|
+
|
196
|
+
# indicates if a person is a member of the academic council
|
197
|
+
def academic_council?
|
198
|
+
# If there are no affiliations, the person is not a member of the academic council
|
199
|
+
return false if affiliations.empty?
|
200
|
+
|
201
|
+
affiliations.none? do |affiliation|
|
202
|
+
affiliation.affdata.any? do |affdata|
|
203
|
+
affdata.type == 'academic_council' && affdata.value&.downcase == 'non-member'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
181
208
|
# Identifiers (multiple)
|
182
209
|
def identifiers
|
183
210
|
xml.xpath('//identifier').map do |id_node|
|