├── LICENSE ├── README.md └── etc └── rbenv.d └── install └── default-gems.bash /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Sam Stephenson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rbenv-default-gems 2 | 3 | This rbenv plugin hooks into the `rbenv install` command to 4 | automatically install gems every time you install a new version of 5 | Ruby. 6 | 7 | ## Installation 8 | 9 | Make sure you have the latest rbenv and ruby-build versions, then run: 10 | 11 | git clone https://github.com/rbenv/rbenv-default-gems.git $(rbenv root)/plugins/rbenv-default-gems 12 | 13 | ## Usage 14 | 15 | rbenv-default-gems automatically installs the gems listed in the 16 | `$(rbenv root)/default-gems` file every time you successfully install a new 17 | version of Ruby with `rbenv install`. 18 | 19 | Specify gems in `$(rbenv root)/default-gems` by name, one per line. You may 20 | optionally specify a version string after the name, or `--pre` to 21 | install a prerelease version. For example: 22 | 23 | bundler 24 | bcat ~>0.6 25 | rails --pre 26 | 27 | Blank lines and lines beginning with a `#` are ignored. 28 | 29 | ## License 30 | 31 | (The MIT License) 32 | 33 | Copyright (c) 2013 Sam Stephenson 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining 36 | a copy of this software and associated documentation files (the 37 | "Software"), to deal in the Software without restriction, including 38 | without limitation the rights to use, copy, modify, merge, publish, 39 | distribute, sublicense, and/or sell copies of the Software, and to 40 | permit persons to whom the Software is furnished to do so, subject to 41 | the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be 44 | included in all copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 47 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 48 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 49 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 50 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 51 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 52 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /etc/rbenv.d/install/default-gems.bash: -------------------------------------------------------------------------------- 1 | if declare -Ff after_install >/dev/null; then 2 | after_install install_default_gems 3 | else 4 | echo "rbenv: rbenv-default-gems plugin requires ruby-build 20130129 or later" >&2 5 | fi 6 | 7 | install_default_gems() { 8 | # Only install default gems after successfully installing Ruby. 9 | [ "$STATUS" = "0" ] || return 0 10 | 11 | if [ -f "${RBENV_ROOT}/default-gems" ]; then 12 | local line gem_name gem_version args 13 | 14 | # Read gem names and versions from $RBENV_ROOT/default-gems. 15 | while IFS=" " read -r -a line; do 16 | 17 | # Skip empty lines. 18 | [ "${#line[@]}" -gt 0 ] || continue 19 | 20 | # Skip comment lines that begin with `#`. 21 | [ "${line[0]:0:1}" != "#" ] || continue 22 | 23 | gem_name="${line[0]}" 24 | gem_version="${line[1]}" 25 | 26 | if [ "$gem_version" == "--pre" ]; then 27 | args=( --pre ) 28 | elif [ -n "$gem_version" ]; then 29 | args=( --version "$gem_version" ) 30 | else 31 | args=() 32 | fi 33 | 34 | # Invoke `gem install` in the just-installed Ruby. Point its 35 | # stdin to /dev/null or else it'll read from our default-gems 36 | # file. 37 | RBENV_VERSION="$VERSION_NAME" rbenv-exec gem install "$gem_name" "${args[@]}" < /dev/null || { 38 | echo "rbenv: error installing gem \`$gem_name'" 39 | } >&2 40 | 41 | done < "${RBENV_ROOT}/default-gems" 42 | fi 43 | } 44 | --------------------------------------------------------------------------------