module OnContainer::Dev::BundlerOps

Public Instance Methods

bundle_belongs_to_current_user?() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 18
def bundle_belongs_to_current_user?
  bundle_owner_id == current_user_id
end
bundle_owner_id() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 10
def bundle_owner_id
  File.stat(bundle_path).uid
end
bundle_path() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 6
def bundle_path
  '/usr/local/bundle'
end
current_user_id() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 14
def current_user_id
  Etc.getpwuid.uid
end
ensure_bundle_belongs_to_current_user() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 27
def ensure_bundle_belongs_to_current_user
  return if bundle_belongs_to_current_user?

  make_bundle_belong_to_current_user
end
ensure_project_gems_are_installed() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 33
def ensure_project_gems_are_installed
  ensure_bundle_belongs_to_current_user

  system 'bundle check || bundle install'
end
make_bundle_belong_to_current_user() click to toggle source
# File lib/on_container/dev/bundler_ops.rb, line 22
def make_bundle_belong_to_current_user
  target_ownership = "#{current_user_id}:#{current_user_id}"
  system "sudo chown -R #{target_ownership} #{bundle_path}"
end