Created
June 8, 2017 14:02
-
-
Save moonhouse/48874acbf23dca6b2dc1515b3ec9c657 to your computer and use it in GitHub Desktop.
Create list of three letter acronyms used in a Slack team with example usage
This file contains hidden or 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
| require 'zip' | |
| require 'json' | |
| infile = ARGV[0] | |
| tlas = {} | |
| Zip::File.open(infile) do |zip_file| | |
| entries = zip_file.glob('*/*.json') | |
| entries.each do |entry| | |
| messages = JSON.parse(entry.get_input_stream.read) | |
| messages.each do |msg| | |
| matches = msg["text"].match(/\s([A-Z]{3,3})\s/) | |
| unless matches.nil? | |
| tlas[matches[1]] = msg["text"].gsub("\n"," ").gsub("\t"," ") | |
| end | |
| end | |
| end | |
| end | |
| tlas = Hash[tlas.sort_by{|k,v| k}] | |
| tlas.each do |tla,val| | |
| puts "#{tla}\t#{val}" | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment