class SigtermExtensions::Boot::GemfileNextAutoSync
Public Instance Methods
setup()
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 4 def setup check_bundler_version opt_in end
Private Instance Methods
check_bundler_version()
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 11 def check_bundler_version self.class.hook("before-install-all") do next if Bundler::VERSION >= "1.17.0" || !GEMFILE_NEXT_LOCK.exist? Bundler.ui.warn(<<-EOM.gsub(/\s+/, " ")) Boot can't automatically update the Gemfile_next.lock because you are running an older version of Bundler. Update Bundler to 1.17.0 to discard this warning. EOM end end
nothing_changed?(current_definition)
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 40 def nothing_changed?(current_definition) current_definition.to_lock == @previous_lock end
opt_in()
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 23 def opt_in self.class.hook('before-install-all') do @previous_lock = Bundler.default_lockfile.read end self.class.hook("after-install-all") do current_definition = Bundler.definition next if !GEMFILE_NEXT_LOCK.exist? || nothing_changed?(current_definition) || ENV[Boot.env_next] || ENV[Boot.env_previous] update!(current_definition) end end
update!(current_definition)
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 44 def update!(current_definition) env = which_env lock = which_lock Bundler.ui.confirm("Updating the #{lock}") ENV[env] = '1' ENV['SKIP_BUNDLER_PATCH'] = '1' unlock = current_definition.instance_variable_get(:@unlock) definition = Bundler::Definition.build(GEMFILE, lock, unlock) definition.resolve_remotely! definition.lock(lock) ensure ENV.delete(env) ENV.delete('SKIP_BUNDLER_PATCH') end
which_env()
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 61 def which_env if Bundler.default_lockfile.to_s =~ /_next\.lock/ Boot.env_previous else Boot.env_next end end
which_lock()
click to toggle source
# File lib/sigterm_extensions/staging/boot/gemfile_next_auto_sync.rb, line 69 def which_lock if Bundler.default_lockfile.to_s =~ /_next\.lock/ GEMFILE_LOCK else GEMFILE_NEXT_LOCK end end