├── lib ├── capistrano-rbenv.rb └── capistrano │ ├── rbenv.rb │ └── tasks │ └── rbenv.rake ├── Rakefile ├── .gitignore ├── Gemfile ├── capistrano-rbenv.gemspec ├── CHANGELOG.md ├── LICENSE.txt └── README.md /lib/capistrano-rbenv.rb: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Vagrantfile 2 | .vagrant/ 3 | pkg/ 4 | -------------------------------------------------------------------------------- /lib/capistrano/rbenv.rb: -------------------------------------------------------------------------------- 1 | load File.expand_path("../tasks/rbenv.rake", __FILE__) 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in capistrano-rbenv.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /capistrano-rbenv.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | 5 | Gem::Specification.new do |gem| 6 | gem.name = "capistrano-rbenv" 7 | gem.version = '2.0.3' 8 | gem.authors = ["Kir Shatrov", "Yamashita Yuu"] 9 | gem.email = ["shatrov@me.com", "yamashita@geishatokyo.com"] 10 | gem.description = %q{rbenv integration for Capistrano} 11 | gem.summary = %q{rbenv integration for Capistrano} 12 | gem.homepage = "https://github.com/capistrano/rbenv" 13 | 14 | gem.files = `git ls-files`.split($/) 15 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 16 | gem.require_paths = ["lib"] 17 | 18 | gem.add_dependency 'capistrano', '~> 3.1' 19 | gem.add_dependency 'sshkit', '~> 1.3' 20 | 21 | end 22 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 2.0.3 (27 Jan 2015) 2 | 3 | * rbenv:validate is a 'success' if version exists #36 4 | * MIT license included 5 | * rbenv command runs only on release_roles #44 6 | 7 | # 2.0.2 (29 Jan 2014) 8 | 9 | * Environment variables are set with native SSHKit API 10 | * Depend on capistrano 3.1 11 | 12 | # 2.0.1 (9 Jan 2014) 13 | 14 | * Added ability to setup custom `rbenv_roles` variable (default: :all). 15 | * Fixed SSHKit dependency 16 | 17 | # 2.0.0 18 | 19 | * Added ability to setup custom `rbenv_prefix` variable. 20 | * prefix rails with rbenv by default 21 | * Switching to new command map (https://github.com/capistrano/sshkit/pull/45) 22 | This gives us more flexible integration and command mapping. 23 | Fixed bug when `cap some_task` didn't invoke rbenv hooks. 24 | 25 | Capistrano 3 -ready release. 26 | 27 | # 1.0.5 28 | 29 | Versions < 2.0 are located in another repo: https://github.com/yyuu/capistrano-rbenv 30 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License (MIT) 2 | 3 | Copyright (c) 2013-2014 Kir Shatrov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/capistrano/tasks/rbenv.rake: -------------------------------------------------------------------------------- 1 | namespace :rbenv do 2 | task :validate do 3 | on release_roles(fetch(:rbenv_roles)) do 4 | rbenv_ruby = fetch(:rbenv_ruby) 5 | if rbenv_ruby.nil? 6 | error "rbenv: rbenv_ruby is not set" 7 | exit 1 8 | end 9 | 10 | unless test "[ -d #{fetch(:rbenv_ruby_dir)} ]" 11 | error "rbenv: #{rbenv_ruby} is not installed or not found in #{fetch(:rbenv_ruby_dir)}" 12 | exit 1 13 | end 14 | end 15 | end 16 | 17 | task :map_bins do 18 | SSHKit.config.default_env.merge!({ rbenv_root: fetch(:rbenv_path), rbenv_version: fetch(:rbenv_ruby) }) 19 | rbenv_prefix = fetch(:rbenv_prefix, proc { "#{fetch(:rbenv_path)}/bin/rbenv exec" }) 20 | SSHKit.config.command_map[:rbenv] = "#{fetch(:rbenv_path)}/bin/rbenv" 21 | 22 | fetch(:rbenv_map_bins).each do |command| 23 | SSHKit.config.command_map.prefix[command.to_sym].unshift(rbenv_prefix) 24 | end 25 | end 26 | end 27 | 28 | Capistrano::DSL.stages.each do |stage| 29 | after stage, 'rbenv:validate' 30 | after stage, 'rbenv:map_bins' 31 | end 32 | 33 | namespace :load do 34 | task :defaults do 35 | set :rbenv_path, -> { 36 | rbenv_path = fetch(:rbenv_custom_path) 37 | rbenv_path ||= if fetch(:rbenv_type, :user) == :system 38 | "/usr/local/rbenv" 39 | else 40 | "~/.rbenv" 41 | end 42 | } 43 | 44 | set :rbenv_roles, fetch(:rbenv_roles, :all) 45 | 46 | set :rbenv_ruby_dir, -> { "#{fetch(:rbenv_path)}/versions/#{fetch(:rbenv_ruby)}" } 47 | set :rbenv_map_bins, %w{rake gem bundle ruby rails} 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Capistrano::rbenv 2 | 3 | This gem provides idiomatic rbenv support for Capistrano 3.x (and 3.x 4 | *only*). 5 | 6 | ## Please Note 7 | 8 | If you want to use this plugin with Cap 2.x, please use 1.x version of the gem. 9 | Source code and docs for older integration is available in [another repo](https://github.com/yyuu/capistrano-rbenv) 10 | 11 | Thanks a lot to [@yyuu](https://github.com/yyuu) for merging his gem with official one. 12 | 13 | ## Installation 14 | 15 | Add this line to your application's Gemfile: 16 | 17 | gem 'capistrano', '~> 3.1' 18 | gem 'capistrano-rbenv', '~> 2.0' 19 | 20 | And then execute: 21 | 22 | $ bundle install 23 | 24 | ## Usage 25 | 26 | # Capfile 27 | require 'capistrano/rbenv' 28 | 29 | 30 | # config/deploy.rb 31 | set :rbenv_type, :user # or :system, depends on your rbenv setup 32 | set :rbenv_ruby, '2.0.0-p247' 33 | 34 | # in case you want to set ruby version from the file: 35 | # set :rbenv_ruby, File.read('.ruby-version').strip 36 | 37 | set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" 38 | set :rbenv_map_bins, %w{rake gem bundle ruby rails} 39 | set :rbenv_roles, :all # default value 40 | 41 | If your rbenv is located in some custom path, you can use `rbenv_custom_path` to set it. 42 | 43 | ## Contributing 44 | 45 | 1. Fork it 46 | 2. Create your feature branch (`git checkout -b my-new-feature`) 47 | 3. Commit your changes (`git commit -am 'Add some feature'`) 48 | 4. Push to the branch (`git push origin my-new-feature`) 49 | 5. Create new Pull Request 50 | --------------------------------------------------------------------------------