lib/rconf/configurators/bundler_configurator.rb in rconf-0.8.3 vs lib/rconf/configurators/bundler_configurator.rb in rconf-0.8.4
- old
+ new
@@ -26,29 +26,45 @@
:bundle_path => 'Path where bundle should be installed',
:gem_path => 'Path to bundler gem, e.g. "vendor/system_gems/cache"'
validate_has_settings :version
- # Install bundler if needed and run bundle install
+ # Check whether bundler is already installed
#
# === Return
- # true:: Always return true
- def run_linux
+ # true:: If bundler is already installed
+ # false:: Otherwise
+ def check_linux
report_check("Checking for bundler #{version}")
res = Command.execute_in_ruby('bundle', '--version')
success = (res.output =~ /#{version}/)
report_result(success)
- unless success
- install_bundler
- report_check('Installing gems')
- options = [ "_#{version}_", 'install' ]
- options << "--without=#{exclusions.delete(' ')}" unless exclusions.nil?
- options += [ '--path', bundle_path ] unless bundle_path.nil?
- options << { :abort_on_failure => 'Failed to install gems' }
- res = Command.execute_in_ruby('bundle', *options)
- report_success
- end
+ success
+ end
+ alias :check_darwin :check_linux
+
+ # Not implemented on windows
+ #
+ # === Raise
+ # (Exception):: Always raise
+ def check_windows
+ raise "Bundler is not supported on Windows!"
+ end
+
+ # Install bundler if needed and run bundle install
+ #
+ # === Return
+ # true:: Always return true
+ def run_linux
+ install_bundler
+ report_check('Installing gems')
+ options = [ "_#{version}_", 'install' ]
+ options << "--without=#{exclusions.delete(' ')}" unless exclusions.nil?
+ options += [ '--path', bundle_path ] unless bundle_path.nil?
+ options << { :abort_on_failure => 'Failed to install gems' }
+ res = Command.execute_in_ruby('bundle', *options)
+ report_success
true
end
alias :run_darwin :run_linux
# Not implemented on windows
@@ -69,10 +85,10 @@
# === Raise
# (Exception):: If bundler gem cannot be found or installed
def install_bundler
res = Command.execute_in_ruby('bundle', '--version')
exists = res.success? && res.output !~ /exec: bundle: not found/
- if exists
+ if exists && res.output !~ /#{version}/
report_check('Uninstalling existing versions of bundler')
Command.execute_in_ruby('gem', 'uninstall', 'bundler', '-a', '-x')
report_success
end
report_check("Installing bundler #{version}")