class ConfigTable

Constants

ALIASES

Attributes

config_opt[RW]
install_prefix[RW]
no_harm[W]
verbose[W]

Public Class Methods

new(rbconfig) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 49
def initialize(rbconfig)
  @rbconfig = rbconfig
  @items = []
  @table = {}
  # options
  @install_prefix = nil
  @config_opt = nil
  @verbose = true
  @no_harm = false
end

Public Instance Methods

[](key) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 75
def [](key)
  lookup(key).resolve(self)
end
[]=(key, val) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 79
def []=(key, val)
  lookup(key).set val
end
add(item) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 99
def add(item)
  @items.push item
  @table[item.name] = item
end
dllext() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 309
def dllext
  @rbconfig['DLEXT']
end
each(&block) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 87
def each(&block)
  @items.each(&block)
end
fixup() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 295
def fixup
  ALIASES.each do |ali, name|
    @table[ali] = @table[name]
  end
  @items.freeze
  @table.freeze
  @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/
end
key?(name) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 91
def key?(name)
  @table.key?(name)
end
load_multipackage_entries() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 260
def load_multipackage_entries
  multipackage_entries().each do |ent|
    add ent
  end
end
load_savefile() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 121
def load_savefile
  begin
    File.foreach(savefile()) do |line|
      k, v = *line.split(/=/, 2)
      self[k] = v.strip
    end
  rescue Errno::ENOENT
    setup_rb_error $!.message + "\n#{File.basename($0)} config first"
  end
end
load_script(path, inst = nil) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 111
def load_script(path, inst = nil)
  if File.file?(path)
    MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path
  end
end
load_standard_entries() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 141
def load_standard_entries
  standard_entries(@rbconfig).each do |ent|
    add ent
  end
end
lookup(name) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 95
def lookup(name)
  @table[name] or setup_rb_error "no such config item: #{name}"
end
names() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 83
def names
  @items.map {|i| i.name }
end
no_harm?() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 71
def no_harm?
  @no_harm
end
parse_opt(opt) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 304
def parse_opt(opt)
  m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}"
  m.to_a[1,2]
end
remove(name) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 104
def remove(name)
  item = lookup(name)
  @items.delete_if {|i| i.name == name }
  @table.delete_if {|name, i| i.name == name }
  item
end
save() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 132
def save
  @items.each {|i| i.value }
  File.open(savefile(), 'w') {|f|
    @items.each do |i|
      f.printf "%s=%s\n", i.name, i.value if i.value? and i.value
    end
  }
end
savefile() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 117
def savefile
  '.config'
end
value_config?(name) click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 313
def value_config?(name)
  lookup(name).value?
end
verbose?() click to toggle source
# File pkg/statsample-1.4.0/setup.rb, line 65
def verbose?
  @verbose
end