Class: PDK::Util::Bundler::BundleHelper
- Inherits:
-
Object
- Object
- PDK::Util::Bundler::BundleHelper
- Defined in:
- lib/pdk/util/bundler.rb,
lib/pdk/util/bundler.rb
Instance Method Summary collapse
- #binstubs!(gems) ⇒ Object
- #gemfile ⇒ Object
- #gemfile? ⇒ Boolean
- #install! ⇒ Object
- #installed? ⇒ Boolean
- #lock! ⇒ Object
- #locked? ⇒ Boolean
Instance Method Details
#binstubs!(gems) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/pdk/util/bundler.rb', line 122 def binstubs!(gems) binstub_dir = File.join(File.dirname(gemfile), 'bin') return true if gems.all? { |gem| File.file?(File.join(binstub_dir, gem)) } command = bundle_command('binstubs', *gems, '--force') result = command.execute! unless result[:exit_code].zero? PDK.logger.fatal(_("Failed to generate binstubs for '%{gems}':\n%{output}") % { gems: gems.join(' '), output: result.values_at(:stdout, :stderr).join("\n") }) end result[:exit_code].zero? end |
#gemfile ⇒ Object
137 138 139 |
# File 'lib/pdk/util/bundler.rb', line 137 def gemfile @gemfile ||= PDK::Util.find_upwards('Gemfile') end |
#gemfile? ⇒ Boolean
68 69 70 |
# File 'lib/pdk/util/bundler.rb', line 68 def gemfile? !gemfile.nil? end |
#install! ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/pdk/util/bundler.rb', line 105 def install! argv = ['install', "--gemfile=#{gemfile}", '-j4'] argv << "--path=#{bundle_cachedir}" if PDK::Util.gem_install? command = bundle_command(*argv).tap do |c| c.add_spinner(_('Installing missing Gemfile dependencies')) end result = command.execute! unless result[:exit_code].zero? PDK.logger.fatal(result.values_at(:stdout, :stderr).join("\n")) end result[:exit_code].zero? end |
#installed? ⇒ Boolean
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/pdk/util/bundler.rb', line 76 def installed? PDK.logger.debug(_('Checking for missing Gemfile dependencies.')) argv = ['check', "--gemfile=#{gemfile}"] argv << "--path=#{bundle_cachedir}" if PDK::Util.gem_install? result = bundle_command(*argv).execute! unless result[:exit_code].zero? PDK.logger.debug(result.values_at(:stdout, :stderr).join("\n")) end result[:exit_code].zero? end |
#lock! ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/pdk/util/bundler.rb', line 91 def lock! command = bundle_command('lock').tap do |c| c.add_spinner(_('Resolving Gemfile dependencies')) end result = command.execute! unless result[:exit_code].zero? PDK.logger.fatal(result.values_at(:stdout, :stderr).join("\n")) end result[:exit_code].zero? end |
#locked? ⇒ Boolean
72 73 74 |
# File 'lib/pdk/util/bundler.rb', line 72 def locked? !gemfile_lock.nil? end |