【发布时间】:2016-01-28 09:35:10
【问题描述】:
像许多人一样,我创建了一个 dotfiles 存储库,并尝试将非私有的位提取到各自的 dotfile 中。我通常会加载一个.whatever.local 文件(如果存在),其中可能包含我不想签入存储库的信息。 Rubygems 使用~/.gemrc 文件,但我看不到将私人信息从中提取到单独文件中的方法。有谁知道这是怎么做到的?
我特别希望将sources 列表放在 .gemrc 文件之外。
【问题讨论】:
像许多人一样,我创建了一个 dotfiles 存储库,并尝试将非私有的位提取到各自的 dotfile 中。我通常会加载一个.whatever.local 文件(如果存在),其中可能包含我不想签入存储库的信息。 Rubygems 使用~/.gemrc 文件,但我看不到将私人信息从中提取到单独文件中的方法。有谁知道这是怎么做到的?
我特别希望将sources 列表放在 .gemrc 文件之外。
【问题讨论】:
根据 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 环境变量来加载额外的私有文件。
【讨论】: