是否有 .gemrc.local 或等价物?

Is there a .gemrc.local or equivalent?

像许多人一样,我创建了一个点文件存储库,并尝试将不私有的位提取到各自的点文件中。我通常会加载一个 .whatever.local 文件(如果存在),其中可能包含我不想签入存储库的信息。 Rubygems 使用 ~/.gemrc 文件,但我看不到将私有信息从中提取到单独文件中的方法。有谁知道如何做到这一点?

特别是我想要 .gemrc 文件外部的 sources 列表。

根据 v2.4.6(最新版本,但不是最新版本),我没有看到与 .local 等效的版本。

不过,RubyGems 的源代码说明了一些与您想要实现的目标相关的内容。例如,在 src/ruby-2.3.0/lib/rubygems/config_file.rb:

##
# Gem::ConfigFile RubyGems options and gem command options from gemrc.
#
# gemrc is a YAML file that uses strings to match gem command arguments and
# symbols to match RubyGems options.
#
# Gem command arguments use a String key that matches the command name and
# +:sources+:: Sets Gem::sources
# +:verbose+:: See #verbose
#
# gemrc files may exist in various locations and are read and merged in
# the following order:
#
# - system wide (/etc/gemrc)
# - per user (~/.gemrc)
# - per environment (gemrc files listed in the GEMRC environment variable)

因此您也可以使用 GEMRC 环境变量来加载额外的私人文件。