Class: Utils::Config::ConfigFile
- Inherits:
-
Object
- Object
- Utils::Config::ConfigFile
show all
- Includes:
- DSLKit::Interpreter
- Defined in:
- lib/utils/config/config_file.rb
Defined Under Namespace
Classes: BlockConfig, ConfigFileError, Discover, FileFinder, Probe, Search, StripSpaces
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ConfigFile.
9
10
|
# File 'lib/utils/config/config_file.rb', line 9
def initialize
end
|
Instance Method Details
#discover(&block) ⇒ Object
115
116
117
118
119
120
|
# File 'lib/utils/config/config_file.rb', line 115
def discover(&block)
if block
@discover = Discover.new(&block)
end
@discover ||= Discover.new
end
|
#parse(source) ⇒ Object
23
24
25
26
|
# File 'lib/utils/config/config_file.rb', line 23
def parse(source)
interpret_with_binding source, binding
self
end
|
#parse_config_file(config_file_name) ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/utils/config/config_file.rb', line 12
def parse_config_file(config_file_name)
File.open(config_file_name) do |cf|
parse cf.read
end
self
rescue SystemCallError => e
$DEBUG and warn "Couldn't read config file "\
"#{config_file_name.inspect}: #{e.class} #{e}"
return nil
end
|
#probe(&block) ⇒ Object
77
78
79
80
81
82
|
# File 'lib/utils/config/config_file.rb', line 77
def probe(&block)
if block
@probe = Probe.new(&block)
end
@probe ||= Probe.new
end
|
#search(&block) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/utils/config/config_file.rb', line 100
def search(&block)
if block
@search = Search.new(&block)
end
@search ||= Search.new
end
|
#strip_spaces(&block) ⇒ Object
128
129
130
131
132
133
|
# File 'lib/utils/config/config_file.rb', line 128
def strip_spaces(&block)
if block
@strip_spaces = StripSpaces.new(&block)
end
@strip_spaces ||= StripSpaces.new
end
|
135
136
137
138
139
140
141
|
# File 'lib/utils/config/config_file.rb', line 135
def to_ruby
result = "# vim: set ft=ruby:\n"
for bc in %w[search discover strip_spaces probe]
result << "\n" << __send__(bc).to_ruby
end
result
end
|