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
113
114
115
116
117
118
|
# File 'lib/utils/config/config_file.rb', line 113
def discover(&block)
if block
@discover = Discover.new(&block)
end
@discover ||= Discover.new
end
|
#parse(source) ⇒ Object
22
23
24
25
|
# File 'lib/utils/config/config_file.rb', line 22
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
|
# 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}."
return nil
end
|
#probe(&block) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/utils/config/config_file.rb', line 75
def probe(&block)
if block
@probe = Probe.new(&block)
end
@probe ||= Probe.new
end
|
#search(&block) ⇒ Object
98
99
100
101
102
103
|
# File 'lib/utils/config/config_file.rb', line 98
def search(&block)
if block
@search = Search.new(&block)
end
@search ||= Search.new
end
|
#strip_spaces(&block) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/utils/config/config_file.rb', line 126
def strip_spaces(&block)
if block
@strip_spaces = StripSpaces.new(&block)
end
@strip_spaces ||= StripSpaces.new
end
|
133
134
135
136
137
138
139
|
# File 'lib/utils/config/config_file.rb', line 133
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
|