team_api 0.0.10 → 0.0.12

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
  SHA1:
3
- metadata.gz: 7eea87de342e4012fb94967e8eab63740c879d4e
4
- data.tar.gz: 57088f7ff058759e77607ac23709c472d4e37053
3
+ metadata.gz: f31b401ffc417fa83d0ee449df251344d5a335ad
4
+ data.tar.gz: fa3955bd6883d49800ec50d351e778d41766a65d
5
5
  SHA512:
6
- metadata.gz: a356708d7b61188ba49b0ad3434cbc092df5ee8f0e19f1bfc8d10e14ad73fe25c8dd4150b8c19a37b39ce0f982ed30e86eed5513b18f5070f1fc702c845ccd97
7
- data.tar.gz: 30692609d6d3f5b4aa837e492ee87f11933ddcff7808459a9ed97015eb51a39dc5fbe5a71109f6db8fded6f5330f478010f6d14f54259a36c199953768008754
6
+ metadata.gz: 0154afdd77ec5af1a0aafef5109aa1fa5b618828842023f678166af63fce7d9e1225cea371a4b4b34853249ff28967ca5c49268fcf5062f919dfff3cf150ec95
7
+ data.tar.gz: a032bcbcdd2b2682aeb4107779084377ead02f3641751155ae906f04fe13d14add0957134b5f6efa6b391259ee1616e14e154c9241dddc04e54e73e96cc37ef5
data/lib/team_api/api.rb CHANGED
@@ -17,6 +17,7 @@ module TeamApi
17
17
  impl = ApiImpl.new site, BASEURL
18
18
  generate_collection_endpoints impl
19
19
  generate_tag_category_endpoints impl
20
+ impl.generate_schema_endpoint team_api_schema_location
20
21
  impl.generate_snippets_endpoints
21
22
  impl.generate_error_endpoint
22
23
  IndexPage.create site, impl.index_endpoints
@@ -58,5 +59,16 @@ module TeamApi
58
59
  end
59
60
 
60
61
  private_class_method :generate_tag_category_endpoints
62
+
63
+ def self.team_api_schema_location
64
+ about_yml = Gem::Specification.find_by_name 'about_yml'
65
+ if about_yml.nil?
66
+ nil
67
+ else
68
+ "#{about_yml.gem_dir}/lib/about_yml/schema.json"
69
+ end
70
+ end
71
+
72
+ private_class_method :team_api_schema_location
61
73
  end
62
74
  end
@@ -1,6 +1,7 @@
1
1
  require_relative 'endpoint'
2
2
  require_relative 'api_impl_snippet_helpers'
3
3
  require_relative 'api_impl_error_helpers'
4
+ require 'json'
4
5
 
5
6
  module TeamApi
6
7
  class ApiImpl
@@ -32,6 +33,15 @@ module TeamApi
32
33
  }
33
34
  end
34
35
 
36
+ def generate_schema_endpoint(schema_file_location)
37
+ return if schema_file_location.nil? || schema_file_location.empty?
38
+ file = File.read schema_file_location
39
+ items = JSON.parse file
40
+ generate_index_endpoint('schemas', 'Schemas',
41
+ 'Schema used to parse .about.yml files',
42
+ items)
43
+ end
44
+
35
45
  def generate_tag_category_endpoint(category)
36
46
  canonicalized = Canonicalizer.canonicalize(category)
