RailsCasts Pro episodes are now free!

Learn more or hide this

Charl Fourie's Profile

GitHub User: chfourie

Comments by Charl Fourie

Avatar

Add the following method to base.rb ...

ruby
def add_apt_repository(repo)
  run "#{sudo} add-apt-repository #{repo}", :pty => true do |ch, stream, data|
    if data =~ /Press.\[ENTER\].to.continue/
      ch.send_data("\n")
    else
      Capistrano::Configuration.default_io_proc.call(ch, stream, data)
    end
  end
end

Now use it in all recipes (3 in the example code) where 'add-apt-repository' is being used...

ruby
  add_apt_repository 'ppa:nginx/stable'
Avatar

You can add the following method to rbenv.rb:

ruby
  def rbenv(command)
    run "rbenv #{command}", :pty => true do |ch, stream, data|
      if data =~ /\[sudo\].password.for/
        ch.send_data(Capistrano::CLI.password_prompt("Password:") + "\n")
      else
        Capistrano::Configuration.default_io_proc.call(ch, stream, data)
      end
    end
  end

Then you can just use the method to invoke rbenv wherever you need to ...

ruby
    rbenv "#{rbenv_bootstrap}"
    rbenv "install #{ruby_version}"
    rbenv "global #{ruby_version}"
    run "gem install bundler --no-ri --no-rdoc"