summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems.rb12
-rw-r--r--lib/rubygems/commands/generate_index_command.rb2
-rw-r--r--lib/rubygems/commands/setup_command.rb29
-rw-r--r--lib/rubygems/commands/unpack_command.rb4
-rw-r--r--lib/rubygems/config_file.rb2
-rw-r--r--lib/rubygems/ext/builder.rb2
-rw-r--r--lib/rubygems/indexer.rb9
-rw-r--r--lib/rubygems/installer.rb13
-rw-r--r--lib/rubygems/package.rb4
-rw-r--r--lib/rubygems/package/file_source.rb4
-rw-r--r--lib/rubygems/package/old.rb2
-rw-r--r--lib/rubygems/request_set/lockfile.rb2
-rw-r--r--lib/rubygems/security.rb2
-rw-r--r--lib/rubygems/security/trust_dir.rb2
-rw-r--r--lib/rubygems/source.rb2
-rw-r--r--lib/rubygems/stub_specification.rb2
-rw-r--r--lib/rubygems/test_case.rb10
-rw-r--r--lib/rubygems/test_utilities.rb2
-rw-r--r--lib/rubygems/util.rb3
-rw-r--r--lib/rubygems/validator.rb6
20 files changed, 69 insertions, 45 deletions
@@ -10,7 +10,7 @@ require 'rbconfig'
require 'thread'
module Gem
- VERSION = "2.7.3"
end
# Must be first since it unloads the prelude from 1.9.2
@@ -161,7 +161,7 @@ module Gem
# these are defined in Ruby 1.8.7, hence the need for this convoluted setup.
READ_BINARY_ERRORS = begin
- read_binary_errors = [Errno::EACCES, Errno::EROFS]
read_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP)
read_binary_errors
end.freeze
@@ -171,7 +171,7 @@ module Gem
# these are defined in Ruby 1.8.7.
WRITE_BINARY_ERRORS = begin
- write_binary_errors = []
write_binary_errors << Errno::ENOTSUP if Errno.const_defined?(:ENOTSUP)
write_binary_errors
end.freeze
@@ -871,19 +871,19 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
# Safely read a file in binary mode on all platforms.
def self.read_binary(path)
- open path, 'rb+' do |f|
f.flock(File::LOCK_EX)
f.read
end
rescue *READ_BINARY_ERRORS
- open path, 'rb' do |f|
f.read
end
rescue Errno::ENOLCK # NFS
if Thread.main != Thread.current
raise
else
- open path, 'rb' do |f|
f.read
end
end
@@ -68,7 +68,7 @@ Marshal::MINOR_VERSION constants. It is used to ensure compatibility.
if not File.exist?(options[:directory]) or
not File.directory?(options[:directory]) then
- alert_error "unknown directory name #{directory}."
terminate_interaction 1
else
indexer = Gem::Indexer.new options.delete(:directory), options
@@ -350,7 +350,9 @@ By default, this RubyGems will install gem as:
def install_default_bundler_gem
return unless Gem::USE_BUNDLER_FOR_GEMDEPS
- mkdir_p Gem::Specification.default_specifications_dir
# Workaround for non-git environment.
gemspec = File.open('bundler/bundler.gemspec', 'rb'){|f| f.read.gsub(/`git ls-files -z`/, "''") }
@@ -359,23 +361,36 @@ By default, this RubyGems will install gem as:
bundler_spec = Gem::Specification.load("bundler/bundler.gemspec")
bundler_spec.files = Dir.chdir("bundler") { Dir["{*.md,{lib,exe,man}/**/*}"] }
bundler_spec.executables -= %w[bundler bundle_ruby]
- Dir.entries(Gem::Specification.default_specifications_dir).
select {|gs| gs.start_with?("bundler-") }.
- each {|gs| File.delete(File.join(Gem::Specification.default_specifications_dir, gs)) }
- default_spec_path = File.join(Gem::Specification.default_specifications_dir, "#{bundler_spec.full_name}.gemspec")
Gem.write_binary(default_spec_path, bundler_spec.to_ruby)
bundler_spec = Gem::Specification.load(default_spec_path)
if File.directory? bundler_spec.gems_dir
Dir.entries(bundler_spec.gems_dir).
- select {|default_gem| File.basename(default_gem).match(/^bundler-#{Gem::Version::VERSION_PATTERN}$/) }.
each {|default_gem| rm_r File.join(bundler_spec.gems_dir, default_gem) }
end
- mkdir_p bundler_spec.bin_dir
- bundler_spec.executables.each {|e| cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_spec.bin_dir, e) }
if Gem.win_platform?
require 'rubygems/installer'
@@ -94,7 +94,7 @@ command help for an example.
spec_file = File.basename spec.spec_file
- open spec_file, 'w' do |io|
io.write metadata
end
else
@@ -176,7 +176,7 @@ command help for an example.
metadata = nil
- open path, Gem.binary_mode do |io|
tar = Gem::Package::TarReader.new io
tar.each_entry do |entry|
case entry.full_name
@@ -458,7 +458,7 @@ if you believe they were disclosed to a third party.
# Writes out this config file, replacing its source.
def write
- open config_file_name, 'w' do |io|
io.write to_yaml
end
end
@@ -212,7 +212,7 @@ EOF
FileUtils.mkdir_p @spec.extension_dir
- open destination, 'wb' do |io| io.puts output end
destination
end
@@ -2,6 +2,7 @@
require 'rubygems'
require 'rubygems/package'
require 'time'
begin
gem 'builder'
@@ -64,7 +65,7 @@ class Gem::Indexer
@build_modern = options[:build_modern]
@dest_directory = directory
- @directory = File.join(Dir.tmpdir, "gem_generate_index_#{$$}")
marshal_name = "Marshal.#{Gem.marshal_version}"
@@ -123,7 +124,7 @@ class Gem::Indexer
marshal_name = File.join @quick_marshal_dir, spec_file_name
marshal_zipped = Gem.deflate Marshal.dump(spec)
- open marshal_name, 'wb' do |io| io.write marshal_zipped end
files << marshal_name
@@ -261,7 +262,7 @@ class Gem::Indexer
zipped = Gem.deflate data
- open "#{filename}.#{extension}", 'wb' do |io|
io.write zipped
end
end
@@ -427,7 +428,7 @@ class Gem::Indexer
specs_index = compact_specs specs_index.uniq.sort
- open dest, 'wb' do |io|
Marshal.dump specs_index, io
end
end
@@ -206,7 +206,7 @@ class Gem::Installer
ruby_executable = false
existing = nil
- open generated_bin, 'rb' do |io|
next unless io.gets =~ /^#!/ # shebang
io.gets # blankline
@@ -427,7 +427,7 @@ class Gem::Installer
# specifications directory.
def write_spec
- open spec_file, 'w' do |file|
spec.installed_by_version = Gem.rubygems_version
file.puts spec.to_ruby_for_cache
@@ -464,7 +464,12 @@ class Gem::Installer
def generate_bin # :nodoc:
return if spec.executables.nil? or spec.executables.empty?
- Dir.mkdir @bin_dir unless File.exist? @bin_dir
raise Gem::FilePermissionError.new(@bin_dir) unless File.writable? @bin_dir
spec.executables.each do |filename|
@@ -863,7 +868,7 @@ TEXT
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
- open build_info_file, 'w' do |io|
@build_args.each do |arg|
io.puts arg
end
@@ -219,7 +219,7 @@ class Gem::Package
next unless stat.file?
tar.add_file_simple file, stat.mode, stat.size do |dst_io|
- open file, 'rb' do |src_io|
dst_io.write src_io.read 16384 until src_io.eof?
end
end
@@ -380,7 +380,7 @@ EOM
FileUtils.mkdir_p mkdir, mkdir_options
- open destination, 'wb' do |out|
out.write entry.read
FileUtils.chmod entry.header.mode, destination
end if entry.file?
@@ -23,11 +23,11 @@ class Gem::Package::FileSource < Gem::Package::Source # :nodoc: all
end
def with_write_io &block
- open path, 'wb', &block
end
def with_read_io &block
- open path, 'rb', &block
end
end
@@ -80,7 +80,7 @@ class Gem::Package::Old < Gem::Package
FileUtils.mkdir_p File.dirname destination
- open destination, 'wb', entry['mode'] do |out|
out.write file_data
end
@@ -223,7 +223,7 @@ class Gem::RequestSet::Lockfile
def write
content = to_s
- open "#{@gem_deps_file}.lock", 'w' do |io|
io.write content
end
end
@@ -578,7 +578,7 @@ module Gem::Security
def self.write pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER
path = File.expand_path path
- open path, 'wb', permissions do |io|
if passphrase and cipher
io.write pemmable.to_pem cipher, passphrase
else
@@ -93,7 +93,7 @@ class Gem::Security::TrustDir
destination = cert_path certificate
- open destination, 'wb', @permissions[:trusted_cert] do |io|
io.write certificate.to_pem
end
end
@@ -160,7 +160,7 @@ class Gem::Source
if update_cache? then
FileUtils.mkdir_p cache_dir
- open local_spec, 'wb' do |io|
io.write spec
end
end
@@ -113,6 +113,8 @@ class Gem::StubSpecification < Gem::BasicSpecification
unless @data
begin
saved_lineno = $.
open loaded_from, OPEN_MODE do |file|
begin
file.readline # discard encoding line
@@ -488,7 +488,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
gemspec = "#{name}.gemspec"
- open File.join(directory, gemspec), 'w' do |io|
io.write git_spec.to_ruby
end
@@ -592,7 +592,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
# Reads a Marshal file at +path+
def read_cache(path)
- open path.dup.untaint, 'rb' do |io|
Marshal.load io.read
end
end
@@ -612,7 +612,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
dir = File.dirname path
FileUtils.mkdir_p dir unless File.directory? dir
- open path, 'wb' do |io|
yield io if block_given?
end
@@ -727,7 +727,7 @@ class Gem::TestCase < MiniTest::Unit::TestCase
install_default_specs(*specs)
specs.each do |spec|
- open spec.loaded_from, 'w' do |io|
io.write spec.to_ruby_for_cache
end
end
@@ -1363,7 +1363,7 @@ Also, a list:
yield specification if block_given?
end
- open File.join(directory, "#{name}.gemspec"), 'w' do |io|
io.write vendor_spec.to_ruby
end
@@ -346,7 +346,7 @@ class Gem::TestCase::SpecFetcherSetup
end
def write_spec spec # :nodoc:
- open spec.spec_file, 'w' do |io|
io.write spec.to_ruby_for_cache
end
end
@@ -114,7 +114,8 @@ module Gem::Util
here = File.expand_path directory
loop do
- Dir.chdir here, &block
new_here = File.expand_path('..', here)
return if new_here == here # toplevel
here = new_here
@@ -34,7 +34,7 @@ class Gem::Validator
# gem_path:: [String] Path to gem file
def verify_gem_file(gem_path)
- open gem_path, Gem.binary_mode do |file|
gem_data = file.read
verify_gem gem_data
end
@@ -109,7 +109,7 @@ class Gem::Validator
good, gone, unreadable = nil, nil, nil, nil
- open gem_path, Gem.binary_mode do |file|
package = Gem::Package.new gem_path
good, gone = package.contents.partition { |file_name|
@@ -134,7 +134,7 @@ class Gem::Validator
source = File.join gem_directory, entry['path']
- open source, Gem.binary_mode do |f|
unless f.read == data then
errors[gem_name][entry['path']] = "Modified from original"
end