123456789_123456789_123456789_123456789_123456789_

Module: Gem

Relationships & Source Files
Namespace Children
Modules:
Classes:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Defined in: lib/bundler/rubygems_ext.rb

Constant Summary

Class Attribute Summary

Class Method Summary

Instance Method Summary

Class Attribute Details

.freebsd_platform?Boolean (readonly)

[ GitHub ]

  
# File 'lib/bundler/rubygems_ext.rb', line 28

def self.freebsd_platform?
  RbConfig::CONFIG["host_os"].to_s.include?("bsd")
end

Class Method Details

.open_file_with_flock(path, &block)

[ GitHub ]

  
# File 'lib/bundler/rubygems_ext.rb', line 38

def open_file_with_flock(path, &block)
  # read-write mode is used rather than read-only in order to support NFS
  mode = IO::RDWR | IO::APPEND | IO::CREAT | IO::BINARY
  mode |= IO::SHARE_DELETE if IO.const_defined?(:SHARE_DELETE)

  File.open(path, mode) do |io|
    begin
      io.flock(File::LOCK_EX)
    rescue Errno::ENOSYS, Errno::ENOTSUP
    end
    yield io
  end
end

.open_file_with_lock(path, &block)

[ GitHub ]

  
# File 'lib/bundler/rubygems_ext.rb', line 52

def open_file_with_lock(path, &block)
  file_lock = "#{path}.lock"
  open_file_with_flock(file_lock, &block)
ensure
  FileUtils.rm_f file_lock
end