Sha256: f72e4772e897edf9285d36de2834b68490eda0fff3ee1d71d9aae5f8eba640b1

Contents?: true

Size: 1.78 KB

Versions: 19

Compression:

Stored size: 1.78 KB

Contents

## rbenv.rb
#
# Adds capistrano/rbenv specific variables and tasks

namespace :load do
  task :defaults do

    # Set the ruby version using the .ruby-version file
    # Looks for the file in the project root
    set :rbenv_ruby, File.read('.ruby-version').strip if File.exist?('.ruby-version')

    # Link .rbenv-vars file
    set :linked_files, fetch(:linked_files, []) << '.rbenv-vars'

    # Set the path to rbenv
    set :rbenv_path, "/usr/local/rbenv"
  end
end

namespace :rbenv do
  namespace :vars do
    desc "Show current environmental variables"
    task :show do
      on release_roles :app do
        within shared_path do
          execute :rbenv, 'vars'
        end
      end
    end

    desc "Sets environmental variables in the form VAR=value"
    task :set, [:variable] => 'deploy:check:directories' do |t, args|

      vars = [args.variable] + args.extras

      on release_roles :app do
        within shared_path do
          vars.compact.each do |var|
            key, value = var.split('=')
            cmd = build_set_var_cmd("#{shared_path}/.rbenv-vars", key, value)
            execute cmd
          end
        end

        if test "[ -d #{current_path} ]"
          invoke 'env:changed'
        end
      end

    end

    desc "Unset environmental variable"
    task :unset, [:key] do |t, args|
      on release_roles :app do
        within shared_path do
          execute :sed, "-i", "/^#{args[:key]}=/d", ".rbenv-vars"
        end

        if test "[ -d #{current_path} ]"
          invoke 'env:changed'
        end
      end
    end

    # Ensure the rbenv-vars file exist
    after 'deploy:check:directories', 'check:files' do
      on release_roles fetch(:rbenv_roles) do
        within shared_path do
          execute :touch, ".rbenv-vars"
        end
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
negroku-2.8.6 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.8.5 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.8.4 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.8.3 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.8.2 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.8.1 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.8.0 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.7.1 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.7.0 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.6.0 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.5.5 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.5.4 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.5.3 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.5.2 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.5.1 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.5.0 lib/negroku/capistrano/tasks/rbenv.rake
negroku-2.4.2 lib/negroku/tasks/rbenv.rake
negroku-2.4.1 lib/negroku/tasks/rbenv.rake
negroku-2.4.0 lib/negroku/tasks/rbenv.rake