summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2023-04-11 14:56:08 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2023-04-11 19:12:28 +0900
commitd89cc317c642848008f5b17a82196d25ddcdf124 (patch)
treeb1a0dea2ae57246ff407a7608618ff12bb77204f /lib
parent65e276096f2b5ace95d07ac15af545362e0714c1 (diff)
util/rubocop -A --only Style/NumericLiteralPrefix
Diffstat (limited to 'lib')
-rw-r--r--lib/rubygems.rb2
-rw-r--r--lib/rubygems/commands/cert_command.rb4
-rw-r--r--lib/rubygems/commands/setup_command.rb14
-rw-r--r--lib/rubygems/config_file.rb6
-rw-r--r--lib/rubygems/indexer.rb2
-rw-r--r--lib/rubygems/installer.rb14
-rw-r--r--lib/rubygems/package.rb12
-rw-r--r--lib/rubygems/package/old.rb2
-rw-r--r--lib/rubygems/package/tar_writer.rb2
-rw-r--r--lib/rubygems/security.rb2
-rw-r--r--lib/rubygems/security/trust_dir.rb8
-rw-r--r--lib/rubygems/specification_policy.rb2
12 files changed, 35 insertions, 35 deletions
diff --git a/lib/rubygems.rb b/lib/rubygems.rb
index de0c8b84c3..cb71657018 100644
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -429,7 +429,7 @@ An Array (#{env.inspect}) was passed in from #{caller[3]}
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
old_umask = File.umask
- File.umask old_umask | 002
+ File.umask old_umask | 0o002
options = {}
diff --git a/lib/rubygems/commands/cert_command.rb b/lib/rubygems/commands/cert_command.rb
index 57f01a3ae1..22864a9b29 100644
--- a/lib/rubygems/commands/cert_command.rb
+++ b/lib/rubygems/commands/cert_command.rb
@@ -178,7 +178,7 @@ class Gem::Commands::CertCommand < Gem::Command
algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
key = Gem::Security.create_key(algorithm)
- key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
+ key_path = Gem::Security.write key, "gem-private_key.pem", 0o600, passphrase
[key, key_path]
end
@@ -291,7 +291,7 @@ For further reading on signing gems see `ri Gem::Security`.
cert = File.read cert_file
cert = OpenSSL::X509::Certificate.new cert
- permissions = File.stat(cert_file).mode & 0777
+ permissions = File.stat(cert_file).mode & 0o777
issuer_cert = options[:issuer_cert]
issuer_key = options[:key]
diff --git a/lib/rubygems/commands/setup_command.rb b/lib/rubygems/commands/setup_command.rb
index cf3924df54..c2b681c60d 100644
--- a/lib/rubygems/commands/setup_command.rb
+++ b/lib/rubygems/commands/setup_command.rb
@@ -243,7 +243,7 @@ By default, this RubyGems will install gem as:
end
def install_executables(bin_dir)
- prog_mode = options[:prog_mode] || 0755
+ prog_mode = options[:prog_mode] || 0o755
executables = { "gem" => "bin" }
executables.each do |tool, path|
@@ -369,7 +369,7 @@ By default, this RubyGems will install gem as:
File.dirname(loaded_from)
else
target_specs_dir = File.join(default_dir, "specifications", "default")
- mkdir_p target_specs_dir, :mode => 0755
+ mkdir_p target_specs_dir, :mode => 0o755
target_specs_dir
end
@@ -393,7 +393,7 @@ By default, this RubyGems will install gem as:
end
bundler_bin_dir = bundler_spec.bin_dir
- mkdir_p bundler_bin_dir, :mode => 0755
+ mkdir_p bundler_bin_dir, :mode => 0o755
bundler_spec.executables.each do |e|
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
end
@@ -430,8 +430,8 @@ By default, this RubyGems will install gem as:
lib_dir, bin_dir = generate_default_dirs
end
- mkdir_p lib_dir, :mode => 0755
- mkdir_p bin_dir, :mode => 0755
+ mkdir_p lib_dir, :mode => 0o755
+ mkdir_p bin_dir, :mode => 0o755
[lib_dir, bin_dir]
end
@@ -639,10 +639,10 @@ abort "#{deprecation_message}"
dest_file = File.join dest_dir, file
dest_dir = File.dirname dest_file
unless File.directory? dest_dir
- mkdir_p dest_dir, :mode => 0755
+ mkdir_p dest_dir, :mode => 0o755
end
- install file, dest_file, :mode => options[:data_mode] || 0644
+ install file, dest_file, :mode => options[:data_mode] || 0o644
end
def remove_file_list(files, dir)
diff --git a/lib/rubygems/config_file.rb b/lib/rubygems/config_file.rb
index 0a5f6ffad2..9d38d8b134 100644
--- a/lib/rubygems/config_file.rb
+++ b/lib/rubygems/config_file.rb
@@ -241,9 +241,9 @@ class Gem::ConfigFile
return if Gem.win_platform? # windows doesn't write 0600 as 0600
return unless File.exist? credentials_path
- existing_permissions = File.stat(credentials_path).mode & 0777
+ existing_permissions = File.stat(credentials_path).mode & 0o777
- return if existing_permissions == 0600
+ return if existing_permissions == 0o600
alert_error <<-ERROR
Your gem push credentials file located at:
@@ -326,7 +326,7 @@ if you believe they were disclosed to a third party.
Gem.load_yaml
- permissions = 0600 & (~File.umask)
+ permissions = 0o600 & (~File.umask)
File.open(credentials_path, "w", permissions) do |f|
f.write config.to_yaml
end
diff --git a/lib/rubygems/indexer.rb b/lib/rubygems/indexer.rb
index 6a13d9c11c..c6691517b3 100644
--- a/lib/rubygems/indexer.rb
+++ b/lib/rubygems/indexer.rb
@@ -327,7 +327,7 @@ class Gem::Indexer
def make_temp_directories
FileUtils.rm_rf @directory
- FileUtils.mkdir_p @directory, :mode => 0700
+ FileUtils.mkdir_p @directory, :mode => 0o700
FileUtils.mkdir_p @quick_marshal_dir
end
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index 5aa6acf811..0534d7c36b 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -316,7 +316,7 @@ class Gem::Installer
FileUtils.rm_rf spec.extension_dir
dir_mode = options[:dir_mode]
- FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0o755
if @options[:install_as_default]
extract_bin
@@ -495,7 +495,7 @@ class Gem::Installer
next unless File.exist? bin_path
mode = File.stat(bin_path).mode
- dir_mode = options[:prog_mode] || (mode | 0111)
+ dir_mode = options[:prog_mode] || (mode | 0o111)
unless dir_mode == mode
require "fileutils"
@@ -540,9 +540,9 @@ class Gem::Installer
require "fileutils"
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
- File.open bin_script_path, "wb", 0755 do |file|
+ File.open bin_script_path, "wb", 0o755 do |file|
file.print app_script_text(filename)
- file.chmod(options[:prog_mode] || 0755)
+ file.chmod(options[:prog_mode] || 0o755)
end
verbose bin_script_path
@@ -712,7 +712,7 @@ class Gem::Installer
end
def verify_gem_home # :nodoc:
- FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0755
+ FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0o755
raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
end
@@ -934,7 +934,7 @@ TEXT
build_info_dir = File.join gem_home, "build_info"
dir_mode = options[:dir_mode]
- FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0o755
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
@@ -957,7 +957,7 @@ TEXT
def ensure_writable_dir(dir) # :nodoc:
begin
- Dir.mkdir dir, *[options[:dir_mode] && 0755].compact
+ Dir.mkdir dir, *[options[:dir_mode] && 0o755].compact
rescue SystemCallError
raise unless File.directory? dir
end
diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index c3f91ebc34..61cae75357 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -230,7 +230,7 @@ class Gem::Package
end
end
- tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io|
+ tar.add_file_signed "checksums.yaml.gz", 0o444, @signer do |io|
gzip_to io do |gz_io|
Psych.dump checksums_by_algorithm, gz_io
end
@@ -242,7 +242,7 @@ class Gem::Package
# and adds this file to the +tar+.
def add_contents(tar) # :nodoc:
- digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io|
+ digests = tar.add_file_signed "data.tar.gz", 0o444, @signer do |io|
gzip_to io do |gz_io|
Gem::Package::TarWriter.new gz_io do |data_tar|
add_files data_tar
@@ -278,7 +278,7 @@ class Gem::Package
# Adds the package's Gem::Specification to the +tar+ file
def add_metadata(tar) # :nodoc:
- digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io|
+ digests = tar.add_file_signed "metadata.gz", 0o444, @signer do |io|
gzip_to io do |gz_io|
gz_io.write @spec.to_yaml
end
@@ -382,7 +382,7 @@ EOM
def extract_files(destination_dir, pattern = "*")
verify unless @spec
- FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0755
+ FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0o755
@gem.with_read_io do |io|
reader = Gem::Package::TarReader.new io
@@ -432,7 +432,7 @@ EOM
FileUtils.rm_rf destination
mkdir_options = {}
- mkdir_options[:mode] = dir_mode ? 0755 : (entry.header.mode if entry.directory?)
+ mkdir_options[:mode] = dir_mode ? 0o755 : (entry.header.mode if entry.directory?)
mkdir =
if entry.directory?
destination
@@ -468,7 +468,7 @@ EOM
end
def file_mode(mode) # :nodoc:
- ((mode & 0111).zero? ? data_mode : prog_mode) ||
+ ((mode & 0o111).zero? ? data_mode : prog_mode) ||
# If we're not using one of the default modes, then we're going to fall
# back to the mode from the tarball. In this case we need to mask it down
# to fit into 2^16 bits (the maximum value for a mode in CRuby since it
diff --git a/lib/rubygems/package/old.rb b/lib/rubygems/package/old.rb
index bf0ed61b0a..41f6986b8f 100644
--- a/lib/rubygems/package/old.rb
+++ b/lib/rubygems/package/old.rb
@@ -78,7 +78,7 @@ class Gem::Package::Old < Gem::Package
FileUtils.rm_rf destination
- FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755
+ FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0o755
File.open destination, "wb", file_mode(entry["mode"]) do |out|
out.write file_data
diff --git a/lib/rubygems/package/tar_writer.rb b/lib/rubygems/package/tar_writer.rb
index 30880d893c..e06ec25961 100644
--- a/lib/rubygems/package/tar_writer.rb
+++ b/lib/rubygems/package/tar_writer.rb
@@ -192,7 +192,7 @@ class Gem::Package::TarWriter
if signer.key
signature = signer.sign signature_digest.digest
- add_file_simple "#{name}.sig", 0444, signature.length do |io|
+ add_file_simple "#{name}.sig", 0o444, signature.length do |io|
io.write signature
end
end
diff --git a/lib/rubygems/security.rb b/lib/rubygems/security.rb
index 46f084fa40..1e8e57b5a9 100644
--- a/lib/rubygems/security.rb
+++ b/lib/rubygems/security.rb
@@ -589,7 +589,7 @@ module Gem::Security
# +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
# passed to +to_pem+.
- def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER)
+ def self.write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
path = File.expand_path path
File.open path, "wb", permissions do |io|
diff --git a/lib/rubygems/security/trust_dir.rb b/lib/rubygems/security/trust_dir.rb
index 713d0e6ffa..ea011e6d65 100644
--- a/lib/rubygems/security/trust_dir.rb
+++ b/lib/rubygems/security/trust_dir.rb
@@ -9,8 +9,8 @@ class Gem::Security::TrustDir
# Default permissions for the trust directory and its contents
DEFAULT_PERMISSIONS = {
- :trust_dir => 0700,
- :trusted_cert => 0600,
+ :trust_dir => 0o700,
+ :trusted_cert => 0o600,
}.freeze
##
@@ -91,7 +91,7 @@ class Gem::Security::TrustDir
destination = cert_path certificate
- File.open destination, "wb", 0600 do |io|
+ File.open destination, "wb", 0o600 do |io|
io.write certificate.to_pem
io.chmod(@permissions[:trusted_cert])
end
@@ -109,7 +109,7 @@ class Gem::Security::TrustDir
"trust directory #{@dir} is not a directory" unless
File.directory? @dir
- FileUtils.chmod 0700, @dir
+ FileUtils.chmod 0o700, @dir
else
FileUtils.mkdir_p @dir, :mode => @permissions[:trust_dir]
end
diff --git a/lib/rubygems/specification_policy.rb b/lib/rubygems/specification_policy.rb
index 06c0ba52ec..da3beee628 100644
--- a/lib/rubygems/specification_policy.rb
+++ b/lib/rubygems/specification_policy.rb
@@ -234,7 +234,7 @@ duplicate dependency on #{dep}, (#{prev.requirement}) use:
@specification.files.each do |file|
next unless File.file?(file)
- next if File.stat(file).mode & 0444 == 0444
+ next if File.stat(file).mode & 0o444 == 0o444
warning "#{file} is not world-readable"
end