Skip to content

Commit d89cc31

Browse files
committed
util/rubocop -A --only Style/NumericLiteralPrefix
1 parent 65e2760 commit d89cc31

36 files changed

Lines changed: 198 additions & 198 deletions

lib/rubygems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ def self.ensure_default_gem_subdirectories(dir = Gem.dir, mode = nil)
429429

430430
def self.ensure_subdirectories(dir, mode, subdirs) # :nodoc:
431431
old_umask = File.umask
432-
File.umask old_umask | 002
432+
File.umask old_umask | 0o002
433433

434434
options = {}
435435

lib/rubygems/commands/cert_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def build_key # :nodoc:
178178

179179
algorithm = options[:key_algorithm] || Gem::Security::DEFAULT_KEY_ALGORITHM
180180
key = Gem::Security.create_key(algorithm)
181-
key_path = Gem::Security.write key, "gem-private_key.pem", 0600, passphrase
181+
key_path = Gem::Security.write key, "gem-private_key.pem", 0o600, passphrase
182182

183183
[key, key_path]
184184
end
@@ -291,7 +291,7 @@ def sign(cert_file)
291291
cert = File.read cert_file
292292
cert = OpenSSL::X509::Certificate.new cert
293293

294-
permissions = File.stat(cert_file).mode & 0777
294+
permissions = File.stat(cert_file).mode & 0o777
295295

296296
issuer_cert = options[:issuer_cert]
297297
issuer_key = options[:key]

lib/rubygems/commands/setup_command.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def execute
243243
end
244244

245245
def install_executables(bin_dir)
246-
prog_mode = options[:prog_mode] || 0755
246+
prog_mode = options[:prog_mode] || 0o755
247247

248248
executables = { "gem" => "bin" }
249249
executables.each do |tool, path|
@@ -369,7 +369,7 @@ def install_default_bundler_gem(bin_dir)
369369
File.dirname(loaded_from)
370370
else
371371
target_specs_dir = File.join(default_dir, "specifications", "default")
372-
mkdir_p target_specs_dir, :mode => 0755
372+
mkdir_p target_specs_dir, :mode => 0o755
373373
target_specs_dir
374374
end
375375

@@ -393,7 +393,7 @@ def install_default_bundler_gem(bin_dir)
393393
end
394394

395395
bundler_bin_dir = bundler_spec.bin_dir
396-
mkdir_p bundler_bin_dir, :mode => 0755
396+
mkdir_p bundler_bin_dir, :mode => 0o755
397397
bundler_spec.executables.each do |e|
398398
cp File.join("bundler", bundler_spec.bindir, e), File.join(bundler_bin_dir, e)
399399
end
@@ -430,8 +430,8 @@ def make_destination_dirs
430430
lib_dir, bin_dir = generate_default_dirs
431431
end
432432

433-
mkdir_p lib_dir, :mode => 0755
434-
mkdir_p bin_dir, :mode => 0755
433+
mkdir_p lib_dir, :mode => 0o755
434+
mkdir_p bin_dir, :mode => 0o755
435435

436436
[lib_dir, bin_dir]
437437
end
@@ -639,10 +639,10 @@ def install_file(file, dest_dir)
639639
dest_file = File.join dest_dir, file
640640
dest_dir = File.dirname dest_file
641641
unless File.directory? dest_dir
642-
mkdir_p dest_dir, :mode => 0755
642+
mkdir_p dest_dir, :mode => 0o755
643643
end
644644

645-
install file, dest_file, :mode => options[:data_mode] || 0644
645+
install file, dest_file, :mode => options[:data_mode] || 0o644
646646
end
647647

648648
def remove_file_list(files, dir)

lib/rubygems/config_file.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ def check_credentials_permissions
241241
return if Gem.win_platform? # windows doesn't write 0600 as 0600
242242
return unless File.exist? credentials_path
243243

244-
existing_permissions = File.stat(credentials_path).mode & 0777
244+
existing_permissions = File.stat(credentials_path).mode & 0o777
245245

246-
return if existing_permissions == 0600
246+
return if existing_permissions == 0o600
247247

248248
alert_error <<-ERROR
249249
Your gem push credentials file located at:
@@ -326,7 +326,7 @@ def set_api_key(host, api_key)
326326

327327
Gem.load_yaml
328328

329-
permissions = 0600 & (~File.umask)
329+
permissions = 0o600 & (~File.umask)
330330
File.open(credentials_path, "w", permissions) do |f|
331331
f.write config.to_yaml
332332
end

lib/rubygems/indexer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def install_indices
327327

328328
def make_temp_directories
329329
FileUtils.rm_rf @directory
330-
FileUtils.mkdir_p @directory, :mode => 0700
330+
FileUtils.mkdir_p @directory, :mode => 0o700
331331
FileUtils.mkdir_p @quick_marshal_dir
332332
end
333333

lib/rubygems/installer.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def install
316316
FileUtils.rm_rf spec.extension_dir
317317

318318
dir_mode = options[:dir_mode]
319-
FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0755
319+
FileUtils.mkdir_p gem_dir, :mode => dir_mode && 0o755
320320

321321
if @options[:install_as_default]
322322
extract_bin
@@ -495,7 +495,7 @@ def generate_bin # :nodoc:
495495
next unless File.exist? bin_path
496496

497497
mode = File.stat(bin_path).mode
498-
dir_mode = options[:prog_mode] || (mode | 0111)
498+
dir_mode = options[:prog_mode] || (mode | 0o111)
499499

500500
unless dir_mode == mode
501501
require "fileutils"
@@ -540,9 +540,9 @@ def generate_bin_script(filename, bindir)
540540
require "fileutils"
541541
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
542542

