Class: RBT::Configuration::SimpleConfigurationLoader
- Inherits:
-
Object
- Object
- RBT::Configuration::SimpleConfigurationLoader
show all
- Defined in:
- lib/rbt/configuration/simple_configuration_loader.rb
Overview
RBT::Configuration::SimpleConfigurationLoader
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
38
39
40
41
42
43
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 38
def initialize(
run_already = true
)
reset
run if run_already
end
|
Class Method Details
.[](i = '') ⇒ Object
#
RBT::SimpleConfigurationLoader[]
#
204
205
206
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 204
def self.[](i = '')
new(i)
end
|
.return_value_of_this_configuration_value(i) ⇒ Object
#
RBT::SimpleConfigurationLoader.return_value_of_this_configuration_value
This method could be used to quickly return the value of a particular configuration value, if you know the name of its associated yaml file.
Invocation example:
x = RBT::Configuration::SimpleConfigurationLoader.return_value_of_this_configuration_value('use_abbreviations')
#
220
221
222
223
224
225
226
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 220
def self.return_value_of_this_configuration_value(i)
i = i.to_sym unless i.is_a? Symbol
result = nil
_ = RBT::Configuration::SimpleConfigurationLoader.new
result = _.send(i)
return result
end
|
Instance Method Details
#array_available_methods? ⇒ Boolean
Also known as:
hash?, _, _?, available_methods?
#
array_available_methods?
#
61
62
63
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 61
def array_available_methods?
@array_available_methods
end
|
#do_save(these_files = @yaml_files) ⇒ Object
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 167
def do_save(
these_files = @yaml_files
)
sorted = these_files.sort
sorted.each {|this_yaml_file|
method_name = File.basename(this_yaml_file).sub(/\.yml$/,'')
new_value = send(method_name)
::RBT.write_what_into(new_value, this_yaml_file)
if ::RBT.is_on_roebe?
into = ::RBT::RUBY_SRC_DIR_RBT_YAML+'configuration/'+
File.basename(this_yaml_file)
::RBT.write_what_into(new_value, into)
end
}
end
|
#iterate_over_the_yaml_files ⇒ Object
#
iterate_over_the_yaml_files
#
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 83
def iterate_over_the_yaml_files
_ = @yaml_files.sort
unless _.empty?
_.each {|this_yaml_file|
data = YAML.load_file(this_yaml_file)
name_of_the_method_that_is_to_be_defined = File.basename(
this_yaml_file.sub(/\.yml$/,'') ).to_sym
@array_available_methods << name_of_the_method_that_is_to_be_defined
if data.is_a? String
if data.include? '$'
data = RBT.convert_global_env(data).dup
if File.directory?(data) and !data.end_with?('/')
data << '/' end
end
case data
when 'f'
data = false
when 't'
data = true
end
end
this_method_setter = (
"#{name_of_the_method_that_is_to_be_defined}="
).to_sym
unless @array_available_methods.include? this_method_setter
@array_available_methods << this_method_setter
end
self.class.class_eval {
instance_variable_set(
('@'+name_of_the_method_that_is_to_be_defined.to_s).to_sym, data
)
define_method(name_of_the_method_that_is_to_be_defined.to_sym) {
self.class.class_eval {
instance_variable_get(('@'+name_of_the_method_that_is_to_be_defined.to_s).to_sym)
}
}
define_method(this_method_setter) {|input_argument|
self.class.class_eval {
instance_variable_set(
('@'+name_of_the_method_that_is_to_be_defined.to_s).to_sym,
input_argument
)
}
}
}
}
end
end
|
#obtain_all_available_yaml_files(from_this_dir = ::RBT.rbt_configuration_directory?) ⇒ Object
#
obtain_all_available_yaml_files
This method will fetch every available .yml file that is part of the “configuration system” for the RBT.
#
74
75
76
77
78
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 74
def obtain_all_available_yaml_files(
from_this_dir = ::RBT.rbt_configuration_directory?
)
@yaml_files = Dir["#{from_this_dir}*.yml"]
end
|
#reset ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 48
def reset
@array_available_methods = []
end
|
#run ⇒ Object
196
197
198
199
|
# File 'lib/rbt/configuration/simple_configuration_loader.rb', line 196
def run
obtain_all_available_yaml_files
iterate_over_the_yaml_files
end
|