Sha256: 49058263c7ec1cd581368db335a9578f824d758095f19752e67b9b8426a76dd9
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
#!/usr/bin/env ruby require 'yaml' module Gem class ConfigFile attr_reader :backtrace, :args def initialize(arg_list) handle_arguments(arg_list) begin @hash = open(config_file_name) {|f| YAML.load(f) } rescue ArgumentError warn "Failed to load #{config_file_name}" rescue Errno::ENOENT warn "Config file #{config_file_name} does not exist" end @hash ||= {} end def config_file_name @config_file_name || default_config_file_name end def [](key) @hash[key.to_s] end private def handle_arguments(arg_list) need_cfg_name = false @args = [] arg_list.each do |arg| if need_cfg_name @config_file_name = arg need_cfg_name = false else case arg when /^--backtrace$/ @backtrace = true when /^--debug$/ $DEBUG = true when /^--config-file$/ need_cfg_name = true when /^--config-file=(.+)$/ @config_file_name = $1 else @args << arg end end end end def default_config_file_name File.join(ENV['HOME'], '.gemrc') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubygems-update-0.8.6 | lib/rubygems/config_file.rb |
rubygems-update-0.8.5 | lib/rubygems/config_file.rb |