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 lib/rbt/yaml/individual_cookbooks/setup.rb, line 42 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 lib/rbt/yaml/individual_cookbooks/setup.rb, line 74 def [](key) lookup(key).resolve(self) end
[]=(key, val)
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 78 def []=(key, val) lookup(key).set val end
add(item)
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 101 def add(item) @items.push item @table[item.name] = item end
dllext()
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 331 def dllext @rbconfig['DLEXT'] end
each(&block)
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 89 def each(&block) @items.each(&block) end
fixup()
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 317 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 lib/rbt/yaml/individual_cookbooks/setup.rb, line 93 def key?(name) @table.key?(name) end
load_multipackage_entries()
click to toggle source
load_savefile()
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 132 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
load_standard_entries()
click to toggle source
lookup(name)
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 97 def lookup(name) @table[name] or setup_rb_error "no such config item: #{name}" end
names()
click to toggle source
no_harm?()
click to toggle source
parse_opt(opt)
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 326 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
save()
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 143 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
value_config?(name)
click to toggle source
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 335 def value_config?(name) lookup(name).value? end
Private Instance Methods
multipackage_entries()
click to toggle source
#¶ ↑
multipackage_entries
¶ ↑
#¶ ↑
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 289 def multipackage_entries [ PackageSelectionItem.new('with', 'name,name...', '', 'ALL', 'package names that you want to install'), PackageSelectionItem.new('without', 'name,name...', '', 'NONE', 'package names that you do not want to install') ] end
standard_entries(rbconfig)
click to toggle source
#¶ ↑
standard_entries
¶ ↑
#¶ ↑
# File lib/rbt/yaml/individual_cookbooks/setup.rb, line 164 def standard_entries(rbconfig) c = rbconfig rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) major = c['MAJOR'].to_i minor = c['MINOR'].to_i teeny = c['TEENY'].to_i version = "#{major}.#{minor}" # ruby ver. >= 1.4.4? newpath_p = ((major >= 2) or ((major == 1) and ((minor >= 5) or ((minor == 4) and (teeny >= 4))))) if c['rubylibdir'] # V > 1.6.3 libruby = "#{c['prefix']}/lib/ruby" librubyver = c['rubylibdir'] librubyverarch = c['archdir'] siteruby = c['sitedir'] siterubyver = c['sitelibdir'] siterubyverarch = c['sitearchdir'] elsif newpath_p # 1.4.4 <= V <= 1.6.3 libruby = "#{c['prefix']}/lib/ruby" librubyver = "#{c['prefix']}/lib/ruby/#{version}" librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" siteruby = c['sitedir'] siterubyver = "$siteruby/#{version}" siterubyverarch = "$siterubyver/#{c['arch']}" else # V < 1.4.4 libruby = "#{c['prefix']}/lib/ruby" librubyver = "#{c['prefix']}/lib/ruby/#{version}" librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" siterubyver = siteruby siterubyverarch = "$siterubyver/#{c['arch']}" end parameterize = lambda {|path| path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') } if arg = c['configure_args'].split.detect {|inner_arg| /--with-make-prog=/ =~ inner_arg } makeprog = arg.sub(/'/, '').split(/=/, 2)[1] else makeprog = 'make' end [ ExecItem.new('installdirs', 'std/site/home', 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ {|val, table| case val when 'std' table['rbdir'] = '$librubyver' table['sodir'] = '$librubyverarch' when 'site' table['rbdir'] = '$siterubyver' table['sodir'] = '$siterubyverarch' when 'home' setup_rb_error '$HOME was not set' unless ENV['HOME'] table['prefix'] = ENV['HOME'] table['rbdir'] = '$libdir/ruby' table['sodir'] = '$libdir/ruby' end }, PathItem.new('prefix', 'path', c['prefix'], 'path prefix of target environment'), PathItem.new('bindir', 'path', parameterize.call(c['bindir']), 'the directory for commands'), PathItem.new('libdir', 'path', parameterize.call(c['libdir']), 'the directory for libraries'), PathItem.new('datadir', 'path', parameterize.call(c['datadir']), 'the directory for shared data'), PathItem.new('mandir', 'path', parameterize.call(c['mandir']), 'the directory for man pages'), PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), 'the directory for system configuration files'), PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), 'the directory for local state data'), PathItem.new('libruby', 'path', libruby, 'the directory for ruby libraries'), PathItem.new('librubyver', 'path', librubyver, 'the directory for standard ruby libraries'), PathItem.new('librubyverarch', 'path', librubyverarch, 'the directory for standard ruby extensions'), PathItem.new('siteruby', 'path', siteruby, 'the directory for version-independent aux ruby libraries'), PathItem.new('siterubyver', 'path', siterubyver, 'the directory for aux ruby libraries'), PathItem.new('siterubyverarch', 'path', siterubyverarch, 'the directory for aux ruby binaries'), PathItem.new('rbdir', 'path', '$siterubyver', 'the directory for ruby scripts'), PathItem.new('sodir', 'path', '$siterubyverarch', 'the directory for ruby extentions'), PathItem.new('rubypath', 'path', rubypath, 'the path to set to #! line'), ProgramItem.new('rubyprog', 'name', rubypath, 'the ruby program using for installation'), ProgramItem.new('makeprog', 'name', makeprog, 'the make program to compile ruby extentions'), SelectItem.new('shebang', 'all/ruby/never', 'ruby', 'shebang line (#!) editing mode'), BoolItem.new('without-ext', 'yes/no', 'no', 'does not compile/install ruby extentions') ] end