module MGit::Configuration

Constants

KEYS

Public Class Methods

each() { |first.to_s, send(first).to_s| ... } click to toggle source
# File lib/mgit/configuration.rb, line 55
def self.each
  KEYS.each do |key|
    yield [key.first.to_s, send(key.first).to_s]
  end
end
method_missing(meth, *) click to toggle source
# File lib/mgit/configuration.rb, line 61
def self.method_missing(meth, *)
  fail ConfigurationError, "Unknown key: #{meth}"
end
set(key, value) click to toggle source
# File lib/mgit/configuration.rb, line 41
def self.set(key, value)
  case key
  when 'threads', 'colors'
    set_boolean(key, value)
  when 'plugindir'
    unless File.directory?(value)
      fail ConfigurationError, 'Illegal value for key plugindir. Has to be a directory.'
    end
    self.plugindir = File.expand_path(value)
  else
    fail ConfigurationError, "Unknown key: #{key}."
  end
end

Private Class Methods

set_boolean(key, value) click to toggle source
# File lib/mgit/configuration.rb, line 67
def self.set_boolean(key, value)
  unless %w( true, false, on, off ).include?(value)
    fail ConfigurationError, "Illegal value for key #{key}."
  end

  if %w( true, on ).include?(value)
    send("#{key}=", true)
  else
    send("#{key}=", false)
  end
end