team_api 0.0.1 → 0.0.2

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: ef00943a7c4a579f14f2c11d6281999c080de7d1
4
- data.tar.gz: 6f804bb279a6186020da17bbb59bfc5d07320e7b
3
+ metadata.gz: 9dff193621885b732e86f4796e1392e51f1d9025
4
+ data.tar.gz: b28833e5d8d114604ba3f2b76e0af14d132f842a
5
5
  SHA512:
6
- metadata.gz: 71fb30ac148f71fd39923947e0d78a284568a9650b5ef612df866c40c5c7cbce0626e08f168c8fc8bd220be65f6ecad1f501e7b5586edfd017796837419ee4b1
7
- data.tar.gz: a771ca5de1ebdb3f0ad1b8f9d23031391cd293ebaa5219674e470b64533da446a18c5eb7b1bcaa1d0a1f3966f1352a7c7224b3cbc81d195e0c5c977f5b97c42a
6
+ metadata.gz: 694d28f524bb623a665ea18b821d08966b0abcd4dcf8d23949bfc491c319e3ae0df785ba9dcb34e362813e23da0539a000d9a77ad4b44b168867028d430c1488
7
+ data.tar.gz: 38e1984b4bc4158481a5be7bd588b6c275b75156eadd32f73b77a392eb4fff2e12790f5448080aaf82a030e63de6b6a193af27d59b464fa5581f9f090594074d
@@ -9,8 +9,13 @@ module TeamApi
9
9
  # Canonicalizes the order and names of certain fields within site_data.
10
10
  def self.canonicalize_data(site_data)
11
11
  sort_collections site_data
12
- canonicalize_tag_category site_data['skills']
13
- canonicalize_tag_category site_data['interests']
12
+ %w(skills interests).each do |category|
13
+ xrefs = site_data[category]
14
+ canonicalize_tag_category xrefs
15
+ site_data['team'].values.each do |member|
16
+ canonicalize_tags_for_item category, xrefs, member
17
+ end
18
+ end
14
19
  end
15
20
 
16
21
  def self.sort_collections(site_data)
@@ -121,5 +126,11 @@ module TeamApi
121
126
  [slug, result]
122
127
  end
123
128
  private_class_method :consolidate_xrefs
129
+
130
+ def self.canonicalize_tags_for_item(category, xrefs, item)
131
+ return if item[category].nil?
132
+ item[category].each { |tag| tag['name'] = xrefs[tag['slug']]['name'] }
133
+ .sort_by! { |tag| tag['name'] }
134
+ end
124
135
  end
125
136
  end
@@ -110,10 +110,11 @@ module TeamApi
110
110
  # Builds cross-references between data sets.
111
111
  class CrossReferencer
112
112
  TEAM_FIELDS = %w(name last_name first_name full_name self)
113
- PROJECT_FIELDS = %w(name project self)
113
+ PROJECT_FIELDS = %w(name full_name self)
114
114
  WORKING_GROUP_FIELDS = %w(name full_name self)
115
115
  GUILD_FIELDS = %w(name full_name self)
116
116
  TAG_CATEGORIES = %w(skills interests)
117
+ TAG_XREF_FIELDS = %w(name slug self)
117
118
 
118
119
  # Build cross-references between data sets.
119
120
  # +site_data+:: Jekyll +site.data+ object
@@ -140,10 +141,20 @@ module TeamApi
140
141
  private_class_method :create_xref_data
141
142
 
142
143
  def self.xref_tags_and_team_members(site, tag_categories, team_xref)
144
+ team = (site.data['team'] || {})
143
145
  tag_categories.each do |category|
144
- xrefs = create_tag_xrefs(site, (site.data['team'] || {}).values,
145
- category, team_xref)
146
- site.data[category] = xrefs unless xrefs.empty?
146
+ xrefs = create_tag_xrefs(site, team.values, category, team_xref)
147
+ next if xrefs.empty?
148
+ site.data[category] = xrefs
149
+ replace_item_tags_with_xrefs category, xrefs, team.values
150
+ end
151
+ end
152
+
153
+ def self.replace_item_tags_with_xrefs(tag_category, tag_xrefs, items)
154
+ items.each do |item|
155
+ (item[tag_category] || []).map! do |tag|
156
+ tag_xrefs[tag].select { |field| TAG_XREF_FIELDS.include? field }
157
+ end
147
158
  end
148
159
  end
149
160
 
@@ -1,5 +1,5 @@
1
1
  # @author Mike Bland (michael.bland@gsa.gov)
2
2
 
3
3
  module TeamApi
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: team_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Bland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-10 00:00:00.000000000 Z
11
+ date: 2015-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler