lib/bin_install/ruby/rbenv.rb in bin_install-0.0.15 vs lib/bin_install/ruby/rbenv.rb in bin_install-0.0.16
- old
+ new
@@ -1,58 +1,28 @@
module BinInstall
module Ruby
module Rbenv
def self.install
- if installed?
- puts 'rbenv is already installed. Skipping.'.blue
- Brew::Package.upgrade('rbenv')
- Brew::Package.install_or_upgrade('ruby-build')
- else
- first_install
- end
- end
-
- def self.install!
- if installed?
- puts 'rbenv is already installed. Skipping.'.blue
- Brew::Package.upgrade!('rbenv')
- Brew::Package.install_or_upgrade!('ruby-build')
- else
- first_install!
- end
- end
-
- def self.first_install
puts 'Installing rbenv...'.white
Brew::Package.install('rbenv')
Brew::Package.install_or_upgrade('ruby-build')
Shell.append_to_profiles(%{eval "$(rbenv init -)"\n})
-
- version
- rehash
- doctor
- puts 'First install done **************************'
+ require_doctor!
+ install_ruby
+ require_doctor!
end
- def self.first_install!
+ def self.install!
puts 'Installing rbenv...'.white
Brew::Package.install!('rbenv')
Brew::Package.install_or_upgrade!('ruby-build')
- Shell.append_to_profiles(%{eval "$(rbenv init -)"\n})
-
- version!
- rehash!
- doctor!
+ Shell.append_to_profiles!(%{eval "$(rbenv init -)"\n})
+ require_doctor!
+ install_ruby!
+ require_doctor!
end
- def self.reload_shell!
- puts 'Warning rbenv requires reloading the shell'.yellow
- puts 'Close this shell and rerun the installer with:'.red
- puts '$ bin/install'.cyan
- abort('Can not continue.'.red)
- end
-
def self.install_ruby(version = nil)
version ||= Ruby.required_ruby_version
puts "Installing Ruby #{version}...".white
if version
@@ -87,9 +57,24 @@
system('curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash')
end
def self.doctor!
BinInstall.system!('curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash')
+ end
+
+ def self.require_doctor!
+ abort_install! unless doctor
+ end
+
+ def self.abort_install!
+ puts 'Warning rbenv-doctor returned a non zero exit status.'.yellow
+ puts 'Correct the error above before continuing.'.yellow
+ puts 'Try closing this window and restarting your shell session.'.yellow
+ puts "\n"
+ puts 'Rerun the installer with:'
+ puts '$ bin/install'.cyan
+ puts "\n"
+ abort('Aborting install.'.red)
end
def self.rehash
system('rbenv rehash')
end