Class Grit::Config
In: lib/grit/config.rb
Parent: Object

Methods

[]   []=   config_lines   data   fetch   keys   load_config   new  

Public Class methods

[Source]

# File lib/grit/config.rb, line 4
    def initialize(repo)
      @repo = repo
    end

Public Instance methods

[Source]

# File lib/grit/config.rb, line 13
    def [](key)
      data[key]
    end

[Source]

# File lib/grit/config.rb, line 8
    def []=(key, value)
      @repo.git.config({}, key, value)
      @data = nil
    end

[Source]

# File lib/grit/config.rb, line 17
    def fetch(key, default = nil)
      data[key] || default || raise(IndexError.new("key not found"))
    end

[Source]

# File lib/grit/config.rb, line 21
    def keys
      data.keys
    end

Protected Instance methods

[Source]

# File lib/grit/config.rb, line 39
      def config_lines
        @repo.git.config(:list => true).split(/\n/)
      end

[Source]

# File lib/grit/config.rb, line 26
      def data
        @data ||= load_config
      end

[Source]

# File lib/grit/config.rb, line 30
      def load_config
        hash = {}
        config_lines.map do |line|
          key, value = line.split(/=/, 2)
          hash[key] = value
        end
        hash
      end

[Validate]