Class: ConfigTable
Defined Under Namespace
Classes: BoolItem, ExecItem, Item, MetaConfigEnvironment, PackageSelectionItem, PathItem, ProgramItem, SelectItem
Constant Summary
collapse
- ALIASES =
{
'std-ruby' => 'librubyver',
'stdruby' => 'librubyver',
'rubylibdir' => 'librubyver',
'archdir' => 'librubyverarch',
'site-ruby-common' => 'siteruby', 'site-ruby' => 'siterubyver', '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'
}
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(rbconfig) ⇒ ConfigTable
Returns a new instance of ConfigTable.
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/vendor/xmpp4r/setup.rb', line 50
def initialize(rbconfig)
@rbconfig = rbconfig
@items = []
@table = {}
@install_prefix = nil
@config_opt = nil
@verbose = true
@no_harm = false
end
|
Instance Attribute Details
#config_opt ⇒ Object
Returns the value of attribute config_opt.
62
63
64
|
# File 'lib/vendor/xmpp4r/setup.rb', line 62
def config_opt
@config_opt
end
|
#install_prefix ⇒ Object
Returns the value of attribute install_prefix.
61
62
63
|
# File 'lib/vendor/xmpp4r/setup.rb', line 61
def install_prefix
@install_prefix
end
|
#no_harm=(value) ⇒ Object
Sets the attribute no_harm
70
71
72
|
# File 'lib/vendor/xmpp4r/setup.rb', line 70
def no_harm=(value)
@no_harm = value
end
|
#verbose=(value) ⇒ Object
Sets the attribute verbose
64
65
66
|
# File 'lib/vendor/xmpp4r/setup.rb', line 64
def verbose=(value)
@verbose = value
end
|
Instance Method Details
#[](key) ⇒ Object
76
77
78
|
# File 'lib/vendor/xmpp4r/setup.rb', line 76
def [](key)
lookup(key).resolve(self)
end
|
#[]=(key, val) ⇒ Object
80
81
82
|
# File 'lib/vendor/xmpp4r/setup.rb', line 80
def []=(key, val)
lookup(key).set val
end
|
#add(item) ⇒ Object
100
101
102
103
|
# File 'lib/vendor/xmpp4r/setup.rb', line 100
def add(item)
@items.push item
@table[item.name] = item
end
|
#dllext ⇒ Object
310
311
312
|
# File 'lib/vendor/xmpp4r/setup.rb', line 310
def dllext
@rbconfig['DLEXT']
end
|
#each(&block) ⇒ Object
88
89
90
|
# File 'lib/vendor/xmpp4r/setup.rb', line 88
def each(&block)
@items.each(&block)
end
|
#fixup ⇒ Object
296
297
298
299
300
301
302
303
|
# File 'lib/vendor/xmpp4r/setup.rb', line 296
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) ⇒ Boolean
92
93
94
|
# File 'lib/vendor/xmpp4r/setup.rb', line 92
def key?(name)
@table.key?(name)
end
|
#load_multipackage_entries ⇒ Object
261
262
263
264
265
|
# File 'lib/vendor/xmpp4r/setup.rb', line 261
def load_multipackage_entries
multipackage_entries().each do |ent|
add ent
end
end
|
#load_savefile ⇒ Object
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/vendor/xmpp4r/setup.rb', line 122
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) ⇒ Object
112
113
114
115
116
|
# File 'lib/vendor/xmpp4r/setup.rb', line 112
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 ⇒ Object
142
143
144
145
146
|
# File 'lib/vendor/xmpp4r/setup.rb', line 142
def load_standard_entries
standard_entries(@rbconfig).each do |ent|
add ent
end
end
|
#lookup(name) ⇒ Object
96
97
98
|
# File 'lib/vendor/xmpp4r/setup.rb', line 96
def lookup(name)
@table[name] or setup_rb_error "no such config item: #{name}"
end
|
#names ⇒ Object
84
85
86
|
# File 'lib/vendor/xmpp4r/setup.rb', line 84
def names
@items.map {|i| i.name }
end
|
#no_harm? ⇒ Boolean
72
73
74
|
# File 'lib/vendor/xmpp4r/setup.rb', line 72
def no_harm?
@no_harm
end
|
#parse_opt(opt) ⇒ Object
305
306
307
308
|
# File 'lib/vendor/xmpp4r/setup.rb', line 305
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) ⇒ Object
105
106
107
108
109
110
|
# File 'lib/vendor/xmpp4r/setup.rb', line 105
def remove(name)
item = lookup(name)
@items.delete_if {|i| i.name == name }
@table.delete_if {|name, i| i.name == name }
item
end
|
#save ⇒ Object
133
134
135
136
137
138
139
140
|
# File 'lib/vendor/xmpp4r/setup.rb', line 133
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 ⇒ Object
118
119
120
|
# File 'lib/vendor/xmpp4r/setup.rb', line 118
def savefile
'.config'
end
|
#value_config?(name) ⇒ Boolean
314
315
316
|
# File 'lib/vendor/xmpp4r/setup.rb', line 314
def value_config?(name)
lookup(name).value?
end
|
#verbose? ⇒ Boolean
66
67
68
|
# File 'lib/vendor/xmpp4r/setup.rb', line 66
def verbose?
@verbose
end
|