Parent

Class Index [+]

Quicksearch

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  = load_config(local_config_file)
6:       @global_config = load_config(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 84
84:     def allow_sudo?
85:       !@local_config.key?(key_for(:path))
86:     end
delete(key) click to toggle source
    # File lib/bundler/settings.rb, line 18
18:     def delete(key)
19:       @local_config.delete(key_for(key))
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 73
73:     def path
74:       path = ENV[key_for(:path)] || @global_config[key_for(:path)]
75:       return path if path && !@local_config.key?(key_for(:path))
76: 
77:       if path = self[:path]
78:         "#{path}/#{Bundler.ruby_scope}"
79:       else
80:         Bundler.rubygems.gem_dir
81:       end
82:     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}: #{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 68
68:     def without
69:       self[:without] ? self[:without].split(":").map { |w| w.to_sym } : []
70:     end
without=(array) click to toggle source
    # File lib/bundler/settings.rb, line 64
64:     def without=(array)
65:       self[:without] = (array.empty? ? nil : array.join(":")) if array
66:     end

Private Instance Methods

global_config_file() click to toggle source
     # File lib/bundler/settings.rb, line 106
106:     def global_config_file
107:       file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config")
108:       Pathname.new(file)
109:     end
key_for(key) click to toggle source
    # File lib/bundler/settings.rb, line 89
89:     def key_for(key)
90:       key = key.to_s.sub(".", "__").upcase
91:       "BUNDLE_#{key}"
92:     end
load_config(config_file) click to toggle source
     # File lib/bundler/settings.rb, line 115
115:     def load_config(config_file)
116:       if config_file.exist? && !config_file.size.zero?
117:         yaml = YAML.load_file(config_file)
118:       end
119:       yaml || {}
120:     end
local_config_file() click to toggle source
     # File lib/bundler/settings.rb, line 111
111:     def local_config_file
112:       Pathname.new("#{@root}/config")
113:     end
set_key(key, value, hash, file) click to toggle source
     # File lib/bundler/settings.rb, line 94
 94:     def set_key(key, value, hash, file)
 95:       key = key_for(key)
 96: 
 97:       unless hash[key] == value
 98:         hash[key] = value
 99:         hash.delete(key) if value.nil?
100:         FileUtils.mkdir_p(file.dirname)
101:         File.open(file, "w") { |f| f.puts hash.to_yaml }
102:       end
103:       value
104:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.