RailsCasts Pro episodes are now free!
Learn more or hide this
GitHub User: chfourie
Add the following method to base.rb ...
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...
add_apt_repository 'ppa:nginx/stable'
You can add the following method to rbenv.rb:
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 ...
rbenv "#{rbenv_bootstrap}" rbenv "install #{ruby_version}" rbenv "global #{ruby_version}" run "gem install bundler --no-ri --no-rdoc"
Add the following method to base.rb ...
Now use it in all recipes (3 in the example code) where 'add-apt-repository' is being used...
add_apt_repository 'ppa:nginx/stable'
You can add the following method to rbenv.rb:
Then you can just use the method to invoke rbenv wherever you need to ...