class TeamHub::CrossReferencerImpl
Implements CrossReferencer
operations.
Attributes
Public Class Methods
# File lib/team_hub/cross_referencer.rb, line 140 def initialize(site_data) @site_data = site_data @team = @site_data['team'].map {|i| [i['name'], i]}.to_h end
Public Instance Methods
Cross-references groups with team members.
@param groups_name [String] site.data key identifying the group
collection, e.g. 'working_groups'
@param member_type_list_names [Array<String>] names of the properties
identifying lists of members, e.g. ['leads', 'members']
# File lib/team_hub/cross_referencer.rb, line 184 def xref_groups_and_team_members(groups_name, member_type_list_names) member_type_list_names.each do |member_type| CrossReferencer.create_xrefs( @site_data[groups_name], member_type, @team, groups_name) end @team.values.each {|i| (i[groups_name] || []).uniq! {|g| g['name']}} end
Cross-references geographic locations with team members, projects, and working groups.
xref_projects_and_team_members
and xref_working_groups_and_team_members should be called before this method.
The resulting site.data collection will be an Array<Hash> of location code =>
{'team' => Array, 'projects' => Array, 'working_groups' => Array}.
# File lib/team_hub/cross_referencer.rb, line 154 def xref_locations locations = CrossReferencer.create_index(@site_data['team'], 'location') locations = locations.to_a.sort!.map do |entry| team = entry[1] result = {'code' => entry[0], 'team' => team} ['projects', 'working_groups'].each do |category| items = Array.new team.each {|i| items.concat i[category] if i.member? category} items.sort_by!{|i| i['name']}.uniq! result[category] = items unless items.empty? end result end HashJoiner.join_array_data 'code', @site_data['locations'], locations end
Cross-references projects with team members. Replaces string-based site_data['team'] values with team member hashes.
# File lib/team_hub/cross_referencer.rb, line 172 def xref_projects_and_team_members projects = @site_data['projects'] projects.each {|p| p['team'] = p['team'].split(/, ?/) if p['team']} CrossReferencer.create_xrefs projects, 'team', @team, 'projects' end
Cross-references skillsets with team members.
@param skills [Array<String>] list of skill categories; may be
capitalized, though the members of site.data['team'] pertaining to each category should be lowercased
# File lib/team_hub/cross_referencer.rb, line 215 def xref_skills_and_team_members(categories) skills = categories.map {|category| [category, Hash.new]}.to_h @team.values.each do |i| skills.each do |category, xref| (i[category.downcase] || []).each {|s| (xref[s] ||= Array.new) << i} end end skills.delete_if {|category, skill_xref| skill_xref.empty?} @site_data['skills'] = skills unless skills.empty? end
Cross-references snippets with team members. Also sets site.data and @site_data.
# File lib/team_hub/cross_referencer.rb, line 194 def xref_snippets_and_team_members (@site_data['snippets'] || []).each do |timestamp, snippets| snippets.each do |snippet| (@team[snippet['name']]['snippets'] ||= Array.new) << snippet end # Since the snippets are naturally ordered in chronological order, # the last will be the latest. @site_data['snippets_latest'] = timestamp end @site_data['snippets_team_members'] = @team.values.select do |i| i['snippets'] end unless (@site_data['snippets'] || []).empty? end