lib/rconf/configurators/bundler_configurator.rb in rconf-1.0.6 vs lib/rconf/configurators/bundler_configurator.rb in rconf-1.0.7
- old
+ new
@@ -30,15 +30,11 @@
#
# === Return
# true:: If bundler is already installed
# false:: Otherwise
def check_linux
- report_check("Checking for bundler #{version}")
- res = Command.execute('bundle', '--version')
- success = (res.output =~ /#{version}/)
- report_result(success)
- success
+ check_bundler && check_bundle
end
alias :check_darwin :check_linux
# Not implemented on windows
#
@@ -46,23 +42,17 @@
# (Exception):: Always raise
def check_windows
raise "Bundler is not supported on Windows!"
end
- # Install bundler if needed and run bundle install
+ # 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('bundle', *options)
- report_success
+ install_bundle
true
end
alias :run_darwin :run_linux
# Not implemented on windows
@@ -73,10 +63,36 @@
raise "Bundler is not supported on Windows!"
end
protected
+ # Check whether bundler is already installed.
+ #
+ # === Return
+ # true:: If bundler is already installed
+ # false:: Otherwise
+ def check_bundler
+ report_check("Checking bundler #{version}")
+ res = Command.execute("bundle", "_#{version}_", '--version')
+ success = !!(res.output =~ /#{version}/)
+ report_result(success)
+ success
+ end
+
+ # Check whether the gems in the bundle are all installed.
+ #
+ # === Return
+ # true:: If bundle's gem dependencies are satisfied.
+ # false:: Otherwise
+ def check_bundle
+ report_check("Checking bundle")
+ res = Command.execute("bundle", "_#{version}_", 'check')
+ success = !!(res.output =~ /dependencies are satisfied/)
+ report_result(success)
+ success
+ end
+
# Install bundler from gem in cache
#
# === Return
# true:: Always return true
#
@@ -91,12 +107,30 @@
version_or_file = [ 'bundler', '-v', version ]
end
options = [ 'gem','install' ]
options += version_or_file
options += [ '--no-ri', '--no-rdoc', { :abort_on_failure => 'Failed to install bundler' } ]
- res = Command.execute(*options)
+ Command.execute(*options)
report_success
true
end
+ # Run "bundle install" to install the gems in the app's bundle.
+ #
+ # === Return
+ # true:: Always return true
+ #
+ # === Raise
+ # (Exception):: If one or gems in the bundle cannot be installed for any reason
+ def install_bundle
+ 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('bundle', *options)
+ report_success
+ Command.execute('rbenv', 'rehash') # this is kind of optional
+ true
+ end
end
end