Parent

Bundler::Settings

Public Class Methods

new(root) click to toggle source
   # File lib/bundler/settings.rb, line 3
3:     def initialize(root)
4:       @root   = root
5:       @local_config = File.exist?(local_config_file) ? YAML.load_file(local_config_file) : {}
6:       @global_config = File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
7:     end

Public Instance Methods

[](key) click to toggle source
    # File lib/bundler/settings.rb, line 9
 9:     def [](key)
10:       key = key_for(key)
11:       @local_config[key] || ENV[key] || @global_config[key]
12:     end
[]=(key, value) click to toggle source
    # File lib/bundler/settings.rb, line 14
14:     def []=(key, value)
15:       set_key(key, value, @local_config, local_config_file)
16:     end
all() click to toggle source
    # File lib/bundler/settings.rb, line 26
26:     def all
27:       env_keys = ENV.keys.select { |k| k =~ /BUNDLE_.*/ }
28:       keys = @global_config.keys | @local_config.keys | env_keys
29: 
30:       keys.map do |key|
31:         key.sub(/^BUNDLE_/, '').gsub(/__/, ".").downcase
32:       end
33:     end
allow_sudo?() click to toggle source
    # File lib/bundler/settings.rb, line 86
86:     def allow_sudo?
87:       !@local_config.key?(key_for(:path))
88:     end
delete(key) click to toggle source
    # File lib/bundler/settings.rb, line 18
18:     def delete(key)
19:       @local_config
20:     end
locations(key) click to toggle source
    # File lib/bundler/settings.rb, line 35
35:     def locations(key)
36:       locations = {}
37: 
38:       locations[:local]  = @local_config[key] if @local_config.key?(key)
39:       locations[:env]    = ENV[key] if ENV[key]
40:       locations[:global] = @global_config[key] if @global_config.key?(key)
41:       locations
42:     end
path() click to toggle source

@local_config[“BUNDLE_PATH“] should be prioritized over ENV[“BUNDLE_PATH“]

    # File lib/bundler/settings.rb, line 75
75:     def path
76:       path = ENV[key_for(:path)] || @global_config[key_for(:path)]
77:       return path if path && !@local_config.key?(key_for(:path))
78: 
79:       if path = self[:path]
80:         "#{path}/#{Bundler.ruby_scope}"
81:       else
82:         Gem.dir
83:       end
84:     end
pretty_values_for(exposed_key) click to toggle source
    # File lib/bundler/settings.rb, line 44
44:     def pretty_values_for(exposed_key)
45:       key = key_for(exposed_key)
46: 
47:       locations = []
48:       if @local_config.key?(key)
49:         locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
50:       end
51: 
52:       if value = ENV[key]
53:         locations << "Set via $#{key_for(key)}: #{value.inspect}"
54:       end
55: 
56:       if @global_config.key?(key)
57:         locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
58:       end
59: 
60:       return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
61:       locations
62:     end
set_global(key, value) click to toggle source
    # File lib/bundler/settings.rb, line 22
22:     def set_global(key, value)
23:       set_key(key, value, @global_config, global_config_file)
24:     end
without() click to toggle source
    # File lib/bundler/settings.rb, line 70
70:     def without
71:       self[:without] ? self[:without].split(":").map { |w| w.to_sym } : []
72:     end
without=(array) click to toggle source
    # File lib/bundler/settings.rb, line 64
64:     def without=(array)
65:       unless array.empty? && without.empty?
66:         self[:without] = array.join(":")
67:       end
68:     end

Private Instance Methods

global_config_file() click to toggle source
     # File lib/bundler/settings.rb, line 108
108:     def global_config_file
109:       file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config")
110:       Pathname.new(file)
111:     end
key_for(key) click to toggle source
    # File lib/bundler/settings.rb, line 91
91:     def key_for(key)
92:       key = key.to_s.sub(".", "__").upcase
93:       "BUNDLE_#{key}"
94:     end
local_config_file() click to toggle source
     # File lib/bundler/settings.rb, line 113
113:     def local_config_file
114:       Pathname.new("#{@root}/config")
115:     end
set_key(key, value, hash, file) click to toggle source
     # File lib/bundler/settings.rb, line 96
 96:     def set_key(key, value, hash, file)
 97:       key = key_for(key)
 98: 
 99:       unless hash[key] == value
100:         hash[key] = value
101:         hash.delete(key) if value.nil?
102:         FileUtils.mkdir_p(file.dirname)
103:         File.open(file, "w") { |f| f.puts hash.to_yaml }
104:       end
105:       value
106:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.