Skip to content

Commit

Permalink
[rubygems/rubygems] Use modern hashes consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and matzbot committed Dec 7, 2023
1 parent 9d696aa commit 2755cb1
Show file tree
Hide file tree
Showing 262 changed files with 3,028 additions and 3,114 deletions.
12 changes: 6 additions & 6 deletions lib/bundler.rb
Expand Up @@ -194,7 +194,7 @@ def load
end

def environment
SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", :print_caller_location => true
SharedHelpers.major_deprecation 2, "Bundler.environment has been removed in favor of Bundler.load", print_caller_location: true
load
end

Expand Down Expand Up @@ -353,7 +353,7 @@ def clean_env
removed_message =
"`Bundler.clean_env` has been removed in favor of `Bundler.unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.original_env`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
unbundled_env
end

Expand Down Expand Up @@ -396,7 +396,7 @@ def with_clean_env
removed_message =
"`Bundler.with_clean_env` has been removed in favor of `Bundler.with_unbundled_env`. " \
"If you instead want the environment before bundler was originally loaded, use `Bundler.with_original_env`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
with_env(unbundled_env) { yield }
end

Expand All @@ -418,7 +418,7 @@ def clean_system(*args)
removed_message =
"`Bundler.clean_system` has been removed in favor of `Bundler.unbundled_system`. " \
"If you instead want to run the command in the environment before bundler was originally loaded, use `Bundler.original_system`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
with_env(unbundled_env) { Kernel.system(*args) }
end

Expand All @@ -440,7 +440,7 @@ def clean_exec(*args)
removed_message =
"`Bundler.clean_exec` has been removed in favor of `Bundler.unbundled_exec`. " \
"If you instead want to exec to a command in the environment before bundler was originally loaded, use `Bundler.original_exec`"
Bundler::SharedHelpers.major_deprecation(2, message, :removed_message => removed_message, :print_caller_location => true)
Bundler::SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
with_env(unbundled_env) { Kernel.exec(*args) }
end

Expand Down Expand Up @@ -517,7 +517,7 @@ def safe_load_marshal(data)
raise MarshalError, "#{e.class}: #{e.message}"
end
else
load_marshal(data, :marshal_proc => SafeMarshal.proc)
load_marshal(data, marshal_proc: SafeMarshal.proc)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/build_metadata.rb
Expand Up @@ -29,7 +29,7 @@ def self.git_commit_sha
# commit instance variable then we can't determine its commits SHA.
git_dir = File.expand_path("../../../.git", __dir__)
if File.directory?(git_dir)
return @git_commit_sha = IO.popen(%w[git rev-parse --short HEAD], { :chdir => git_dir }, &:read).strip.freeze
return @git_commit_sha = IO.popen(%w[git rev-parse --short HEAD], { chdir: git_dir }, &:read).strip.freeze
end

@git_commit_sha ||= "unknown"
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/capistrano.rb
Expand Up @@ -17,6 +17,6 @@

Capistrano::Configuration.instance(:must_exist).load do
before "deploy:finalize_update", "bundle:install"
Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
Bundler::Deployment.define_task(self, :task, except: { no_release: true })
set :rake, lambda { "#{fetch(:bundle_cmd, "bundle")} exec rake" }
end
2 changes: 1 addition & 1 deletion lib/bundler/checksum.rb
Expand Up @@ -23,7 +23,7 @@ def from_gem_package(gem_package, algo = DEFAULT_ALGORITHM)

def from_gem(io, pathname, algo = DEFAULT_ALGORITHM)
digest = Bundler::SharedHelpers.digest(algo.upcase).new
buf = String.new(:capacity => DEFAULT_BLOCK_SIZE)
buf = String.new(capacity: DEFAULT_BLOCK_SIZE)
digest << io.readpartial(DEFAULT_BLOCK_SIZE, buf) until io.eof?
Checksum.new(algo, digest.hexdigest!, Source.new(:gem, pathname))
end
Expand Down
411 changes: 166 additions & 245 deletions lib/bundler/cli.rb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/bundler/cli/add.rb
Expand Up @@ -28,9 +28,9 @@ def inject_dependencies
dependencies = gems.map {|g| Bundler::Dependency.new(g, version, options) }

