Sha256: c7d0963069e4c61e88b046476d6a361eae0efb2e1f9654baeb75ea88d89c47ce

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 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'
  end
end

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

    desc "Add environmental variables in the form VAR=value"
    task :add, :variable do |t, args|

      vars = [args.variable] + args.extras

      on release_roles :app do
        within shared_path do
          unless test "[ ! -f .rbenv-vars ]"
            execute :touch, ".rbenv-vars"
          end
          vars.compact.each do |var|
            key, value = var.split('=')
            cmd = build_add_var_cmd("#{shared_path}/.rbenv-vars", key, value)
            execute cmd
          end
        end
      end

    end

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
negroku-2.0.0.pre4 lib/negroku/tasks/rbenv.rake
negroku-2.0.0.pre3 lib/negroku/tasks/rbenv.rake