Skip to content

Commit 1f62a98

Browse files
deivid-rodriguezmatzbot
authored andcommitted
[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 ruby/rubygems@439c446, so this should no longer be necessary. ruby/rubygems@3e5c861046
1 parent 1615996 commit 1f62a98

File tree

1 file changed

+4
-23
lines changed

1 file changed

+4
-23
lines changed

lib/bundler/cli.rb

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,6 @@ def viz
539539
end
540540
end
541541

542-
old_gem = instance_method(:gem)
543-
544542
desc "gem NAME [OPTIONS]", "Creates a skeleton for creating a rubygem"
545543
method_option :exe, type: :boolean, default: false, aliases: ["--bin", "-b"], desc: "Generate a binary executable for your library."
546544
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 @@ def viz
564562
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>`."
565563

566564
def gem(name)
567-
end
568-
569-
commands["gem"].tap do |gem_command|
570-
def gem_command.run(instance, args = [])
571-
arity = 1 # name
572-
573-
require_relative "cli/gem"
574-
cmd_args = args + [instance]
575-
cmd_args.unshift(instance.options)
565+
require_relative "cli/gem"
566+
cmd_args = args + [self]
567+
cmd_args.unshift(options)
576568

577-
cmd = begin
578-
Gem.new(*cmd_args)
579-
rescue ArgumentError => e
580-
instance.class.handle_argument_error(self, e, args, arity)
581-
end
582-
583-
cmd.run
584-
end
569+
Gem.new(*cmd_args).run
585570
end
586571

587-
undef_method(:gem)
588-
define_method(:gem, old_gem)
589-
private :gem
590-
591572
def self.source_root
592573
File.expand_path("templates", __dir__)
593574
end

0 commit comments

Comments
 (0)