[rubygems/rubygems] Remove no longer necessary hacks to define the gem command

We did this because RubyGems `require` would call `gem` on self, so
defining a `gem` method in the CLI would cause conflicts. However, this
is not the case since
439c446489,
so this should no longer be necessary.

https://github.com/rubygems/rubygems/commit/3e5c861046
This commit is contained in:
David Rodríguez 2024-11-06 19:01:15 +01:00 committed by git
parent 1615996067
commit 1f62a98f73

View File

@ -539,8 +539,6 @@ module Bundler
end
end
old_gem = instance_method(:gem)
desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
method_option :exe, type: :boolean, default: false, aliases: ["--bin", "-b"], desc: "Generate a binary executable for your library."
method_option :coc, type: :boolean, desc: "Generate a code of conduct file. Set a default with `bundle config set --global gem.coc true`."
@ -564,30 +562,13 @@ module Bundler
method_option :github_username, type: :string, default: Bundler.settings["gem.github_username"], banner: "Set your username on GitHub", desc: "Fill in GitHub username on README so that you don't have to do it manually. Set a default with `bundle config set --global gem.github_username <your_username>`."
def gem(name)
require_relative "cli/gem"
cmd_args = args + [self]
cmd_args.unshift(options)
Gem.new(*cmd_args).run
end
commands["gem"].tap do |gem_command|
def gem_command.run(instance, args = [])
arity = 1 # name
require_relative "cli/gem"
cmd_args = args + [instance]
cmd_args.unshift(instance.options)
cmd = begin
Gem.new(*cmd_args)
rescue ArgumentError => e
instance.class.handle_argument_error(self, e, args, arity)
end
cmd.run
end
end
undef_method(:gem)
define_method(:gem, old_gem)
private :gem
def self.source_root
File.expand_path("templates", __dir__)
end