Having a small ruby team, it is sometimes useful to get moving quickly by throwing a list of required gems at them. Our list was getting a tad long to manage manually, so I wrote a little script to automate installation of gems - the list resides in a YAML file of the following structure:
gems:
# FasterCSV is CSV, but faster, smaller, and cleaner.
fastercsv: '1.2.0'
# An implementation of SOAP 1.1 for Ruby.
soap4r: '>1.5.5'
# Client library for the AdWords API.
adwords4r: '0.7'
And here is the script. Use it by typing
./gems_install.rb gems_file.yml#!/usr/bin/env ruby
require 'yaml'
exit if ARGV.empty? && (puts "usage: gems_install.rb [GEMS_YML_FILE]").nil?
def gem_install(gem, version)
puts `sudo gem install #{gem} -f -y -v '#{version}'`
end
YAML::load_file(ARGV[0])['gems'].each { |gem| gem_install(gem[0], gem[1]) }
Short and useful, just like me :)








0 comments:
Post a Comment