flattened_yml 0.0.5
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 +15 -0
- data/lib/flattened_yml.rb +37 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
!binary "U0hBMQ==":
|
|
3
|
+
metadata.gz: !binary |-
|
|
4
|
+
N2Y2NTYwYTZlMjFlNzQ4M2NhZTc0MWUxNWJkMTFjODE2YjcwNDMzZQ==
|
|
5
|
+
data.tar.gz: !binary |-
|
|
6
|
+
NGFhMmIzNDEwNWQ5ZmQ5ODNkZGY4ZjNlNGMzZDQ3NWFhNGYwZjE5Ng==
|
|
7
|
+
!binary "U0hBNTEy":
|
|
8
|
+
metadata.gz: !binary |-
|
|
9
|
+
MDBlNzE2ODY0MmYzNzFlMmYyMWM2NDIyNTQ3ZjJkMjFmOGY1Mjg2NzExM2Zh
|
|
10
|
+
ZDEwZjJjZWIxZDE0NWMyMmI5MDM0Mjk5OTEzMDM3ZWRiY2E3YTU5NmU4ZjM3
|
|
11
|
+
YjM1MmRhZWQwNmUwZTAwYzc4MTVkZmMwYWIyMTk5NmU5ZTQ2Mjg=
|
|
12
|
+
data.tar.gz: !binary |-
|
|
13
|
+
ZWQ2MjU0NTJjZWMxZmNlN2ZiMTBjMTZjMTU4N2ViYzA3NTU3NmZiZjcyY2Fi
|
|
14
|
+
YzE3NzRlZjUzNTgyZmQyNDVjYWVkNTU5YmI2N2JhMGI4NDk1MmNiZGQzMWVj
|
|
15
|
+
YjNiNzVjZWE4YzI5YjIyMDljMmU5N2NlZGM3YTM1NjNlYjNkODA=
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module ProcHash
|
|
2
|
+
def self.process_hash(translations, current_key, hash)
|
|
3
|
+
hash.each do |new_key, value|
|
|
4
|
+
combined_key = [current_key, new_key].delete_if { |k| k == '' }.join(".")
|
|
5
|
+
if value.is_a?(Hash)
|
|
6
|
+
process_hash(translations, combined_key, value)
|
|
7
|
+
else
|
|
8
|
+
translations[combined_key] = value
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def flattened_version_of_yml file=nil, root=nil
|
|
16
|
+
target_file = nil
|
|
17
|
+
if !file.nil?
|
|
18
|
+
target_file = file
|
|
19
|
+
else
|
|
20
|
+
raise 'Unable to load target file!'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
include ProcHash
|
|
24
|
+
require 'yaml'
|
|
25
|
+
|
|
26
|
+
yml_version = YAML::load(IO.read(target_file))
|
|
27
|
+
# p yml_version[locale]
|
|
28
|
+
|
|
29
|
+
if root.nil?
|
|
30
|
+
root = yml_version.keys.first
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
flattend_version = {}
|
|
34
|
+
ProcHash.process_hash(flattend_version, '', yml_version[root])
|
|
35
|
+
flattend_version
|
|
36
|
+
end
|
|
37
|
+
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: flattened_yml
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.5
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mahmoud Gamal
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Flatten yml to a flattened key-value hash
|
|
14
|
+
email:
|
|
15
|
+
- mhmoudgmal.89@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/flattened_yml.rb
|
|
21
|
+
homepage:
|
|
22
|
+
licenses: []
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.0.3
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Flatten yml to a flattened key-value hash
|
|
44
|
+
test_files: []
|