Injector.inject(dependencies,
:conservative_versioning => options[:version].nil?, # Perform conservative versioning only when version is not specified
:optimistic => options[:optimistic],
:strict => options[:strict])
conservative_versioning: options[:version].nil?, # Perform conservative versioning only when version is not specified
optimistic: options[:optimistic],
strict: options[:strict])
end

def validate_options!
Expand Down
8 changes: 4 additions & 4 deletions lib/bundler/cli/binstubs.rb
Expand Up @@ -17,9 +17,9 @@ def run
installer = Installer.new(Bundler.root, Bundler.definition)

installer_opts = {
:force => options[:force],
:binstubs_cmd => true,
:all_platforms => options["all-platforms"],
force: options[:force],
binstubs_cmd: true,
all_platforms: options["all-platforms"],
}

if options[:all]
Expand All @@ -45,7 +45,7 @@ def run
next
end

Bundler.settings.temporary(:path => (Bundler.settings[:path] || Bundler.root)) do
Bundler.settings.temporary(path: (Bundler.settings[:path] || Bundler.root)) do
installer.generate_standalone_bundler_executable_stubs(spec, installer_opts)
end
else
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/cache.rb
Expand Up @@ -19,7 +19,7 @@ def run
# TODO: move cache contents here now that all bundles are locked
custom_path = Bundler.settings[:path] if options[:path]

Bundler.settings.temporary(:cache_all_platforms => options["all-platforms"]) do
Bundler.settings.temporary(cache_all_platforms: options["all-platforms"]) do
Bundler.load.cache(custom_path)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/check.rb
Expand Up @@ -32,7 +32,7 @@ def run
Bundler.ui.error "This bundle has been frozen, but there is no #{SharedHelpers.relative_lockfile_path} present"
exit 1
else
Bundler.load.lock(:preserve_unknown_sections => true) unless options[:"dry-run"]
Bundler.load.lock(preserve_unknown_sections: true) unless options[:"dry-run"]
Bundler.ui.info "The Gemfile's dependencies are satisfied"
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/bundler/cli/config.rb
Expand Up @@ -2,17 +2,17 @@

module Bundler
class CLI::Config < Thor
class_option :parseable, :type => :boolean, :banner => "Use minimal formatting for more parseable output"
class_option :parseable, type: :boolean, banner: "Use minimal formatting for more parseable output"

def self.scope_options
method_option :global, :type => :boolean, :banner => "Only change the global config"
method_option :local, :type => :boolean, :banner => "Only change the local config"
method_option :global, type: :boolean, banner: "Only change the global config"
method_option :local, type: :boolean, banner: "Only change the local config"
end
private_class_method :scope_options

desc "base NAME [VALUE]", "The Bundler 1 config interface", :hide => true
desc "base NAME [VALUE]", "The Bundler 1 config interface", hide: true
scope_options
method_option :delete, :type => :boolean, :banner => "delete"
method_option :delete, type: :boolean, banner: "delete"
def base(name = nil, *value)
new_args =
if ARGV.size == 1
Expand All @@ -27,7 +27,7 @@ def base(name = nil, *value)

message = "Using the `config` command without a subcommand [list, get, set, unset] is deprecated and will be removed in the future. Use `bundle #{new_args.join(" ")}` instead."
removed_message = "Using the `config` command without a subcommand [list, get, set, unset] is has been removed. Use `bundle #{new_args.join(" ")}` instead."
SharedHelpers.major_deprecation 3, message, :removed_message => removed_message
SharedHelpers.major_deprecation 3, message, removed_message: removed_message

Base.new(options, name, value, self).run
end
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/console.rb
Expand Up @@ -11,7 +11,7 @@ def initialize(options, group)
def run
message = "bundle console will be replaced by `bin/console` generated by `bundle gem <name>`"
removed_message = "bundle console has been replaced by `bin/console` generated by `bundle gem <name>`"
Bundler::SharedHelpers.major_deprecation 2, message, :removed_message => removed_message
Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message

