Class: ZendConfigYaml
- Inherits:
-
Object
- Object
- ZendConfigYaml
- Defined in:
- lib/zendConfigYaml.rb
Class Method Summary collapse
-
.load(filePath, section) ⇒ Object
Loading/Parse yaml file and merge section.
Class Method Details
.load(filePath, section) ⇒ Object
Loading/Parse yaml file and merge section
Exemple:
>> yml = ZendConfigYaml.load('configs/application.yml')
Arguments:
filePath: (string) path to yaml file
section: (string) section name for get values
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/zendConfigYaml.rb', line 21 def self.load(filePath, section) # Load file and parsing yml = YAML.load(File.new(filePath, "r")) # Test if th section exist if yml.has_key?(section) == false raise "La section '#{section}' n'existe pas." end # Default value actualYml = yml[section] # Test if the extends key exist if yml[section].has_key?('_extends') actualYml = yml[yml[section]['_extends']].deep_merge(yml[section]) end return actualYml end |