Class ConfigTable
In: lib/mime-types-1.16/setup.rb
Parent: Object

Methods

Included Modules

Enumerable

Classes and Modules

Class ConfigTable::BoolItem
Class ConfigTable::ExecItem
Class ConfigTable::Item
Class ConfigTable::MetaConfigEnvironment
Class ConfigTable::PackageSelectionItem
Class ConfigTable::PathItem
Class ConfigTable::ProgramItem
Class ConfigTable::SelectItem

Constants

ALIASES = { 'std-ruby' => 'librubyver', 'stdruby' => 'librubyver', 'rubylibdir' => 'librubyver', 'archdir' => 'librubyverarch', 'site-ruby-common' => 'siteruby', # For backward compatibility 'site-ruby' => 'siterubyver', # For backward compatibility 'bin-dir' => 'bindir', 'bin-dir' => 'bindir', 'rb-dir' => 'rbdir', 'so-dir' => 'sodir', 'data-dir' => 'datadir', 'ruby-path' => 'rubypath', 'ruby-prog' => 'rubyprog', 'ruby' => 'rubyprog', 'make-prog' => 'makeprog', 'make' => 'makeprog'

Attributes

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

Public Class methods

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/setup.rb, line 75
  def [](key)
    lookup(key).resolve(self)
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 79
  def []=(key, val)
    lookup(key).set val
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 99
  def add(item)
    @items.push item
    @table[item.name] = item
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 309
  def dllext
    @rbconfig['DLEXT']
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 87
  def each(&block)
    @items.each(&block)
  end

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/setup.rb, line 91
  def key?(name)
    @table.key?(name)
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 260
  def load_multipackage_entries
    multipackage_entries().each do |ent|
      add ent
    end
  end

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/setup.rb, line 141
  def load_standard_entries
    standard_entries(@rbconfig).each do |ent|
      add ent
    end
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 95
  def lookup(name)
    @table[name] or setup_rb_error "no such config item: #{name}"
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 83
  def names
    @items.map {|i| i.name }
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 71
  def no_harm?
    @no_harm
  end

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/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

[Source]

# File lib/mime-types-1.16/setup.rb, line 117
  def savefile
    '.config'
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 313
  def value_config?(name)
    lookup(name).value?
  end

[Source]

# File lib/mime-types-1.16/setup.rb, line 65
  def verbose?
    @verbose
  end

[Validate]