Class: BuildConfig
Constant Summary collapse
- @@app_config =
nil
- @@config =
nil
nil
Class Attribute Summary collapse
-
.app_config ⇒ Object
Returns the value of attribute app_config.
-
.config ⇒ Object
Returns the value of attribute config.
-
.shared_config ⇒ Object
Returns the value of attribute shared_config.
Class Method Summary collapse
- .find_elem(config, path, default = nil) ⇒ Object
- .get_key(key_path, default = nil) ⇒ Object
- .parse_path(path) ⇒ Object
Class Attribute Details
.app_config ⇒ Object
Returns the value of attribute app_config.
52 53 54 |
# File 'lib/build/BuildConfig.rb', line 52 def app_config @app_config end |
.config ⇒ Object
Returns the value of attribute config.
52 53 54 |
# File 'lib/build/BuildConfig.rb', line 52 def config @config end |
.shared_config ⇒ Object
Returns the value of attribute shared_config.
52 53 54 |
# File 'lib/build/BuildConfig.rb', line 52 def shared_config @shared_config end |
Class Method Details
.find_elem(config, path, default = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/build/BuildConfig.rb', line 12 def find_elem(config, path, default = nil) if path.kind_of?(String) loc_path = parse_path(path) else loc_path = path.dup end result = nil if !config.nil? result = config until result.nil? || loc_path.empty? section = loc_path.shift result = section.nil? ? nil : result[section] end end result.nil? ? default : result end |
.get_key(key_path, default = nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/build/BuildConfig.rb', line 32 def get_key(key_path, default = nil) if key_path.kind_of?(String) key_sections = parse_path(key_path) end result = nil [@@app_config, $app_config, @@config, $config, @@shared_config, $shared_config].compact.each do |config| unless config.nil? result = find_elem(config, key_sections, nil) break unless result.nil? end end puts "Could not get config #{key_path}" if result.nil? result.nil? ? default : result end |
.parse_path(path) ⇒ Object
8 9 10 |
# File 'lib/build/BuildConfig.rb', line 8 def parse_path(path) path.split('/').map{|c| c.strip}.reject { |c| c.empty? } end |