Sha256: 20438441df59f95bcd5908c97260e13f65654b3e7b0cd369bf622a79b8cb1e29
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 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' if File.exist?('.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 variable" task :add, [:key, :value] do |t, args| key = args[:key] value = args[:value] on release_roles :app do within shared_path do unless test "[ ! -f .rbenv-vars ]" execute :touch, ".rbenv-vars" end cmd = "if awk < #{shared_path}/.rbenv-vars -F= '{print $1}' | grep --quiet -w #{key}; then " cmd += "sed -i 's/^#{key}=.*/#{key}=#{value.gsub("\/", "\\/")}/g' #{shared_path}/.rbenv-vars;" cmd += "else echo '#{key}=#{value}' >> #{shared_path}/.rbenv-vars;" cmd += "fi" execute cmd 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
negroku-2.0.0.pre1 | lib/negroku/tasks/rbenv.rake |