team_api 0.0.7 → 0.0.8

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: 0ee9cac18edcb39d4c5dc0ce24e472ff1a25145b
4
- data.tar.gz: b84db5f63148774f44b08dc934356166307e5f22
3
+ metadata.gz: b082409d55f76bea8898d5a6c1de80965ba7c131
4
+ data.tar.gz: aba420884aa800ce9b6f081c7cb19f52d7322a02
5
5
  SHA512:
6
- metadata.gz: 3d2a04292be3885c6e4cdf84ff113fbff60b7ed10e2782814f86c1d983ae30d53794e55515ef1cfc542c3937e5ef2b7c9a944b16803c6a92ec2acab4464348d4
7
- data.tar.gz: d1c43012bf09539655bb5bf780757bb704694ea0017c87ce4247b1ffb028a42e209eddc1ddfea1d777dedb71b87c32406b772f4b8ccb25028f8a02794367d629
6
+ metadata.gz: c65b65e63296bc6df730f2fca3b79c9a1223170d73ae86d53d587556a6c195e891b761cba248ed37e1e2927170877044e53eac5cd1ff735ed523689d9fb4e439
7
+ data.tar.gz: 9992a74f2887388b34a7c5742a358b138e6bb77a7d01326c931ca73f12c2b90bf43305ddaf73cb57be6f5a3e6833c80a51f217525341eb85e456d9b682e7acec
@@ -17,8 +17,8 @@ module TeamApi
17
17
  def self.join_data(site)
18
18
  impl = JoinerImpl.new site
19
19
  site.data.merge! impl.collection_data
20
- impl.promote_or_remove_data
21
20
  impl.init_team_data site.data['team']
21
+ impl.promote_or_remove_data
22
22
  impl.join_project_data
23
23
  Api.add_self_links site
24
24
  impl.join_snippet_data
@@ -27,7 +27,7 @@ module TeamApi
27
27
 
28
28
  class TeamIndexer
29
29
  def initialize(data)
30
- @team = data
30
+ @team = (data || {}).dup
31
31
  end
32
32
 
33
33
  def team
@@ -66,13 +66,27 @@ module TeamApi
66
66
  .concat((team['private'] || {}).values)
67
67
  end
68
68
 
69
- def team_member_key(ref)
69
+ def team_member_key_by_type(ref)
70
70
  (ref.is_a? String) ? ref : (ref['id'] || ref['email'] || ref['github'])
71
71
  end
72
72
 
73
+ def team_member_key(ref)
74
+ key = team_member_key_by_type(ref).downcase
75
+ team_by_email[key] || team_by_github[key] || key
76
+ end
77
+
73
78
  def team_member_from_reference(reference)
79
+ key = team_member_key reference
80
+ if team['private']
81
+ team[key] || team['private'][key]
82
+ else
83
+ team[key]
84
+ end
85
+ end
86
+
87
+ def team_member_is_private(reference)
74
88
  key = team_member_key(reference).downcase
75
- team[key] || team[team_by_email[key] || team_by_github[key]]
89
+ team['private'] && team['private'][key]
76
90
  end
77
91
  end
78
92
 
@@ -141,6 +155,23 @@ module TeamApi
141
155
  data['errors'][name] = errors
142
156
  end
143
157
 
158
+ def should_exclude_member(reference)
159
+ @public_mode && team_indexer.team_member_is_private(reference)
160
+ end
161
+
162
+ def get_canonical_reference(reference, errors)
163
+ member = team_indexer.team_member_from_reference reference
164
+ if member.nil?
165
+ errors << 'Unknown Team Member: ' +
166
+ team_indexer.team_member_key(reference)
167
+ nil
168
+ elsif should_exclude_member(reference)
169
+ nil
170
+ else
171
+ member['name'].downcase
172
+ end
173
+ end
174
+
144
175
  # Replaces each member of team_list with a key into the team hash.
145
176
  # Values can be:
146
177
  # - Strings that are already team hash keys
@@ -150,15 +181,7 @@ module TeamApi
150
181
  # - Hashes that contain a 'github' property
151
182
  def join_team_list(team_list, errors)
152
183
  (team_list || []).map! do |reference|
153
- member = team_indexer.team_member_from_reference reference
154
-
155
- if member.nil?
156
- errors << 'Unknown Team Member: ' +
157
- team_indexer.team_member_key(reference)
158
- nil
159
- else
160
- member['name'].downcase
161
- end
184
+ get_canonical_reference reference, errors
162
185
  end.compact! || []
163
186
  end
164
187
 
@@ -1,5 +1,5 @@
1
1
  # @author Mike Bland (michael.bland@gsa.gov)
2
2
 
3
3
  module TeamApi
4
- VERSION = '0.0.7'
4
+ VERSION = '0.0.8'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: team_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bland