- #
- B
- C
- E
- H
- L
- N
- R
- W
DEFAULT_BACKTRACE | = | false |
DEFAULT_BENCHMARK | = | false |
DEFAULT_BULK_THRESHOLD | = | 1000 |
DEFAULT_VERBOSITY | = | true |
DEFAULT_UPDATE_SOURCES | = | true |
OPERATING_SYSTEM_DEFAULTS | = | {} |
For Ruby packagers to set configuration defaults. Set in rubygems/defaults/operating_system.rb |
||
PLATFORM_DEFAULTS | = | {} |
For Ruby implementers to set configuration defaults. Set in rubygems/defaults/#{RUBY_ENGINE}.rb |
||
CSIDL_COMMON_APPDATA | = | 0x0023 |
SHGetFolderPath | = | Win32API.new 'shell32', 'SHGetFolderPath', 'PLPLP', 'L', :stdcall |
SYSTEM_WIDE_CONFIG_FILE | = | File.join system_config_path, 'gemrc' |
[R] | api_keys | Hash of RubyGems.org and alternate API keys |
[R] | args | List of arguments supplied to the config file object. |
[W] | backtrace | True if we print backtraces on errors. |
[RW] | benchmark | True if we are benchmarking this run. |
[RW] | bulk_threshold | Bulk threshold value. If the number of missing gems are above this threshold value, then a bulk download technique is used. (deprecated) |
[R] | hash | |
[RW] | home | Where to install gems (deprecated) |
[RW] | path | Where to look for gems (deprecated) |
[R] | rubygems_api_key | API key for RubyGems.org |
[R] | ssl_ca_cert | Path name of directory or file of openssl CA certificate, used for remote https connection |
[R] | ssl_verify_mode | openssl verify mode value, used for remote https connection |
[RW] | update_sources | True if we want to update the SourceInfoCache every time, false otherwise |
[RW] | verbose | Verbose level of output:
|
Create the config file object. args
is the list of arguments
from the command line.
The following command line options are handled early here rather than later at the time most command options are processed.
--config-file
,--config-file==NAME
-
Obviously these need to be handled by the ConfigFile object to ensure we get the right config file.
--backtrace
-
Backtrace needs to be turned on early so that errors before normal option parsing can be properly handled.
--debug
-
Enable Ruby level debug messages. Handled early for the same reason as –backtrace.
# File ../ruby/lib/rubygems/config_file.rb, line 162 def initialize(arg_list) @config_file_name = nil need_config_file_name = false arg_list = arg_list.map do |arg| if need_config_file_name then @config_file_name = arg need_config_file_name = false nil elsif arg =~ /^--config-file=(.*)/ then @config_file_name = $1 nil elsif arg =~ /^--config-file$/ then need_config_file_name = true nil else arg end end.compact @backtrace = DEFAULT_BACKTRACE @benchmark = DEFAULT_BENCHMARK @bulk_threshold = DEFAULT_BULK_THRESHOLD @verbose = DEFAULT_VERBOSITY @update_sources = DEFAULT_UPDATE_SOURCES operating_system_config = Marshal.load Marshal.dump(OPERATING_SYSTEM_DEFAULTS) platform_config = Marshal.load Marshal.dump(PLATFORM_DEFAULTS) system_config = load_file SYSTEM_WIDE_CONFIG_FILE user_config = load_file config_file_name.dup.untaint @hash = operating_system_config.merge platform_config @hash = @hash.merge system_config @hash = @hash.merge user_config # HACK these override command-line args, which is bad @backtrace = @hash[:backtrace] if @hash.key? :backtrace @benchmark = @hash[:benchmark] if @hash.key? :benchmark @bulk_threshold = @hash[:bulk_threshold] if @hash.key? :bulk_threshold @home = @hash[:gemhome] if @hash.key? :gemhome @path = @hash[:gempath] if @hash.key? :gempath @update_sources = @hash[:update_sources] if @hash.key? :update_sources @verbose = @hash[:verbose] if @hash.key? :verbose @ssl_verify_mode = @hash[:ssl_verify_mode] if @hash.key? :ssl_verify_mode @ssl_ca_cert = @hash[:ssl_ca_cert] if @hash.key? :ssl_ca_cert load_api_keys Gem.sources = @hash[:sources] if @hash.key? :sources handle_arguments arg_list end
Return the configuration information for key
.
True if the backtrace option has been specified, or debug is on.
The name of the configuration file.
Location of RubyGems.org credentials
Delegates to @hash
# File ../ruby/lib/rubygems/config_file.rb, line 272 def each(&block) hash = @hash.dup hash.delete :update_sources hash.delete :verbose hash.delete :benchmark hash.delete :backtrace hash.delete :bulk_threshold yield :update_sources, @update_sources yield :verbose, @verbose yield :benchmark, @benchmark yield :backtrace, @backtrace yield :bulk_threshold, @bulk_threshold yield 'config_file_name', @config_file_name if @config_file_name hash.each(&block) end
Handle the command arguments.
# File ../ruby/lib/rubygems/config_file.rb, line 292 def handle_arguments(arg_list) @args = [] arg_list.each do |arg| case arg when /^--(backtrace|traceback)$/ then @backtrace = true when /^--bench(mark)?$/ then @benchmark = true when /^--debug$/ then $DEBUG = true else @args << arg end end end
# File ../ruby/lib/rubygems/config_file.rb, line 221 def load_api_keys @api_keys = if File.exist? credentials_path then load_file(credentials_path) else @hash end if @api_keys.key? :rubygems_api_key then @rubygems_api_key = @api_keys[:rubygems_api_key] @api_keys[:rubygems] = @api_keys.delete :rubygems_api_key unless @api_keys.key? :rubygems end end
# File ../ruby/lib/rubygems/config_file.rb, line 248 def load_file(filename) Gem.load_yaml return {} unless filename and File.exist? filename begin YAML.load(File.read(filename)) rescue ArgumentError warn "Failed to load #{config_file_name}" rescue Errno::EACCES warn "Failed to load #{config_file_name} due to permissions problem." end or {} end
Really verbose mode gives you extra output.
# File ../ruby/lib/rubygems/config_file.rb, line 233 def rubygems_api_key=(api_key) config = load_file(credentials_path).merge(:rubygems_api_key => api_key) dirname = File.dirname credentials_path Dir.mkdir(dirname) unless File.exist? dirname Gem.load_yaml File.open(credentials_path, 'w') do |f| f.write config.to_yaml end @rubygems_api_key = api_key end