Created
December 6, 2019 05:15
-
-
Save KingBain/5fd75b6857015f7d6feefbc57e96bd5e to your computer and use it in GitHub Desktop.
Can We Jan
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
require 'open-uri' | |
require 'csv' | |
require 'ostruct' | |
target = open('https://raw.githubusercontent.com/isthisblocked/isthisblockedinmydepartment.ca/master/src/data/organizations.csv') | |
targetCSV = CSV.parse(target, headers: true) | |
orgNames = Hash.new | |
targetCSV.each do |x| | |
org = OpenStruct.new(x.to_h) | |
orgNames[org.acronym_en] = org | |
end | |
target = open('https://raw.githubusercontent.com/isthisblocked/isthisblockedinmydepartment.ca/master/src/data/organization_status.csv') | |
targetCSV = CSV.parse(target, headers: true) | |
orgDetails = Hash.new | |
targetCSV.each do |x| | |
details = OpenStruct.new(x.to_h) | |
orgDetails[details.organization] = details | |
end | |
target = open('https://raw.githubusercontent.com/isthisblocked/isthisblockedinmydepartment.ca/master/src/data/services.csv') | |
targetCSV = CSV.parse(target, headers: true) | |
servNames = Hash.new | |
targetCSV.each do |x| | |
details = OpenStruct.new(x.to_h) | |
servNames[details.short_name] = details | |
end | |
puts "Captured Department Names:" | |
orgNames.keys.each do |x| | |
puts "Long Name: #{orgNames[x].name_en} Short Name: #{orgNames[x].acronym_en}" | |
end | |
puts "Select two departments via their short code" | |
print "Department 1: " | |
dept1 = gets.strip | |
#dept1 = "ssc" | |
print "Department 2: " | |
dept2 = gets.strip | |
#dept2="tbs" | |
if !orgNames.key?(dept1) | |
puts "Could Not find dept1" | |
end | |
if !orgNames.key?(dept2) | |
puts "Could Not find dept2" | |
end | |
dept1Details = orgDetails[dept1] | |
dept2Details = orgDetails[dept2] | |
puts | |
puts | |
puts "These platforms are open between the two " | |
#puts "Platform, #{dept1} and #{dept2}" | |
dept1Details.to_h.keys.each do |x| | |
if servNames.key?(x.to_s) | |
if dept1Details[x].match?(dept2Details[x]) && dept1Details[x].match?("open") | |
puts "- #{servNames[x.to_s].name}" | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment