Class: Utils::ConfigFile
- Inherits:
-
Object
show all
- Includes:
- DSLKit::Interpreter
- Defined in:
- lib/utils/config_file.rb
Defined Under Namespace
Classes: BlockConfig, Classify, ConfigFileError, Discover, Edit, FileFinder, Probe, Scope, Search, SshTunnel, StripSpaces, SyncDir
Class Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ConfigFile.
18
19
|
# File 'lib/utils/config_file.rb', line 18
def initialize
end
|
Class Attribute Details
.config_file_paths ⇒ Object
Returns the value of attribute config_file_paths.
6
7
8
|
# File 'lib/utils/config_file.rb', line 6
def config_file_paths
@config_file_paths
end
|
Instance Method Details
#classify(&block) ⇒ Object
278
279
280
281
282
283
|
# File 'lib/utils/config_file.rb', line 278
def classify(&block)
if block
@classify = Classify.new(&block)
end
@classify ||= Classify.new
end
|
21
22
23
24
25
|
# File 'lib/utils/config_file.rb', line 21
def configure_from_paths(paths = self.class.config_file_paths)
for config_file_path in paths
parse_config_file config_file_path
end
end
|
#discover(&block) ⇒ Object
142
143
144
145
146
147
|
# File 'lib/utils/config_file.rb', line 142
def discover(&block)
if block
@discover = Discover.new(&block)
end
@discover ||= Discover.new
end
|
#edit(&block) ⇒ Object
265
266
267
268
269
270
|
# File 'lib/utils/config_file.rb', line 265
def edit(&block)
if block
@edit = Edit.new(&block)
end
@edit ||= Edit.new
end
|
#parse(source) ⇒ Object
39
40
41
42
|
# File 'lib/utils/config_file.rb', line 39
def parse(source)
interpret_with_binding source, binding
self
end
|
#parse_config_file(config_file_path) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/utils/config_file.rb', line 27
def parse_config_file(config_file_path)
config_file_path = File.expand_path(config_file_path)
File.open(config_file_path) do |cf|
parse cf.read
end
self
rescue SystemCallError => e
$DEBUG and warn "Couldn't read config file "\
"#{config_file_path.inspect}: #{e.class} #{e}"
return nil
end
|
#probe(&block) ⇒ Object
100
101
102
103
104
105
|
# File 'lib/utils/config_file.rb', line 100
def probe(&block)
if block
@probe = Probe.new(&block)
end
@probe ||= Probe.new
end
|
#scope(&block) ⇒ Object
157
158
159
160
161
162
|
# File 'lib/utils/config_file.rb', line 157
def scope(&block)
if block
@scope = Scope.new(&block)
end
@scope ||= Scope.new
end
|
#search(&block) ⇒ Object
123
124
125
126
127
128
|
# File 'lib/utils/config_file.rb', line 123
def search(&block)
if block
@search = Search.new(&block)
end
@search ||= Search.new
end
|
#ssh_tunnel(&block) ⇒ Object
252
253
254
255
256
257
|
# File 'lib/utils/config_file.rb', line 252
def ssh_tunnel(&block)
if block
@ssh_tunnel = SshTunnel.new(&block)
end
@ssh_tunnel ||= SshTunnel.new
end
|
#strip_spaces(&block) ⇒ Object
170
171
172
173
174
175
|
# File 'lib/utils/config_file.rb', line 170
def strip_spaces(&block)
if block
@strip_spaces = StripSpaces.new(&block)
end
@strip_spaces ||= StripSpaces.new
end
|
#sync_dir(&block) ⇒ Object
293
294
295
296
297
298
|
# File 'lib/utils/config_file.rb', line 293
def sync_dir(&block)
if block
@sync_dir = SyncDir.new(&block)
end
@sync_dir ||= SyncDir.new
end
|
300
301
302
303
304
305
306
|
# File 'lib/utils/config_file.rb', line 300
def to_ruby
result = "# vim: set ft=ruby:\n"
for bc in %w[search discover strip_spaces probe ssh_tunnel edit classify]
result << "\n" << __send__(bc).to_ruby
end
result
end
|