mais_person_client 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f40e726a92b17f54c949d9e1cd7ad4a6de1c3e8bac87aefaed9f6d28399bc1b
4
- data.tar.gz: ad5bb0a6f802899fe8a9b3741f812df1b13164bcdc1b608267762bd4b1ebd69f
3
+ metadata.gz: 7de338a07f3f6851a28604ddc6375e38928965e1a8a6d6647d0286a1cb6eb078
4
+ data.tar.gz: d1d6381bfeb5896caf46407522a699537bbee3c32247d46b9ad7618f3c8f1de4
5
5
  SHA512:
6
- metadata.gz: bd5fb21a2dbdde8c4e1def167deccc6db4642b0d53b8e1fc6e263dacc4b92e68030e9d026126f30868d0d06b37bef08fca92e76a0dc72c02c18f50dbac2a5d8a
7
- data.tar.gz: 955dfe576e735743881b6978360d6cb7f3f5cb26269c95f532103ae739df36f929bfee2886744b54c7b550e36ffe139d06d3ce1e087a2876fa9422f86154af19
6
+ metadata.gz: fa6af950fe76d47022e45f1694b29fe6ad9813613bf78debd3f3749fddfbc47abf5744e07f61182778c9e5903b3c24bbc26a6370e71ea1c387487ff1c953f30d
7
+ data.tar.gz: 1392a6fcc0e3672339d863171ba590d1ded0e8761c1798780e33cd3e62034b4f950b1de2139e1e562803cb822a7ab603c8c5bd148e056e609114639693405bf1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mais_person_client (0.0.3)
4
+ mais_person_client (0.0.4)
5
5
  activesupport (>= 4.2)
6
6
  faraday
7
7
  faraday-retry
@@ -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 primary_org_id
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,30 @@ 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
+ affiliations.none? do |affiliation|
199
+ affiliation.affdata.any? do |affdata|
200
+ affdata.type == 'academic_council' && affdata.value&.downcase == 'non-member'
201
+ end
202
+ end
203
+ end
204
+
181
205
  # Identifiers (multiple)
182
206
  def identifiers
183
207
  xml.xpath('//identifier').map do |id_node|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class MaisPersonClient
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mais_person_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Mangiafico