Browse files

rbenv plugin for running a command across many rubies.

  • Loading branch information...
0 parents commit 391befe73c59891e39748e1e6aeeec9d7434dbe6 @chriseppstein chriseppstein committed Oct 12, 2011
Showing with 69 additions and 0 deletions.
  1. +30 −0 README.md
  2. +39 −0 bin/rbenv-each
30 README.md
@@ -0,0 +1,30 @@
+## Installation
+
+To install rbenv-each, clone this repository into your ~/.rbenv/plugins directory. (You'll need a recent version of rbenv that supports plugin bundles.)
+
+
+```
+$ mkdir -p ~/.rbenv/plugins
+$ cd ~/.rbenv/plugins
+$ git clone https://github.com/chriseppstein/rbenv-each.git
+```
+
+## Usage
+
+You can get help for the `each` command by passing the `-h` option.
+
+```
+$ rbenv each -h
+Usage: rbenv each [-v] ...
+ -v Verbose mode. Prints a header for each ruby.
+```
+
+Verbose mode will print a header for each ruby so you can distinguish
+the output.
+
+### Examples:
+
+```
+$ rbenv each bundle install
+$ rbenv each -v rake test
+```
39 bin/rbenv-each
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+verbose=0
+
+function usage() {
+ echo >&2 "Usage: rbenv each [-v] ..."
+ echo >&2 " -v Verbose mode. Prints a header for each ruby."
+}
+while getopts vh option
+do case "$option" in
+ v) verbose=1;;
+ h) usage; exit 0;;
+ [?])
+ usage;
+ exit 1;;
+ esac
+done
+shift $(($OPTIND-1))
+
+failed_rubies=""
+
+for ruby in `rbenv versions --bare`; do
+ if [ $verbose = 1 ]; then
+ echo -e "\033[1;34m[$ruby]:\033[0m \033[1;32m$@\033[0m";
+ echo -e "\033[1;34m******************************************************************\033[0m";
+ fi
+ RBENV_VERSION=$ruby $@
+ if [ $verbose = 1 ]; then
+ echo
+ fi
+ if [ $? != 0 ]; then
+ failed_rubies="$failed_rubies $ruby"
+ fi
+done
+
+if [ -n "$failed_rubies" ]; then
+ echo -e "\033[1;31mFAILED IN:$failed_rubies\033[0m"
+fi
+

0 comments on commit 391befe

Please sign in to comment.