ruby-changes:72353
From: David <ko1@a...>
Date: Wed, 29 Jun 2022 03:26:07 +0900 (JST)
Subject: [ruby-changes:72353] a16de43f23 (master): [rubygems/rubygems] Add `gem env user_gemhome` and `gem env user_gemdir`
https://git.ruby-lang.org/ruby.git/commit/?id=a16de43f23 From a16de43f23c0ca160ee3bf3c8655a6ebb586e8fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Wed, 22 Jun 2022 14:24:19 +0200 Subject: [rubygems/rubygems] Add `gem env user_gemhome` and `gem env user_gemdir` https://github.com/rubygems/rubygems/commit/14d3f80df6 --- lib/rubygems/commands/environment_command.rb | 3 +++ .../test_gem_commands_environment_command.rb | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/lib/rubygems/commands/environment_command.rb b/lib/rubygems/commands/environment_command.rb index ceccf882ee..b6b3d3812c 100644 --- a/lib/rubygems/commands/environment_command.rb +++ b/lib/rubygems/commands/environment_command.rb @@ -10,6 +10,7 @@ class Gem::Commands::EnvironmentCommand < Gem::Command https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/environment_command.rb#L10 args = <<-EOF home display the path where gems are installed. Aliases: gemhome, gemdir, GEM_HOME path display path used to search for gems. Aliases: gempath, GEM_PATH + user_gemhome display the path where gems are installed when `--user-install` is given. Aliases: user_gemdir version display the gem format version remotesources display the remote gem servers platform display the supported gem platforms @@ -80,6 +81,8 @@ lib/rubygems/defaults/operating_system.rb https://github.com/ruby/ruby/blob/trunk/lib/rubygems/commands/environment_command.rb#L81 Gem.dir when /^gempath/, /^path/, /^GEM_PATH/ then Gem.path.join(File::PATH_SEPARATOR) + when /^user_gemdir/, /^user_gemhome/ then + Gem.user_dir when /^remotesources/ then Gem.sources.to_a.join("\n") when /^platform/ then diff --git a/test/rubygems/test_gem_commands_environment_command.rb b/test/rubygems/test_gem_commands_environment_command.rb index 23aa11990b..eeddb2befe 100644 --- a/test/rubygems/test_gem_commands_environment_command.rb +++ b/test/rubygems/test_gem_commands_environment_command.rb @@ -65,6 +65,28 @@ class TestGemCommandsEnvironmentCommand < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_commands_environment_command.rb#L65 assert_equal '', @ui.error end + def test_execute_user_gemdir + @cmd.send :handle_options, %w[user_gemdir] + + use_ui @ui do + @cmd.execute + end + + assert_equal "#{Gem.user_dir}\n", @ui.output + assert_equal '', @ui.error + end + + def test_execute_user_gemhome + @cmd.send :handle_options, %w[user_gemhome] + + use_ui @ui do + @cmd.execute + end + + assert_equal "#{Gem.user_dir}\n", @ui.output + assert_equal '', @ui.error + end + def test_execute_gempath @cmd.send :handle_options, %w[gempath] -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/