543-
File.open bin_script_path, "wb", 0755 do |file|
543+
File.open bin_script_path, "wb", 0o755 do |file|
544544
file.print app_script_text(filename)
545-
file.chmod(options[:prog_mode] || 0755)
545+
file.chmod(options[:prog_mode] || 0o755)
546546
end
547547

548548
verbose bin_script_path
@@ -712,7 +712,7 @@ def check_that_user_bin_dir_is_in_path # :nodoc:
712712
end
713713

714714
def verify_gem_home # :nodoc:
715-
FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0755
715+
FileUtils.mkdir_p gem_home, :mode => options[:dir_mode] && 0o755
716716
raise Gem::FilePermissionError, gem_home unless File.writable?(gem_home)
717717
end
718718

@@ -934,7 +934,7 @@ def write_build_info_file
934934
build_info_dir = File.join gem_home, "build_info"
935935

936936
dir_mode = options[:dir_mode]
937-
FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0755
937+
FileUtils.mkdir_p build_info_dir, :mode => dir_mode && 0o755
938938

939939
build_info_file = File.join build_info_dir, "#{spec.full_name}.info"
940940

@@ -957,7 +957,7 @@ def write_cache_file
957957

958958
def ensure_writable_dir(dir) # :nodoc:
959959
begin
960-
Dir.mkdir dir, *[options[:dir_mode] && 0755].compact
960+
Dir.mkdir dir, *[options[:dir_mode] && 0o755].compact
961961
rescue SystemCallError
962962
raise unless File.directory? dir
963963
end

lib/rubygems/package.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def add_checksums(tar)
230230
end
231231
end
232232

233-
tar.add_file_signed "checksums.yaml.gz", 0444, @signer do |io|
233+
tar.add_file_signed "checksums.yaml.gz", 0o444, @signer do |io|
234234
gzip_to io do |gz_io|
235235
Psych.dump checksums_by_algorithm, gz_io
236236
end
@@ -242,7 +242,7 @@ def add_checksums(tar)
242242
# and adds this file to the +tar+.
243243

244244
def add_contents(tar) # :nodoc:
245-
digests = tar.add_file_signed "data.tar.gz", 0444, @signer do |io|
245+
digests = tar.add_file_signed "data.tar.gz", 0o444, @signer do |io|
246246
gzip_to io do |gz_io|
247247
Gem::Package::TarWriter.new gz_io do |data_tar|
248248
add_files data_tar
@@ -278,7 +278,7 @@ def add_files(tar) # :nodoc:
278278
# Adds the package's Gem::Specification to the +tar+ file
279279

280280
def add_metadata(tar) # :nodoc:
281-
digests = tar.add_file_signed "metadata.gz", 0444, @signer do |io|
281+
digests = tar.add_file_signed "metadata.gz", 0o444, @signer do |io|
282282
gzip_to io do |gz_io|
283283
gz_io.write @spec.to_yaml
284284
end
@@ -382,7 +382,7 @@ def digest(entry) # :nodoc:
382382
def extract_files(destination_dir, pattern = "*")
383383
verify unless @spec
384384

385-
FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0755
385+
FileUtils.mkdir_p destination_dir, :mode => dir_mode && 0o755
386386

387387
@gem.with_read_io do |io|
388388
reader = Gem::Package::TarReader.new io
@@ -432,7 +432,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
432432
FileUtils.rm_rf destination
433433

434434
mkdir_options = {}
435-
mkdir_options[:mode] = dir_mode ? 0755 : (entry.header.mode if entry.directory?)
435+
mkdir_options[:mode] = dir_mode ? 0o755 : (entry.header.mode if entry.directory?)
436436
mkdir =
437437
if entry.directory?
438438
destination
@@ -468,7 +468,7 @@ def extract_tar_gz(io, destination_dir, pattern = "*") # :nodoc:
468468
end
469469

470470
def file_mode(mode) # :nodoc:
471-
((mode & 0111).zero? ? data_mode : prog_mode) ||
471+
((mode & 0o111).zero? ? data_mode : prog_mode) ||
472472
# If we're not using one of the default modes, then we're going to fall
473473
# back to the mode from the tarball. In this case we need to mask it down
474474
# to fit into 2^16 bits (the maximum value for a mode in CRuby since it

lib/rubygems/package/old.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def extract_files(destination_dir)
7878

7979
FileUtils.rm_rf destination
8080

81-
FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0755
81+
FileUtils.mkdir_p File.dirname(destination), :mode => dir_mode && 0o755
8282

8383
File.open destination, "wb", file_mode(entry["mode"]) do |out|
8484
out.write file_data

lib/rubygems/package/tar_writer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def add_file_signed(name, mode, signer)
192192
if signer.key
193193
signature = signer.sign signature_digest.digest
194194

195-
add_file_simple "#{name}.sig", 0444, signature.length do |io|
195+
add_file_simple "#{name}.sig", 0o444, signature.length do |io|
196196
io.write signature
197197
end
198198
end

lib/rubygems/security.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ def self.trusted_certificates(&block)
589589
# +permissions+. If passed +cipher+ and +passphrase+ those arguments will be
590590
# passed to +to_pem+.
591591

592-
def self.write(pemmable, path, permissions = 0600, passphrase = nil, cipher = KEY_CIPHER)
592+
def self.write(pemmable, path, permissions = 0o600, passphrase = nil, cipher = KEY_CIPHER)
593593
path = File.expand_path path
594594

595595
File.open path, "wb", permissions do |io|

0 commit comments

Comments
 (0)