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
4:     def initialize(repo)
5:       @repo = repo
6:     end

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Source]

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

Protected Instance methods

[Source]

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

[Source]

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

[Source]

    # File lib/grit/config.rb, line 30
30:       def load_config
31:         hash = {}
32:         config_lines.map do |line|
33:           key, value = line.split(/=/, 2)
34:           hash[key] = value
35:         end
36:         hash
37:       end

[Validate]