37
47
  generate_index_endpoint(canonicalized, category,
@@ -19,7 +19,7 @@ module TeamApi
19
19
  # Returns a canonicalized, URL-friendly substitute for an arbitrary string.
20
20
  # +s+:: string to canonicalize
21
21
  def self.canonicalize(s)
22
- s.downcase.gsub(/\s+/, '-')
22
+ s.downcase.gsub(/\s+/, '-') unless s.nil?
23
23
  end
24
24
 
25
25
  def self.team_xrefs(team, usernames)
@@ -16,7 +16,7 @@ module TeamApi
16
16
  # +site+:: Jekyll site data object
17
17
  def self.join_data(site)
18
18
  impl = JoinerImpl.new site
19
- site.data.merge! impl.collection_data
19
+ impl.restructure_team_data!
20
20
  impl.init_team_data site.data['team']
21
21
  impl.promote_or_remove_data
22
22
  impl.join_project_data
@@ -37,6 +37,7 @@ module TeamApi
37
37
  def create_indexes
38
38
  team_by_email
39
39
  team_by_github
40
+ team_by_deprecated_name
40
41
  end
41
42
 
42
43
  # Returns an index of team member usernames keyed by email address.
@@ -49,6 +50,11 @@ module TeamApi
49
50
  @team_by_github ||= team_index_by_field 'github'
50
51
  end
51
52
 
53
+ # Returns an index of team member usernames keyed by deprecated names.
54
+ def team_by_deprecated_name
55
+ @team_by_deprecated_name ||= team_index_by_field 'deprecated_name'
56
+ end
57
+
52
58
  # Returns an index of team member usernames keyed by a particular field.
53
59
  def team_index_by_field(field)
54
60
  team_members.map do |member|
@@ -67,16 +73,17 @@ module TeamApi
67
73
  end
68
74
 
69
75
  def team_member_key_by_type(ref)
70
- (ref.is_a? String) ? ref : (ref['id'] || ref['email'] || ref['github'])
76
+ (ref.is_a? String) ? ref : (ref['id'] || ref['email'] || ref['github'] || ref['deprecated_name'])
71
77
  end
72
78
 
73
79
  def team_member_key(ref)
74
80
  key = team_member_key_by_type(ref).downcase
75
- team_by_email[key] || team_by_github[key] || key
81
+ team_by_email[key] || team_by_github[key] || team_by_deprecated_name[key] || key
76
82
  end
77
83
 
78
84
  def team_member_from_reference(reference)
79
85
  key = team_member_key reference
86
+
80
87
  if team['private']
81
88
  team[key] || team['private'][key]
82
89
  else
@@ -101,37 +108,22 @@ module TeamApi
101
108
  @public_mode = site.config['public']
102
109
  end
103
110
 
111
+ # Jekyll seems to be removing non-alpha characters from the team member
112
+ # names, causing the TeamIndexer to not be able to find any team member
113
+ # matches. This changes all of the team member keys back to what we expect.
114
+ def restructure_team_data!
115
+ if !site.data['team'].nil? && site.data['team'].respond_to?(:keys)
116
+ site.data['team'].keys.each do |key|
117
+ site.data['team'][site.data['team'][key]['name']] = site.data['team'].delete(key)
118
+ end
119
+ end
120
+ end
121
+
104
122
  def init_team_data(data)
105
123
  @team_indexer = TeamIndexer.new data
106
124
  team_indexer.create_indexes
107
125
  end
108
126
 
109
- def collection_data
110
- @collection_data ||= site.collections.map do |data_class, collection|
111
- groups = groups collection
112
- result = (groups[:public] || {})
113
- result.merge!('private' => groups[:private]) if groups[:private]
114
- [data_class, result] unless result.empty?
115
- end.compact.to_h
116
- end
117
-
118
- def groups(collection)
119
- collection.docs
120
- .select { |doc| doc.data['published'] != false }
121
- .group_by { |doc| doc_visibility doc }
122
- .map { |group, docs| [group, docs_data(docs)] }
123
- .to_h
124
- end
125
-
126
- def doc_visibility(doc)
127
- parent = File.basename File.dirname(doc.cleaned_relative_path)
128
- (parent == 'private') ? :private : :public
129
- end
130
-
131
- def docs_data(docs)
132
- docs.map { |doc| [doc.basename_without_ext, doc.data] }.to_h
133
- end
134
-
135
127
  def promote_or_remove_data
136
128
  private_data_method = public_mode ? :remove_data : :promote_data
137
129
  HashJoiner.send private_data_method, data, 'private'
@@ -162,6 +154,7 @@ module TeamApi
162
154
 
163
155
  def get_canonical_reference(reference, errors)
164
156
  member = team_indexer.team_member_from_reference reference
157
+
165
158
  if member.nil?
166
159
  errors << 'Unknown Team Member: ' +
167
160
  team_indexer.team_member_key(reference)
@@ -0,0 +1,86 @@
1
+ {
2
+ "team": {
3
+ "title": "team - [team.member].yml files",
4
+ "description": "Team member metadata",
5
+ "$schema": "http://json-schema.org/draft-04/hyper-schema",
6
+ "type": "object",
7
+ "properties": {
8
+ "name": {
9
+ "type": "string",
10
+ "description": "Unique name for the team member. Must match the file basename."
11
+ },
12
+ "deprecated_name": {
13
+ "type": "string",
14
+ "description": "Previous value for the `name` field (and the previous file name)"
15
+ },
16
+ "full_name": {
17
+ "type": "string",
18
+ "description": "Full proper name of the team member"
19
+ },
20
+ "first_name": {
21
+ "type": "string",
22
+ "description": "Team member's first name"
23
+ },
24
+ "last_name": {
25
+ "type": "string",
26
+ "description": "Team member's last name"
27
+ },
28
+ "github": {
29
+ "type": "string",
30
+ "description": "Team member's GitHub username"
31
+ },
32
+ "email": {
33
+ "type": "string",
34
+ "description": "Team member's email address"
35
+ },
36
+ "location": {
37
+ "type": "string",
38
+ "description": "Team member's location. Should match a value from the /locations endpoint."
39
+ },
40
+ "slack": {
41
+ "type": "string",
42
+ "description": "Team member's Slack username"
43
+ },
44
+ "resume": {
45
+ "type": "string",
46
+ "description": "URL for the team member's resume"
47
+ },
48
+ "okrs": {
49
+ "type": "string",
50
+ "description": "URL for the team member's OKRs"
51
+ },
52
+ "start_date": {
53
+ "type": "date",
54
+ "description": "Date on which team member started. Should be in ISO 8601 format (YYYY-MM-DD)"
55
+ },
56
+ "end_date": {
57
+ "type": "date",
58
+ "description": "Date on which team member left or is expected to leave. Should be in ISO 8601 format (YYYY-MM-DD)"
59
+ },
60
+ "skills": {
61
+ "type": "array",
62
+ "description": "Skills the team member can contribute to projects",
63
+ "items": {
64
+ "type": "string"
65
+ },
66
+ "uniqueItems": true
67
+ },
68
+ "interests": {
69
+ "type": "array",
70
+ "description": "Brief descriptions of team member's interests",
71
+ "items": {
72
+ "type": "string"
73
+ },
74
+ "uniqueItems": true
75
+ },
76
+ },
77
+ "required": [
78
+ "name",
79
+ "full_name",
80
+ "first_name",
81
+ "last_name",
82
+ "email",
83
+ "location"
84
+ ]
85
+ }
86
+ }
@@ -1,5 +1,5 @@
1
1
  # @author Mike Bland (michael.bland@gsa.gov)
2
2
 
3
3
  module TeamApi
4
- VERSION = '0.0.10'
4
+ VERSION = '0.0.12'
5
5
  end
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: team_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bland
8
+ - Amanda Robinson
9
+ - Carlo Costino
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2016-01-06 00:00:00.000000000 Z
13
+ date: 2016-02-11 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: bundler
@@ -196,6 +198,8 @@ description: Compiles information about team members, projects, etc. and exposes
196
198
  via a JSON API.
197
199
  email:
198
200
  - michael.bland@gsa.gov
201
+ - amanda.robinson@gsa.gov
202
+ - carlo.costino@gsa.gov
199
203
  executables: []
200
204
  extensions: []
201
205
  extra_rdoc_files: []
@@ -224,6 +228,7 @@ files:
224
228
  - lib/team_api/snippets.rb
225
229
  - lib/team_api/tag_canonicalizer.rb
226
230
  - lib/team_api/tag_categories.yml
231
+ - lib/team_api/team_member_schema.json
227
232
  - lib/team_api/version.rb
228
233
  homepage: https://github.com/18F/team_api
229
234
  licenses:
@@ -245,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
250
  version: '0'
246
251
  requirements: []
247
252
  rubyforge_project:
248
- rubygems_version: 2.4.5.1
253
+ rubygems_version: 2.5.1
249
254
  signing_key:
250
255
  specification_version: 4
251
256
  summary: Compiles team information and publishes it as a JSON API