Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 4e4ee7d7f8dfe5d25f651223a41a69198c65cd91 @kirs kirs committed Aug 12, 2013
Showing with 99 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +4 −0 Gemfile
  3. +31 −0 README.md
  4. +1 −0 Rakefile
  5. +20 −0 capistrano-chruby.gemspec
  6. 0 lib/capistrano-chruby.rb
  7. +1 −0 lib/capistrano/chruby.rb
  8. +41 −0 lib/capistrano/tasks/chruby.rake
@@ -0,0 +1 @@
+vagrant/
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in capistrano-chruby.gemspec
+gemspec
@@ -0,0 +1,31 @@
+# Capistrano::chruby
+
+## Installation
+
+Add this line to your application's Gemfile:
+
+ gem 'capistrano', version: '~> 3.0.0'
+ gem 'capistrano-chruby', github: "kirs/chruby"
+
+And then execute:
+
+ $ bundle
+ $ cap install
+
+## Usage
+
+ # Capfile
+
+ require 'capistrano/chruby'
+
+ set :chruby_ruby, '2.0.0-p247'
+
+If your `chruby-exec` is located in some custom path, you can use `chruby_exec` to set it.
+
+## Contributing
+
+1. Fork it
+2. Create your feature branch (`git checkout -b my-new-feature`)
+3. Commit your changes (`git commit -am 'Add some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
+# -*- encoding: utf-8 -*-
+lib = File.expand_path('../lib', __FILE__)
+$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
+
+Gem::Specification.new do |gem|
+ gem.name = "capistrano-chruby"
+ gem.version = '0.0.1'
+ gem.authors = ["Kir Shatrov"]
+ gem.email = ["shatrov@me.com"]
+ gem.description = %q{chruby integration for Capistrano}
+ gem.summary = %q{chruby integration for Capistrano}
+ gem.homepage = "https://github.com/kirs/chruby"
+
+ gem.files = `git ls-files`.split($/)
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
+ gem.require_paths = ["lib"]
+
+ gem.add_dependency 'capistrano'
+
+end
No changes.
@@ -0,0 +1 @@
+load File.expand_path("../tasks/chruby.rake", __FILE__)
@@ -0,0 +1,41 @@
+def bundler_loaded?
+ Gem::Specification::find_all_by_name('capistrano-bundler').any?
+end
+
+SSHKit.config.command_map = Hash.new do |hash, key|
+ if fetch(:chruby_map_bins).include?(key.to_s)
+ prefix = "#{fetch(:chruby_exec)} #{fetch(:chruby_ruby)} --"
+ hash[key] = if bundler_loaded? && key.to_s != "bundle"
+ "#{prefix} bundle exec #{key}"
+ else
+ "#{prefix} #{key}"
+ end
+ else
+ hash[key] = key
+ end
+end
+
+namespace :deploy do
+ before :starting, :hook_chruby_bins do
+ invoke :'chruby:check'
+ end
+end
+
+namespace :chruby do
+ task :check do
+ on roles(:all) do
+ chruby_ruby = fetch(:chruby_ruby)
+ if chruby_ruby.nil?
+ error "chruby: chruby_ruby is not set"
+ exit 1
+ end
+ end
+ end
+end
+
+namespace :load do
+ task :defaults do
+ set :chruby_map_bins, %w{rake gem bundle ruby}
+ set :chruby_exec, "/usr/local/bin/chruby-exec"
+ end
+end

0 comments on commit 4e4ee7d

Please sign in to comment.