-
-
Save thephw/2ab31b691abdc01ee961 to your computer and use it in GitHub Desktop.
Lunching Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "CSV" | |
# Read data - team, first name, last name, email address | |
filepath = "./csv_data.csv" | |
max_per_table = 4 | |
people = CSV.read(filepath).map! do |row| | |
{ | |
team: row[0].rstrip, | |
first_name: row[1].rstrip, | |
last_name: row[2].rstrip, | |
email: row[3].rstrip | |
} | |
end.sort! do |x,y| | |
x[:team] <=> y[:team] | |
end | |
# Chunk by team and then zip into groups | |
teams = people.chunk{ |person| person[:team] }.map(&:last).shuffle | |
biggest_team = teams.delete(teams.max{|t| t.count}) | |
zipped_people = biggest_team.zip(*teams).flatten.compact | |
groups = zipped_people.each_slice(max_per_table) | |
# Output to screen | |
IO.popen("pbcopy", "w") do |pipe| | |
pipe.puts "## #{Date.current.to_s(:long)}\n" | |
groups.each.with_index do |group, index| | |
group_email_link = group.map{|p| p[:email]}.join(',') | |
pipe.puts "### [Group ##{index+1}](mailto:#{group_email_link})\n" | |
group.each do |person| | |
pipe.puts "- [#{person[:first_name]} #{person[:last_name]}](mailto:#{person[:email]}), #{person[:team]}" | |
end | |
pipe.puts "\n" | |
end | |
end | |
puts "Copied to clipboard!" | |
%x[open https://gist.github.com] | |
# TO DO - make calendar invites | |
# https://github.com/icalendar/icalendar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment