Created
April 30, 2013 18:46
-
-
Save jtimberman/5490939 to your computer and use it in GitHub Desktop.
gem install roo; cla "string";
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 | |
# Author: Joshua Timberman <[email protected]> | |
# License: Apache Software License version 2 | |
# | |
# gem install roo | |
# | |
# Usage: | |
# cla name [] | |
# | |
# Where name is a string to search, and [] is an optional string to tell the script | |
# to download a fresh copy of the spreadsheet | |
# | |
# Example: | |
# cla timberman yes | |
$stderr.reopen("/dev/null", "w") | |
begin | |
require 'roo' | |
rescue LoadError | |
raise "Spreadsheet gem not available, exiting" | |
end | |
if ARGV[0].nil? | |
puts "Need a name to search" | |
raise | |
else | |
query = ARGV[0] | |
end | |
cla_xls = File.join(File.expand_path("~"), "Downloads", "CLAs.xls") | |
if ARGV[1] | |
puts "Retrieving #{cla_xls}" | |
system("wget -O #{cla_xls} http://wiki.opscode.com/download/attachments/7274740/CLAs.xls") | |
end | |
require 'iconv' | |
require 'open-uri' | |
spreadsheet = Excel.new(cla_xls) | |
spreadsheet.default_sheet = "ICLAs" | |
results = spreadsheet.column(2).grep(/#{query}/i) | |
puts "" | |
if results.length < 1 | |
puts "Not found: #{query}" | |
else | |
results.each {|r| puts r.gsub(/^\s/, '')} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment