Module: MGit::Configuration

Extended by:
Enumerable
Defined in:
lib/mgit/configuration.rb

Constant Summary collapse

KEYS =
{
  :threads => {
    :default => true,
    :description => 'set to true if you want the fetch command to be threaded'
  },

  :plugindir => {
    :default => File.join(AppData::AppDataVersion.latest.send(:config_dir), 'plugins'),
    :description => 'directory from where plugin commands are loaded'
  },

  :colors => {
    :default => true,
    :description => 'set to false to disable all colored output'
  }
}

Class Method Summary collapse

Class Method Details

.eachObject



50
51
52
53
54
# File 'lib/mgit/configuration.rb', line 50

def self.each
  KEYS.each do |key|
    yield [key.first.to_s, self.send(key.first).to_s]
  end
end

.method_missing(meth, *args, &block) ⇒ Object

Raises:



56
57
58
# File 'lib/mgit/configuration.rb', line 56

def self.method_missing(meth, *args, &block)
  raise ConfigurationError.new("Unknown key: #{key}")
end

.set(key, value) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mgit/configuration.rb', line 36

def self.set(key, value)
  case key
  when 'threads', 'colors'
    set_boolean(key, value)
  when 'plugindir'
    if !File.directory?(value)
      raise ConfigurationError.new("Illegal value for key plugindir. Has to be a directory.")
    end
    self.plugindir = File.expand_path(value)
  else
    raise ConfigurationError.new("Unknown key: #{key}.")
  end
end