zendConfigYaml 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/zendConfigYaml.rb +43 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2091be1f1bde8803777e5578c6e24b37265614f7
|
4
|
+
data.tar.gz: 0325da578ed3c9addfd397ab938501eab40f93a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 349054f04e1f82885d543d302343838bb68709a0e60298ccc5207ac4f1829b828f09c41d35b8817b440c416ab80f3c0606af63e20c9a064b38cb1645709bce15
|
7
|
+
data.tar.gz: 16053620c627a821ac49cd379a6c068df6cad3dc76904d7db7a6951f4513f7f189d07de2aa4e8465321ee914c0b73197346efe5f72e03e97b21de848fd4d76ab
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
# Add a recusive merge
|
4
|
+
class ::Hash
|
5
|
+
def deep_merge(second)
|
6
|
+
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
7
|
+
self.merge(second, &merger)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class ZendConfigYaml
|
12
|
+
|
13
|
+
# Loading/Parse yaml file and merge section
|
14
|
+
#
|
15
|
+
# Exemple:
|
16
|
+
# >> yml = ZendConfigYaml.load('configs/application.yml')
|
17
|
+
#
|
18
|
+
# Arguments:
|
19
|
+
# filePath: (string) path to yaml file
|
20
|
+
# section: (string) section name for get values
|
21
|
+
def self.load(filePath, section)
|
22
|
+
|
23
|
+
# Load file and parsing
|
24
|
+
yml = YAML.load(File.new(filePath, "r"))
|
25
|
+
|
26
|
+
# Test if th section exist
|
27
|
+
if yml.has_key?(section) == false
|
28
|
+
raise "La section '#{section}' n'existe pas."
|
29
|
+
end
|
30
|
+
|
31
|
+
# Default value
|
32
|
+
actualYml = yml[section]
|
33
|
+
|
34
|
+
# Test if the extends key exist
|
35
|
+
if yml[section].has_key?('_extends')
|
36
|
+
actualYml = yml[yml[section]['_extends']].deep_merge(yml[section])
|
37
|
+
end
|
38
|
+
|
39
|
+
return actualYml
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zendConfigYaml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bastien Donjon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple parser for yaml application zend framework file
|
14
|
+
email: contact@bastien-donjon.fr
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/zendConfigYaml.rb
|
20
|
+
homepage: http://rubygems.org/gems/zendConfigYaml
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.0.3
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: zendConfigYaml
|
43
|
+
test_files: []
|