Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@juliandunn
Forked from jtimberman/cla.rb
Last active December 16, 2015 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliandunn/5491121 to your computer and use it in GitHub Desktop.
Save juliandunn/5491121 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Author: Joshua Timberman <joshua@opscode.com>
# 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
require 'rubygems'
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 'open-uri'
spreadsheet = Roo::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