Sha256: fe3c5cc3e956e37f7c1f2fecc0317b590ffd98ee9615e57e5d37a824fbc52862

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

module Bundler
  class Settings
    def initialize(root)
      @root   = root
      @config = File.exist?(config_file) ? YAML.load_file(config_file) : {}
    end

    def [](key)
      key = "BUNDLE_#{key.to_s.upcase}"
      @config[key] || ENV[key]
    end

    def []=(key, value)
      key = "BUNDLE_#{key.to_s.upcase}"
      unless @config[key] == value
        @config[key] = value
        FileUtils.mkdir_p(config_file.dirname)
        File.open(config_file, 'w') do |f|
          f.puts @config.to_yaml
        end
      end
      value
    end

    def without=(array)
      unless array.empty? && without.empty?
        self[:without] = array.join(":")
      end
    end

    def without
      self[:without] ? self[:without].split(":").map { |w| w.to_sym } : []
    end

  private

    def config_file
      Pathname.new("#{@root}/.bundle/config")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bundler-1.0.0.beta.2 lib/bundler/settings.rb
bundler-1.0.0.beta.1 lib/bundler/settings.rb