Skip to content

Instantly share code, notes, and snippets.

@oem
Created December 18, 2010 12:06
Show Gist options
  • Save oem/746446 to your computer and use it in GitHub Desktop.
Save oem/746446 to your computer and use it in GitHub Desktop.
all my tools installed on this box?
#!/usr/bin/env ruby
# What's missing from my toolbox?
require "rubygems"
begin
require "term/ansicolor"
rescue LoadError
nil
end
class String
include Term::ANSIColor if defined? Term
def first_line
self.split(/\n/).delete_if{|s| s.empty?}.first
end
unless defined? Term
%w[red green].each do |color|
define_method "#{color}" do self end
end
end
end
tools = %w[rvm git brew node vi ruby rails]
tools.each do |tool|
(!`which #{tool}`.empty?) ? puts((tool + "\t=>\t" + `#{tool} --version`.first_line).green) : puts("#{tool} MISSING".first_line.red)
end
@oem
Copy link
Author

oem commented Dec 18, 2010

Tell me if there is a better way to optionally require/include a library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment