From 9f551b7f0bd10676a2e9bdf6a295715c9e0e4872 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Mon, 1 Jul 2013 11:40:27 +0100 Subject: [PATCH 01/32] First pass at a debian package --- Makefile | 17 +++++++++++------ debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 14 ++++++++++++++ debian/copyright | 24 ++++++++++++++++++++++++ debian/docs | 4 ++++ debian/rules | 23 +++++++++++++++++++++++ debian/source/format | 1 + 8 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/docs create mode 100755 debian/rules create mode 100644 debian/source/format diff --git a/Makefile b/Makefile index bc059772..aba9514f 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,10 @@ PKG_NAME=$(NAME)-$(VERSION) PKG=$(PKG_DIR)/$(PKG_NAME).tar.gz SIG=$(PKG).asc +DESTDIR?=/ PREFIX?=/usr/local -DOC_DIR=$(PREFIX)/share/doc/$(PKG_NAME) +INSTALL_PATH=$(DESTDIR)/$(PREFIX) +DOC_DIR=$(INSTALL_PATH)/share/doc/$(PKG_NAME) pkg: mkdir $(PKG_DIR) @@ -53,14 +55,17 @@ tag: release: tag download sign -install: - for dir in $(INSTALL_DIRS); do mkdir -p $(PREFIX)/$$dir; done - for file in $(INSTALL_FILES); do cp $$file $(PREFIX)/$$file; done +install_files: + for dir in $(INSTALL_DIRS); do mkdir -p $(INSTALL_PATH)/$$dir; done + for file in $(INSTALL_FILES); do cp $$file $(INSTALL_PATH)/$$file; done + +install: install_files mkdir -p $(DOC_DIR) cp -r $(DOC_FILES) $(DOC_DIR)/ uninstall: - for file in $(INSTALL_FILES); do rm -f $(PREFIX)/$$file; done + for file in $(INSTALL_FILES); do rm -f $(INSTALL_PATH)/$$file; done rm -rf $(DOC_DIR) -.PHONY: build download sign verify clean test tag release install uninstall all +.PHONY: build download sign verify clean test tag release \ + install_files install uninstall all diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..15769b82 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +chruby (0.3.6) unstable; urgency=low + + * Initial package + + -- Alex Young Mon, 01 Jul 2013 10:20:24 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..8bf9bc00 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: chruby +Section: devel +Priority: extra +Maintainer: Alex Young +Build-Depends: debhelper (>= 8.0.0) +Standards-Version: 3.9.3 +Homepage: https://github.com/postmodern/chruby#readme + +Package: chruby +Architecture: all +Depends: ${misc:Depends} +Description: Changes the current Ruby. + Updates $PATH, $GEM_HOME and $GEM_PATH to use rubies installed under + /opt/rubies or $HOME/.rubies. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..0008496e --- /dev/null +++ b/debian/copyright @@ -0,0 +1,24 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: chruby +Source: https://github.com/postmodern/chruby + +Files: * +Copyright: 2012-2013 Hal Brodigan +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/debian/docs b/debian/docs new file mode 100644 index 00000000..637eee12 --- /dev/null +++ b/debian/docs @@ -0,0 +1,4 @@ +LICENSE.txt +README.md +ChangeLog.md +CONTRIBUTING.md diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..bb05b903 --- /dev/null +++ b/debian/rules @@ -0,0 +1,23 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +# This skips the doc files, which would otherwise get duplicated by the make +# install task. +override_dh_auto_install-indep: + dh_auto_install -- install_files + +override_dh_auto_test-indep: + +override_dh_auto_build-indep: + +%: + PREFIX=/usr dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..89ae9db8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) From e30f98d2b0aa7357b3a9f64206c9a9929fbd6eb5 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Mon, 1 Jul 2013 15:36:10 +0100 Subject: [PATCH 02/32] Fix debian/rules to only run make install_files --- debian/rules | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/debian/rules b/debian/rules index bb05b903..caa82000 100755 --- a/debian/rules +++ b/debian/rules @@ -13,11 +13,12 @@ # This skips the doc files, which would otherwise get duplicated by the make # install task. override_dh_auto_install-indep: - dh_auto_install -- install_files + PREFIX=/usr DESTDIR=$$(pwd)/debian/chruby $(MAKE) install_files override_dh_auto_test-indep: override_dh_auto_build-indep: + %: - PREFIX=/usr dh $@ + dh $@ From f2dbc9dbe1823cc640fa325d8c4f797c55b73b9d Mon Sep 17 00:00:00 2001 From: Alex Young Date: Mon, 1 Jul 2013 15:45:00 +0100 Subject: [PATCH 03/32] Update .gigignore to ignore debian packaging artifacts --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 56c9706e..c26cb17f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ pkg/*.tar.gz pkg/*.tar.bz2 pkg/*.zip test/rubies +debian/chruby* +debian/files From 4f2a2c0770b3ef2ddae21c646400f3a47269a649 Mon Sep 17 00:00:00 2001 From: Alex Young Date: Sat, 6 Jul 2013 17:59:13 +0100 Subject: [PATCH 04/32] Restore the full `make install` task In order not to duplicate the documentation, this patch makes the DOC_DIR variable overridable by environment variable, and changes the default path *not* to include the version number. --- Makefile | 6 ++---- debian/rules | 9 +-------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index aba9514f..04cd136f 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ SIG=$(PKG).asc DESTDIR?=/ PREFIX?=/usr/local INSTALL_PATH=$(DESTDIR)/$(PREFIX) -DOC_DIR=$(INSTALL_PATH)/share/doc/$(PKG_NAME) +DOC_DIR?=$(INSTALL_PATH)/share/doc/$(NAME) pkg: mkdir $(PKG_DIR) @@ -55,11 +55,9 @@ tag: release: tag download sign -install_files: +install: for dir in $(INSTALL_DIRS); do mkdir -p $(INSTALL_PATH)/$$dir; done for file in $(INSTALL_FILES); do cp $$file $(INSTALL_PATH)/$$file; done - -install: install_files mkdir -p $(DOC_DIR) cp -r $(DOC_FILES) $(DOC_DIR)/ diff --git a/debian/rules b/debian/rules index caa82000..956227c9 100755 --- a/debian/rules +++ b/debian/rules @@ -9,16 +9,9 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 - -# This skips the doc files, which would otherwise get duplicated by the make -# install task. -override_dh_auto_install-indep: - PREFIX=/usr DESTDIR=$$(pwd)/debian/chruby $(MAKE) install_files - override_dh_auto_test-indep: override_dh_auto_build-indep: - %: - dh $@ + PREFIX=/usr dh $@ From 9af492354d1173935c0bf13d271dfa1b23961aba Mon Sep 17 00:00:00 2001 From: Postmodern Date: Tue, 15 Jan 2013 13:38:57 -0800 Subject: [PATCH 05/32] Version bump to 0.4.0. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 205c0c82..edb24fa0 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ NAME=chruby -VERSION=0.3.7 +VERSION=0.4.0 AUTHOR=postmodern URL=https://github.com/$(AUTHOR)/$(NAME) From c77b750a7cc58e3723f627c63334954ccddc0edc Mon Sep 17 00:00:00 2001 From: Postmodern Date: Tue, 15 Jan 2013 13:41:24 -0800 Subject: [PATCH 06/32] Also export RUBY_PATCHLEVEL (issue #62). --- share/chruby/chruby.sh | 1 + test/chruby_use_test.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/share/chruby/chruby.sh b/share/chruby/chruby.sh index 4318b501..ce3aec66 100644 --- a/share/chruby/chruby.sh +++ b/share/chruby/chruby.sh @@ -44,6 +44,7 @@ function chruby_use() begin; require 'rubygems'; rescue LoadError; end puts "export RUBY_ENGINE=#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'};" puts "export RUBY_VERSION=#{RUBY_VERSION};" +puts "export RUBY_PATCHLEVEL=#{RUBY_PATCHLEVEL};" puts "export GEM_ROOT=#{Gem.default_dir.inspect};" if defined?(Gem) EOF` diff --git a/test/chruby_use_test.sh b/test/chruby_use_test.sh index 7e2c8ead..01d66e48 100755 --- a/test/chruby_use_test.sh +++ b/test/chruby_use_test.sh @@ -12,6 +12,7 @@ test_chruby_use() assertEquals "invalid RUBY_ROOT" "$TEST_RUBY_ROOT" "$RUBY_ROOT" assertEquals "invalid RUBY_ENGINE" "$TEST_RUBY_ENGINE" "$RUBY_ENGINE" assertEquals "invalid RUBY_VERSION" "$TEST_RUBY_VERSION" "$RUBY_VERSION" + assertEquals "invalid RUBY_PATCHLEVEL" "$TEST_RUBY_PATCHLEVEL" "$RUBY_PATCHLEVEL" assertEquals "invalid GEM_ROOT" "$TEST_RUBY_ROOT/lib/ruby/gems/$TEST_RUBY_API" "$GEM_ROOT" assertEquals "invalid GEM_HOME" "$TEST_GEM_HOME" "$GEM_HOME" assertEquals "invalid GEM_PATH" "$GEM_HOME:$GEM_ROOT" "$GEM_PATH" From ec135251a2dfed30f06a7c2ba3bfd0192974289c Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Tue, 15 Jan 2013 14:55:24 -0800 Subject: [PATCH 07/32] updated formatting and env descriptions * Pulled in @HavenWood's chruby man page. --- docs/chruby.1 | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/chruby.md | 93 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 docs/chruby.1 create mode 100644 docs/chruby.md diff --git a/docs/chruby.1 b/docs/chruby.1 new file mode 100644 index 00000000..ca52536a --- /dev/null +++ b/docs/chruby.1 @@ -0,0 +1,94 @@ +.TH +.BR chruby (1) +\-\- Changes the current Ruby. +.SH SYNOPSIS +.PP +\fB\fCchruby\fR [] [] +.SH ARGUMENTS +.PP +\fIRUBY|VERSION\fP + Change current Ruby based on fuzzy matching of Ruby by name. +.PP +\fIsystem\fP + Change current Ruby to system Ruby. +.PP +\fIRUBY_OPTS\fP + Additional optional arguements to pass to Ruby. +.SH OPTIONS +.PP +\fB\fC-h\fR, \fB\fC--help\fR +.SH DESCRIPTION +.PP +Changes the current Ruby version by correctly setting the appropriate environment variables. +.PP +https://github.com/postmodern/chruby/blob/master/README.md +.UR https://github.com/postmodern/chruby/blob/master/README.md +.UE +.SH EXAMPLES +.PP +List available Rubies: + $ chruby + ruby\-1.9.3\-p362 + jruby\-1.7.2 + rubinius\-2.0.0\-rc1 +.PP +Select a Ruby: + $ chruby 1.9.3 + $ chruby + * ruby\-1.9.3\-p362 + jruby\-1.7.2 + rubinius\-2.0.0\-rc1 +.PP +Switch to JRuby in 1.9 mode: + $ chruby jruby \-\-1.9 +.PP +Switch back to system Ruby: + $ chruby system +.PP +Switch to an arbitrary Ruby on the fly: + $ chruby_use /path/to/ruby +.SH FILES +.PP +\fI/opt/rubies\fP + Primary default Ruby install location. +.PP +\fI~/.rubies/\fP + Secondary default Ruby install location. +.PP +\fI/etc/profile.d/chruby.sh\fP + Application environment settings for chruby. +.PP +\fI~/.gem/$ruby/$version\fP + Default gem install location. +.SH ENVIRONMENT +.PP +\fIPATH\fP + Updates the PATH environment variable to include Rubies and RubyGems bin/ directories. +.PP +\fIGEM_HOME\fP + Default repository location for gem installation. +.PP +\fIGEM_PATH\fP + A colon\-separated list of gem repository directories. +.PP +\fIGEM_ROOT\fP +.PP +\fIRUBY_ROOT\fP +.PP +\fIRUBY_ENGINE\fP + Name of Ruby implementation. +.PP +\fIRUBY_VERSION\fP + Ruby version number. +.PP +\fIRUBYOPT\fP + Optionally set if additional Ruby options are given. +.SH AUTHOR +.PP +Postmodern postmodern.mod3\@gmail.com +.MT postmodern.mod3@gmail.com +.ME . +.SH SEE ALSO +.PP +.BR ruby (1), +.BR gem (1) \ No newline at end of file diff --git a/docs/chruby.md b/docs/chruby.md new file mode 100644 index 00000000..18352780 --- /dev/null +++ b/docs/chruby.md @@ -0,0 +1,93 @@ +# chruby(1) -- Changes the current Ruby. + +## SYNOPSIS + +`chruby` [] [] + +## ARGUMENTS + +*RUBY|VERSION* + Change current Ruby based on fuzzy matching of Ruby by name. + +*system* + Change current Ruby to system Ruby. + +*RUBY_OPTS* + Additional optional arguements to pass to Ruby. + +## OPTIONS + +`-h`, `--help` + +## DESCRIPTION +Changes the current Ruby version by correctly setting the appropriate environment variables. + +[https://github.com/postmodern/chruby/blob/master/README.md](https://github.com/postmodern/chruby/blob/master/README.md) + +## EXAMPLES + +List available Rubies: + $ chruby + ruby-1.9.3-p362 + jruby-1.7.2 + rubinius-2.0.0-rc1 + +Select a Ruby: + $ chruby 1.9.3 + $ chruby + * ruby-1.9.3-p362 + jruby-1.7.2 + rubinius-2.0.0-rc1 + +Switch to JRuby in 1.9 mode: + $ chruby jruby --1.9 + +Switch back to system Ruby: + $ chruby system + +Switch to an arbitrary Ruby on the fly: + $ chruby_use /path/to/ruby + +##FILES + +*/opt/rubies* + Primary default Ruby install location. + +*~/.rubies/* + Secondary default Ruby install location. + +*/etc/profile.d/chruby.sh* + Application environment settings for chruby. + +*~/.gem/$ruby/$version* + Default gem install location. + +##ENVIRONMENT + +*PATH* + Updates the PATH environment variable to include Rubies and RubyGems bin/ directories. + +*GEM_HOME* + Default repository location for gem installation. + +*GEM_PATH* + A colon-separated list of gem repository directories. + +*GEM_ROOT* + +*RUBY_ROOT* + +*RUBY_ENGINE* + Name of Ruby implementation. + +*RUBY_VERSION* + Ruby version number. + +*RUBYOPT* + Optionally set if additional Ruby options are given. + +##AUTHOR +Postmodern [postmodern.mod3\@gmail.com](mailto:postmodern.mod3\@gmail.com). + +##SEE ALSO +ruby(1), gem(1) \ No newline at end of file From 63dae6abe579fabe839f14343b8212ac4a1cbd68 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Tue, 15 Jan 2013 15:21:40 -0800 Subject: [PATCH 08/32] Renamed chruby.md to chruby.1.md. --- docs/chruby.md => doc/man/chruby.1.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/chruby.md => doc/man/chruby.1.md (100%) diff --git a/docs/chruby.md b/doc/man/chruby.1.md similarity index 100% rename from docs/chruby.md rename to doc/man/chruby.1.md From 09c6c3ee0499d4e242ac2d2bf4d74a978dc5030c Mon Sep 17 00:00:00 2001 From: Postmodern Date: Tue, 15 Jan 2013 15:24:39 -0800 Subject: [PATCH 09/32] Moved docs/chruby.1 into share/man/man1/ --- {docs => share/man/man1}/chruby.1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {docs => share/man/man1}/chruby.1 (100%) diff --git a/docs/chruby.1 b/share/man/man1/chruby.1 similarity index 100% rename from docs/chruby.1 rename to share/man/man1/chruby.1 From 2c53469b95a9fba6dcc73f402dfdc3c8c102d048 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Tue, 15 Jan 2013 15:26:41 -0800 Subject: [PATCH 10/32] Added a basic man page task. --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index edb24fa0..8ffbddd6 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,12 @@ DOC_DIR=$(PREFIX)/share/doc/$(PKG_NAME) pkg: mkdir $(PKG_DIR) +share/man/man1/chruby.1: doc/man/chruby.1.md + md2man doc/man/chruby.1.md > share/man/man1/chruby.1 + +man: share/man/man1/chruby.1 + git commit -m "Updated the man pages" doc/man/chruby.1.md share/man/man1/chruby.1 + download: pkg wget -O $(PKG) $(URL)/archive/v$(VERSION).tar.gz @@ -63,4 +69,4 @@ uninstall: for file in $(INSTALL_FILES); do rm -f $(PREFIX)/$$file; done rm -rf $(DOC_DIR) -.PHONY: build download sign verify clean test tag release install uninstall all +.PHONY: build man download sign verify clean test tag release install uninstall all From 4f5e5ac8b4f1474e543c9fb237308a88d2a6a93d Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Mon, 11 Feb 2013 18:14:05 -0800 Subject: [PATCH 11/32] added -v, --version to OPTIONS --- doc/man/chruby.1.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/man/chruby.1.md b/doc/man/chruby.1.md index 18352780..a5ed6b5d 100644 --- a/doc/man/chruby.1.md +++ b/doc/man/chruby.1.md @@ -19,6 +19,8 @@ `-h`, `--help` +`-v`, `--version` + ## DESCRIPTION Changes the current Ruby version by correctly setting the appropriate environment variables. @@ -90,4 +92,4 @@ Switch to an arbitrary Ruby on the fly: Postmodern [postmodern.mod3\@gmail.com](mailto:postmodern.mod3\@gmail.com). ##SEE ALSO -ruby(1), gem(1) \ No newline at end of file +ruby(1), gem(1) From 189861d1c6c3a63e1604ca6ab6dd116b66f784f3 Mon Sep 17 00:00:00 2001 From: havenwood Date: Sun, 31 Mar 2013 13:13:24 -0700 Subject: [PATCH 12/32] Added chruby-exec(1) manpage to See Also section. --- doc/man/chruby.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/chruby.1.md b/doc/man/chruby.1.md index a5ed6b5d..653d5481 100644 --- a/doc/man/chruby.1.md +++ b/doc/man/chruby.1.md @@ -92,4 +92,4 @@ Switch to an arbitrary Ruby on the fly: Postmodern [postmodern.mod3\@gmail.com](mailto:postmodern.mod3\@gmail.com). ##SEE ALSO -ruby(1), gem(1) +chruby-exec(1), ruby(1), gem(1) From c284f6304d7900c31e7013a647a02bd7cb32042f Mon Sep 17 00:00:00 2001 From: havenwood Date: Sun, 31 Mar 2013 13:13:55 -0700 Subject: [PATCH 13/32] remove doc/ from .gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 56c9706e..bdaacd0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -doc/ pkg/*.tar.gz pkg/*.tar.bz2 pkg/*.zip From b30d23edd2f951e7feaae20e07fc07afe19db446 Mon Sep 17 00:00:00 2001 From: havenwood Date: Sun, 31 Mar 2013 13:14:06 -0700 Subject: [PATCH 14/32] initial commit --- doc/man/chruby-exec.1.md | 76 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 doc/man/chruby-exec.1.md diff --git a/doc/man/chruby-exec.1.md b/doc/man/chruby-exec.1.md new file mode 100644 index 00000000..1146ab00 --- /dev/null +++ b/doc/man/chruby-exec.1.md @@ -0,0 +1,76 @@ +# chruby-exec(1) -- Run a command with selected Ruby. + +## SYNOPSIS + +`chruby-exec` RUBY [RUBYOPTS] -- COMMAND + +## ARGUMENTS + +*RUBY* + Change current Ruby based on fuzzy matching of Ruby by name. + +*RUBYOPTS* + Additional optional arguements to pass to Ruby. + +*COMMAND* + Command to run under the selected Ruby. + +## OPTIONS + +`-h`, `--help` + +`-v`, `--version` + +## DESCRIPTION +Run a command with the selected Ruby version by correctly setting the appropriate environment variables. + +[https://github.com/postmodern/chruby/blob/master/README.md](https://github.com/postmodern/chruby/blob/master/README.md) + +## EXAMPLES + +Run the command `gem update` under JRuby: + $ chruby-exec jruby -- gem update + +##FILES + +*/opt/rubies* + Primary default Ruby install location. + +*~/.rubies/* + Secondary default Ruby install location. + +*/etc/profile.d/chruby.sh* + Application environment settings for chruby. + +*~/.gem/$ruby/$version* + Default gem install location. + +##ENVIRONMENT + +*PATH* + Updates the PATH environment variable to include Rubies and RubyGems bin/ directories. + +*GEM_HOME* + Default repository location for gem installation. + +*GEM_PATH* + A colon-separated list of gem repository directories. + +*GEM_ROOT* + +*RUBY_ROOT* + +*RUBY_ENGINE* + Name of Ruby implementation. + +*RUBY_VERSION* + Ruby version number. + +*RUBYOPT* + Optionally set if additional Ruby options are given. + +##AUTHOR +Postmodern [postmodern.mod3\@gmail.com](mailto:postmodern.mod3\@gmail.com). + +##SEE ALSO +chruby(1), ruby(1), gem(1) From fccdd416c67eff33012b2b3a0157435b2dca804b Mon Sep 17 00:00:00 2001 From: havenwood Date: Sun, 31 Mar 2013 13:30:02 -0700 Subject: [PATCH 15/32] initial commit --- share/man/man1/chruby-exec.1 | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 share/man/man1/chruby-exec.1 diff --git a/share/man/man1/chruby-exec.1 b/share/man/man1/chruby-exec.1 new file mode 100644 index 00000000..47704d2f --- /dev/null +++ b/share/man/man1/chruby-exec.1 @@ -0,0 +1,78 @@ +.TH +.BR chruby-exec (1) +\-\- Run a command with selected Ruby. +.SH SYNOPSIS +.PP +\fB\fCchruby-exec\fR RUBY [RUBYOPTS] \-\- COMMAND +.SH ARGUMENTS +.PP +\fIRUBY\fP + Change current Ruby based on fuzzy matching of Ruby by name. +.PP +\fIRUBYOPTS\fP + Additional optional arguements to pass to Ruby. +.PP +\fICOMMAND\fP + Command to run under the selected Ruby. +.SH OPTIONS +.PP +\fB\fC-h\fR, \fB\fC--help\fR +.PP +\fB\fC-v\fR, \fB\fC--version\fR +.SH DESCRIPTION +.PP +Run a command with the selected Ruby version by correctly setting the appropriate environment variables. +.PP +https://github.com/postmodern/chruby/blob/master/README.md +.UR https://github.com/postmodern/chruby/blob/master/README.md +.UE +.SH EXAMPLES +.PP +Run the command \fB\fCgem update\fR under JRuby: + $ chruby\-exec jruby \-\- gem update +.SH FILES +.PP +\fI/opt/rubies\fP + Primary default Ruby install location. +.PP +\fI~/.rubies/\fP + Secondary default Ruby install location. +.PP +\fI/etc/profile.d/chruby.sh\fP + Application environment settings for chruby. +.PP +\fI~/.gem/$ruby/$version\fP + Default gem install location. +.SH ENVIRONMENT +.PP +\fIPATH\fP + Updates the PATH environment variable to include Rubies and RubyGems bin/ directories. +.PP +\fIGEM_HOME\fP + Default repository location for gem installation. +.PP +\fIGEM_PATH\fP + A colon\-separated list of gem repository directories. +.PP +\fIGEM_ROOT\fP +.PP +\fIRUBY_ROOT\fP +.PP +\fIRUBY_ENGINE\fP + Name of Ruby implementation. +.PP +\fIRUBY_VERSION\fP + Ruby version number. +.PP +\fIRUBYOPT\fP + Optionally set if additional Ruby options are given. +.SH AUTHOR +.PP +Postmodern postmodern.mod3\@gmail.com +.MT postmodern.mod3@gmail.com +.ME . +.SH SEE ALSO +.PP +.BR chruby (1), +.BR ruby (1), +.BR gem (1) \ No newline at end of file From fbfb1ae97c4ef644b84c980bf0e2859a4e9df3a7 Mon Sep 17 00:00:00 2001 From: havenwood Date: Sun, 31 Mar 2013 13:51:23 -0700 Subject: [PATCH 16/32] Added chruby-exec(1) duplicates of chruby(1) entries. --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 8ffbddd6..4c7c2fac 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,15 @@ pkg: share/man/man1/chruby.1: doc/man/chruby.1.md md2man doc/man/chruby.1.md > share/man/man1/chruby.1 +share/man/man1/chruby-exec.1: doc/man/chruby-exec.1.md + md2man doc/man/chruby-exec.1.md > share/man/man1/chruby-exec.1 + man: share/man/man1/chruby.1 git commit -m "Updated the man pages" doc/man/chruby.1.md share/man/man1/chruby.1 +man: share/man/man1/chruby-exec.1 + git commit -m "Updated the man pages" doc/man/chruby-exec.1.md share/man/man1/chruby-exec.1 + download: pkg wget -O $(PKG) $(URL)/archive/v$(VERSION).tar.gz From cf35adb5bb5abf7260ff1f814dd0d23bf77f904e Mon Sep 17 00:00:00 2001 From: Postmodern Date: Mon, 6 May 2013 18:31:01 -0700 Subject: [PATCH 17/32] Use kramdown-man (https://github.com/postmodern/kramdown-man). --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 4c7c2fac..05a16ed8 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,10 @@ pkg: mkdir $(PKG_DIR) share/man/man1/chruby.1: doc/man/chruby.1.md - md2man doc/man/chruby.1.md > share/man/man1/chruby.1 + kramdown-man share/man/man1/chruby.1 share/man/man1/chruby-exec.1: doc/man/chruby-exec.1.md - md2man doc/man/chruby-exec.1.md > share/man/man1/chruby-exec.1 + kramdown-man share/man/man1/chruby-exec.1 man: share/man/man1/chruby.1 git commit -m "Updated the man pages" doc/man/chruby.1.md share/man/man1/chruby.1 From 23c18ecf4c658faa69996dc372cf5aedb9dc21bd Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Fri, 14 Jun 2013 18:38:29 -0600 Subject: [PATCH 18/32] Correct spelling typo. --- doc/man/chruby.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/chruby.1.md b/doc/man/chruby.1.md index 653d5481..fb1e7631 100644 --- a/doc/man/chruby.1.md +++ b/doc/man/chruby.1.md @@ -13,7 +13,7 @@ Change current Ruby to system Ruby. *RUBY_OPTS* - Additional optional arguements to pass to Ruby. + Additional optional arguments to pass to Ruby. ## OPTIONS From 1adcb8a1a03d2cb21b48e9ca225d82861378b453 Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Fri, 14 Jun 2013 18:42:15 -0600 Subject: [PATCH 19/32] Correct spelling typo. --- doc/man/chruby-exec.1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/chruby-exec.1.md b/doc/man/chruby-exec.1.md index 1146ab00..fa25af93 100644 --- a/doc/man/chruby-exec.1.md +++ b/doc/man/chruby-exec.1.md @@ -10,7 +10,7 @@ Change current Ruby based on fuzzy matching of Ruby by name. *RUBYOPTS* - Additional optional arguements to pass to Ruby. + Additional optional arguments to pass to Ruby. *COMMAND* Command to run under the selected Ruby. From 3e104958a9046d1968f7ca30a8a25600602b409c Mon Sep 17 00:00:00 2001 From: havenwood Date: Sun, 21 Jul 2013 19:12:32 -0700 Subject: [PATCH 20/32] Implement chruby-install as a function. --- share/chruby/install.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 share/chruby/install.sh diff --git a/share/chruby/install.sh b/share/chruby/install.sh new file mode 100644 index 00000000..b370dfa1 --- /dev/null +++ b/share/chruby/install.sh @@ -0,0 +1,31 @@ +CHRUBY_VERSION="0.3.7" + +function chruby_reload() +{ + RUBIES=( + `find "$PREFIX"/opt/rubies -mindepth 1 -maxdepth 1 -type d 2>/dev/null` + `find "$HOME"/.rubies -mindepth 1 -maxdepth 1 -type d 2>/dev/null` + ) +} + +function chruby-install() +{ + case "$1" in + -h|--help) + echo "usage: chruby-install [OPTIONS] [RUBY [VERSION]] [-- CONFIGURE_OPTS ...]" + ;; + -V|--version) + echo "chruby version $CHRUBY_VERSION" + ;; + *) + if [[ ! -x $(which ruby-install) ]]; then + echo "Aborting, ruby-install not found ..." + return 1 + fi + + ruby-install $@ + + chruby_reload + ;; + esac +} From 505a42174c94f379e9c5be8f12ea0ed5eed14a7a Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 19:25:22 -0700 Subject: [PATCH 21/32] Simply call chruby --version to avoid redefining CHRUBY_VERSION. --- share/chruby/install.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index b370dfa1..5be4edf2 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -1,5 +1,3 @@ -CHRUBY_VERSION="0.3.7" - function chruby_reload() { RUBIES=( @@ -15,7 +13,7 @@ function chruby-install() echo "usage: chruby-install [OPTIONS] [RUBY [VERSION]] [-- CONFIGURE_OPTS ...]" ;; -V|--version) - echo "chruby version $CHRUBY_VERSION" + chruby --version ;; *) if [[ ! -x $(which ruby-install) ]]; then From 4ad93160f376c492af443741a8921e2357cc3f76 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 19:27:39 -0700 Subject: [PATCH 22/32] Use `type -t` to detect ruby-install. --- share/chruby/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index 5be4edf2..1127664f 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -16,7 +16,7 @@ function chruby-install() chruby --version ;; *) - if [[ ! -x $(which ruby-install) ]]; then + if [[ ! $(type -t ruby-install) ]]; then echo "Aborting, ruby-install not found ..." return 1 fi From 9b9535a073fabdfc945ccbb81043e638c7b7c89b Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 19:28:20 -0700 Subject: [PATCH 23/32] Prefix error messages with the function name. --- share/chruby/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index 1127664f..b64197cd 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -17,7 +17,7 @@ function chruby-install() ;; *) if [[ ! $(type -t ruby-install) ]]; then - echo "Aborting, ruby-install not found ..." + echo "chruby-install: ruby-install could not be found" return 1 fi From ea4cf1a4b9b982a447a4453a58128fef005d705b Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 19:28:37 -0700 Subject: [PATCH 24/32] Print to stderr. --- share/chruby/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index b64197cd..956b40c4 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -17,7 +17,7 @@ function chruby-install() ;; *) if [[ ! $(type -t ruby-install) ]]; then - echo "chruby-install: ruby-install could not be found" + echo "chruby-install: ruby-install could not be found" >&2 return 1 fi From 30b401ed697e779a7b3516fc4ce3df9aa6fbe420 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 19:28:52 -0700 Subject: [PATCH 25/32] Style. --- share/chruby/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index 956b40c4..f79f500f 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -22,7 +22,6 @@ function chruby-install() fi ruby-install $@ - chruby_reload ;; esac From 3bd58f98cebbed37bead8201ee7ba8c75f88433c Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 19:29:39 -0700 Subject: [PATCH 26/32] If ruby-install is available, also print it's version. --- share/chruby/install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index f79f500f..dc4cc6ba 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -14,6 +14,7 @@ function chruby-install() ;; -V|--version) chruby --version + [[ $(type -t ruby-install ]] && ruby-install --version ;; *) if [[ ! $(type -t ruby-install) ]]; then From 8404386be639d05ccb229abc234042755031e96a Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Sun, 21 Jul 2013 19:59:06 -0700 Subject: [PATCH 27/32] Create a chruby-install manpage. --- doc/man/chruby-install.1.md | 76 +++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 doc/man/chruby-install.1.md diff --git a/doc/man/chruby-install.1.md b/doc/man/chruby-install.1.md new file mode 100644 index 00000000..c8b50e24 --- /dev/null +++ b/doc/man/chruby-install.1.md @@ -0,0 +1,76 @@ +# chruby-install(1) -- Install the selected Ruby with ruby-install. + +## SYNOPSIS + +`chruby-install` [OPTIONS] [RUBY [VERSION]] [-- CONFIGURE_OPTS ...] + +## ARGUMENTS + +*RUBY* + Install Ruby by name. + +*VERSION* + Optionally select Ruby version. + +*CONFIGURE_OPTS* + Additional optional configure arguments. + +## OPTIONS + +`-h`, `--help` + +`-V`, `--version` + +See `man ruby-install` for Ruby installation options. + +## DESCRIPTION +Installs Ruby, JRuby, Rubinius or MagLev with ruby-install. + +[https://github.com/postmodern/ruby-install#readme](https://github.com/postmodern/ruby-install#readme) + +And then reloads chruby Rubies. + +[https://github.com/postmodern/chruby/blob/master/README.md](https://github.com/postmodern/chruby/blob/master/README.md) + +## ARGUMENTS + +*RUBY* + Install Ruby by name. + +*VERSION* + Optionally select the version of selected Ruby. + +*CONFIGURE_OPTS* + Additional optional configure arguments. + +## EXAMPLES + +Install the current stable version of Ruby: + + $ chruby-install ruby + +Install a specific version of Ruby: + + $ chruby-install ruby 1.9.3-p395 + +## FILES + +*/usr/local/src* + Default root user source directory. + +*~/src* + Default non-root user source directory. + +*/opt/rubies/$ruby-$version* + Default root user installation directory. + +*~/.rubies/$ruby-$version* + Default non-root user installation directory. + +## AUTHOR + +Postmodern + +## SEE ALSO + +ruby-install(1), chruby(1), chruby-exec(1), ruby(1), gem(1) From c1eece3318586293216fb2f467059286e2363d92 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 20:12:26 -0700 Subject: [PATCH 28/32] Fixed a typo. --- share/chruby/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index dc4cc6ba..6a8e2343 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -14,7 +14,7 @@ function chruby-install() ;; -V|--version) chruby --version - [[ $(type -t ruby-install ]] && ruby-install --version + [[ $(type -t ruby-install) ]] && ruby-install --version ;; *) if [[ ! $(type -t ruby-install) ]]; then From ded83ff7f041c93b44295102d79e59a2bb66cff2 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 20:15:05 -0700 Subject: [PATCH 29/32] Began adding tests. --- test/chruby_install.sh | 10 ++++++++++ test/chruby_reload.sh | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 test/chruby_install.sh create mode 100755 test/chruby_reload.sh diff --git a/test/chruby_install.sh b/test/chruby_install.sh new file mode 100755 index 00000000..f7fcfbff --- /dev/null +++ b/test/chruby_install.sh @@ -0,0 +1,10 @@ +. ./share/chruby/install.sh +. ./test/helper.sh + +test_chruby_install_version() +{ + assertTrue "did not print the chruby version" \ + '[[ `chruby-install --version` == *$CHRUBY_VERSION* ]]' +} + +SHUNIT_PARENT=$0 . $SHUNIT2 diff --git a/test/chruby_reload.sh b/test/chruby_reload.sh new file mode 100755 index 00000000..3bdfc777 --- /dev/null +++ b/test/chruby_reload.sh @@ -0,0 +1,17 @@ +. ./share/chruby/install.sh +. ./test/helper.sh + +test_chruby_reload() +{ + local new_ruby="$HOME/.rubies/newly_installed_ruby" + mkdir -p "$new_ruby" + + chruby_reload + + assertTrue "did not add the new ruby dir to RUBIES" \ + '[[ "${RUBIES[*]}" == *$new_ruby* ]]' + + rmdir "$new_ruby" +} + +SHUNIT_PARENT=$0 . $SHUNIT2 From b07cc807e65d88f8ac668a02e6b36480e250e705 Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Sun, 21 Jul 2013 20:58:40 -0700 Subject: [PATCH 30/32] Add chruby-install usage instructions. --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 7dd005fc..99fe376d 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,30 @@ Chruby provides detailed instructions for installing additional Rubies: * [Rubinius](https://github.com/postmodern/chruby/wiki/Rubinius) * [MagLev](https://github.com/postmodern/chruby/wiki/MagLev) +#### chruby-install + +If you'd like to use chruby-install to install Rubies, just install [ruby-install] and add the following to your `/etc/profile.d/chruby.sh`, `~/.bashrc` or `~/.zshrc` file: + + source /usr/local/share/chruby/install.sh + +You can then use chruby-install to install additional Rubies and automatically add them to chruby's known Rubies: + +List Rubies for installation: + + chruby-install + +Install the current stable version of a Ruby: + + chruby-install ruby + +Install the latest version of a Ruby: + + chruby-install ruby 1.9 + +Install a Ruby with specific configuration: + + chruby-install ruby 2.0.0-p0 -- --enable-shared --enable-dtrace CFLAGS="-O3" + #### ruby-install You can also use [ruby-install] to install additional Rubies: From 1c92f23a92ac24d1e08efb6c43b57d69a88e2a60 Mon Sep 17 00:00:00 2001 From: Postmodern Date: Sun, 21 Jul 2013 21:09:34 -0700 Subject: [PATCH 31/32] Wording. --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99fe376d..220b9602 100644 --- a/README.md +++ b/README.md @@ -85,11 +85,13 @@ Chruby provides detailed instructions for installing additional Rubies: #### chruby-install -If you'd like to use chruby-install to install Rubies, just install [ruby-install] and add the following to your `/etc/profile.d/chruby.sh`, `~/.bashrc` or `~/.zshrc` file: +If you'd like to use chruby-install to install Rubies, just install +[ruby-install] and add the following after where you have loaded `chruby.sh`: source /usr/local/share/chruby/install.sh -You can then use chruby-install to install additional Rubies and automatically add them to chruby's known Rubies: +You can then use chruby-install to install additional Rubies, making them +immediately available to chruby. List Rubies for installation: From 085f0297111838a077a8c0310545e142685d9469 Mon Sep 17 00:00:00 2001 From: Shannon Skipper Date: Mon, 22 Jul 2013 01:23:21 -0700 Subject: [PATCH 32/32] Use `command -v` for zsh compatibility. --- share/chruby/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/chruby/install.sh b/share/chruby/install.sh index 6a8e2343..4267cf02 100644 --- a/share/chruby/install.sh +++ b/share/chruby/install.sh @@ -14,10 +14,10 @@ function chruby-install() ;; -V|--version) chruby --version - [[ $(type -t ruby-install) ]] && ruby-install --version + [[ -n `command -v ruby-install` ]] && ruby-install --version ;; *) - if [[ ! $(type -t ruby-install) ]]; then + if [[ -z `command -v ruby-install` ]]; then echo "chruby-install: ruby-install could not be found" >&2 return 1 fi