class SyncWrap::Bundle
Provision to `bundle install`, optionally triggered by a state change key.
Host component dependencies: RunUser?, SourceTree?, BundlerGem
Attributes
The path to install bin stubs, if any. If relative, it is relative to bundle_path. (Default: sbin; directory in bundle_path) The default is purposefully not 'bin', so as to avoid clashes with source trees that already have a 'bin', for example that contain gem source as well.
Hash of environment key/values to set on call to bundle install (Default: {} -> none)
The path to bundle install dependencies. If relative, it is relative to bundle_path. (Default: ~/.gem -> the bundle_install_user gems)
User to perform the bundle install (Default: SyncWrap::RunUser#run_user)
Path to the Gemfile(.lock) (Default: SyncWrap::SourceTree#remote_source_path)
Public Class Methods
# File lib/syncwrap/components/bundle.rb, line 69 def initialize( opts = {} ) @bundle_path = nil @bundle_install_env = {} @bundle_install_path = '~/.gem' @bundle_install_user = nil @bundle_install_bin_stubs = 'sbin' super end
Public Instance Methods
# File lib/syncwrap/components/bundle.rb, line 82 def bundle_install sh( "( cd #{bundle_path}", close: ')', user: bundle_install_user ) do cmd = [ preamble, bundle_command, '_' + bundler_version + '_', 'install' ] if bundle_install_path cmd += [ '--path', bundle_install_path ] end if bundle_install_bin_stubs cmd += [ '--binstubs', bundle_install_bin_stubs ] end sh( cmd.join(' '), user: bundle_install_user ) end end
# File lib/syncwrap/components/bundle.rb, line 36 def bundle_path @bundle_path || remote_source_path end
# File lib/syncwrap/components/bundle.rb, line 78 def install bundle_install if change_key.nil? || change_key_changes? end
Protected Instance Methods
# File lib/syncwrap/components/bundle.rb, line 58 def bundle_install_user @bundle_install_user || run_user end
# File lib/syncwrap/components/bundle.rb, line 100 def preamble setters = bundle_install_env.map do |k,v| k.to_s + '="' + v.gsub( /["\]/ ) { |c| '\' + c } + '"' end setters.join( ' ' ) end