group ? Bundler.require(:default, *group.split(" ").map!(&:to_sym)) : Bundler.require
ARGV.clear
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/exec.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(options, args)
@options = options
@cmd = args.shift
@args = args
@args << { :close_others => !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
@args << { close_others: !options.keep_file_descriptors? } unless Bundler.current_ruby.jruby?
end

def run
Expand Down
42 changes: 21 additions & 21 deletions lib/bundler/cli/gem.rb
Expand Up @@ -59,23 +59,23 @@ def run
end

config = {
:name => name,
:underscored_name => underscored_name,
:namespaced_path => namespaced_path,
:makefile_path => "#{underscored_name}/#{underscored_name}",
:constant_name => constant_name,
:constant_array => constant_array,
:author => git_author_name.empty? ? "TODO: Write your name" : git_author_name,
:email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
:test => options[:test],
:ext => extension,
:exe => options[:exe],
:bundler_version => bundler_dependency_version,
:git => use_git,
:github_username => github_username.empty? ? "[USERNAME]" : github_username,
:required_ruby_version => required_ruby_version,
:rust_builder_required_rubygems_version => rust_builder_required_rubygems_version,
:minitest_constant_name => minitest_constant_name,
name: name,
underscored_name: underscored_name,
namespaced_path: namespaced_path,
makefile_path: "#{underscored_name}/#{underscored_name}",
constant_name: constant_name,
constant_array: constant_array,
author: git_author_name.empty? ? "TODO: Write your name" : git_author_name,
email: git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
test: options[:test],
ext: extension,
exe: options[:exe],
bundler_version: bundler_dependency_version,
git: use_git,
github_username: github_username.empty? ? "[USERNAME]" : github_username,
required_ruby_version: required_ruby_version,
rust_builder_required_rubygems_version: rust_builder_required_rubygems_version,
minitest_constant_name: minitest_constant_name,
}
ensure_safe_gem_name(name, constant_array)

Expand Down Expand Up @@ -236,7 +236,7 @@ def run
end

if use_git
IO.popen(%w[git add .], { :chdir => target }, &:read)
IO.popen(%w[git add .], { chdir: target }, &:read)
end

# Open gemspec in editor
Expand Down Expand Up @@ -382,18 +382,18 @@ def deprecated_rubocop_option
if options[:rubocop]
Bundler::SharedHelpers.major_deprecation 2,
"--rubocop is deprecated, use --linter=rubocop",
:removed_message => "--rubocop has been removed, use --linter=rubocop"
removed_message: "--rubocop has been removed, use --linter=rubocop"
"rubocop"
else
Bundler::SharedHelpers.major_deprecation 2,
"--no-rubocop is deprecated, use --linter",
:removed_message => "--no-rubocop has been removed, use --linter"
removed_message: "--no-rubocop has been removed, use --linter"
false
end
elsif !Bundler.settings["gem.rubocop"].nil?
Bundler::SharedHelpers.major_deprecation 2,
"config gem.rubocop is deprecated; we've updated your config to use gem.linter instead",
:removed_message => "config gem.rubocop has been removed; we've updated your config to use gem.linter instead"
removed_message: "config gem.rubocop has been removed; we've updated your config to use gem.linter instead"
Bundler.settings["gem.rubocop"] ? "rubocop" : false
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/bundler/cli/install.rb
Expand Up @@ -52,7 +52,7 @@ def run
if options["binstubs"]
Bundler::SharedHelpers.major_deprecation 2,
"The --binstubs option will be removed in favor of `bundle binstubs --all`",
:removed_message => "The --binstubs option have been removed in favor of `bundle binstubs --all`"
removed_message: "The --binstubs option have been removed in favor of `bundle binstubs --all`"
end

Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
Expand All @@ -62,7 +62,7 @@ def run

installer = Installer.install(Bundler.root, definition, options)

Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
Bundler.settings.temporary(cache_all_platforms: options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
end

Expand Down Expand Up @@ -96,7 +96,7 @@ def run
def warn_if_root
return if Bundler.settings[:silence_root_warning] || Gem.win_platform? || !Process.uid.zero?
Bundler.ui.warn "Don't run Bundler as root. Installing your bundle as root " \
"will break this application for all non-root users on this machine.", :wrap => true
"will break this application for all non-root users on this machine.", wrap: true
end

def dependencies_count_for(definition)
Expand Down Expand Up @@ -149,7 +149,7 @@ def normalize_settings
Bundler.settings.set_command_option_if_given :path, options[:path]

if options["standalone"] && Bundler.settings[:path].nil? && !options["local"]
Bundler.settings.temporary(:path_relative_to_cwd => false) do
Bundler.settings.temporary(path_relative_to_cwd: false) do
Bundler.settings.set_command_option :path, "bundle"
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/bundler/cli/lock.rb
Expand Up @@ -26,14 +26,14 @@ def run

if update.is_a?(Array) # unlocking specific gems
Bundler::CLI::Common.ensure_all_gems_in_lockfile!(update)
update = { :gems => update, :conservative => conservative }
update = { gems: update, conservative: conservative }
elsif update && conservative
update = { :conservative => conservative }
update = { conservative: conservative }
elsif update && bundler
update = { :bundler => bundler }
update = { bundler: bundler }
end

Bundler.settings.temporary(:frozen => false) do
Bundler.settings.temporary(frozen: false) do
definition = Bundler.definition(update)

Bundler::CLI::Common.configure_gem_version_promoter(definition, options) if options[:update]
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/cli/open.rb
Expand Up @@ -21,7 +21,7 @@ def run
require "shellwords"
command = Shellwords.split(editor) << File.join([root_path, path].compact)
Bundler.with_original_env do
system(*command, { :chdir => root_path })
system(*command, { chdir: root_path })
end || Bundler.ui.info("Could not run '#{command.join(" ")}'")
end
end
Expand Down
36 changes: 18 additions & 18 deletions lib/bundler/cli/outdated.rb
Expand Up @@ -41,12 +41,12 @@ def run
# We're doing a full update
Bundler.definition(true)
else
Bundler.definition(:gems => gems, :sources => sources)
Bundler.definition(gems: gems, sources: sources)
end

Bundler::CLI::Common.configure_gem_version_promoter(
Bundler.definition,
options.merge(:strict => @strict)
options.merge(strict: @strict)
)

definition_resolution = proc do
Expand Down Expand Up @@ -90,10 +90,10 @@ def run
end

outdated_gems << {
:active_spec => active_spec,
:current_spec => current_spec,
:dependency => dependency,
:groups => groups,
active_spec: active_spec,
current_spec: current_spec,
dependency: dependency,
groups: groups,
}
end

Expand All @@ -105,7 +105,7 @@ def run
end
else
relevant_outdated_gems = if options_include_groups
by_group(outdated_gems, :filter => options[:group])
by_group(outdated_gems, filter: options[:group])
else
outdated_gems
end
Expand Down Expand Up @@ -188,7 +188,7 @@ def print_gems_json(gems_list)
)
end

data = { :outdated_count => gems_list.count, :outdated_gems => data }
data = { outdated_count: gems_list.count, outdated_gems: data }
Bundler.ui.info data.to_json
end

Expand Down Expand Up @@ -233,21 +233,21 @@ def print_gem(current_spec, active_spec, dependency, groups)

def gem_data_for(current_spec, active_spec, dependency, groups)
{
:current_spec => spec_data_for(current_spec),
:active_spec => spec_data_for(active_spec),
:dependency => dependency&.to_s,
:groups => (groups || "").split(", "),
current_spec: spec_data_for(current_spec),
active_spec: spec_data_for(active_spec),
dependency: dependency&.to_s,
groups: (groups || "").split(", "),
}
end

def spec_data_for(spec)
{
:name => spec.name,
:version => spec.version.to_s,
:platform => spec.platform,
:source => spec.source.to_s,
:required_ruby_version => spec.required_ruby_version.to_s,
:required_rubygems_version => spec.required_rubygems_version.to_s,
name: spec.name,
version: spec.version.to_s,
platform: spec.platform,
source: spec.source.to_s,
required_ruby_version: spec.required_ruby_version.to_s,
required_rubygems_version: spec.required_rubygems_version.to_s,
}
end

Expand Down

0 comments on commit 2755cb1

Please sign in to comment.