annotate_yaml 0.0.1 → 0.0.2
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 +4 -4
- data/lib/annotate_yaml/annotate_yaml.rb +12 -7
- data/lib/annotate_yaml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8af3f584ce0b6195aae0a48e4ca78dc9494c5d8
|
4
|
+
data.tar.gz: f4f95b02260107b3f19fc69bfa3aef3ca74a906e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a0b8b542fd0725766f052941bc62e4bbf409a6f99baa86e62f97696ecb22dd517f334d2f3afd0cf62e5cd8d27f9f6a9b8721fa33898e8f8a45990e7e77e012f
|
7
|
+
data.tar.gz: 76eec6b450f0c03e306b54cf756fed05a438b4d3c41683a3647b16d18c71ba75281614f92161d257e8461296bd91f4189f2d28d7dafd2b487a588c8bffdba03b
|
@@ -6,10 +6,12 @@ module AnnotateYaml
|
|
6
6
|
|
7
7
|
files = Dir.glob("config/locales/*.yml")
|
8
8
|
files.each do |file|
|
9
|
-
|
9
|
+
complete_yaml_file = File.open(file).read
|
10
|
+
# Remove the references
|
11
|
+
complete_yaml_file_without_references = complete_yaml_file.gsub(/<<: \*.*/, '')
|
12
|
+
yaml_hash = YAML::load(complete_yaml_file_without_references)
|
10
13
|
array_of_hashes_of_values_with_keys = []
|
11
|
-
yaml_navigation(
|
12
|
-
# puts array_of_hashes_of_values_with_keys.inspect
|
14
|
+
yaml_navigation(yaml_hash, [], array_of_hashes_of_values_with_keys)
|
13
15
|
|
14
16
|
string_result = ''
|
15
17
|
|
@@ -17,9 +19,12 @@ module AnnotateYaml
|
|
17
19
|
text.gsub!(/\r\n?/, "\n")
|
18
20
|
current_hash = array_of_hashes_of_values_with_keys.shift
|
19
21
|
text.each_line do |line|
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
begin
|
23
|
+
line_hash = YAML::load line
|
24
|
+
rescue Exception => e
|
25
|
+
string_result += line
|
26
|
+
next
|
27
|
+
end
|
23
28
|
if line_hash === false
|
24
29
|
string_result += line
|
25
30
|
else
|
@@ -44,7 +49,7 @@ module AnnotateYaml
|
|
44
49
|
yaml_hash.each do |key, value|
|
45
50
|
keys_array_updated = keys_array_origin.dup
|
46
51
|
keys_array_updated.push(key)
|
47
|
-
result.push({ value => keys_array_updated.join('.') }) unless value.nil? || value.is_a?(Hash)
|
52
|
+
result.push({ value => keys_array_updated.join('.') }) unless value.nil? || value.is_a?(Hash) || value.is_a?(Array)
|
48
53
|
yaml_navigation value, keys_array_updated, result if value.is_a?(Hash)
|
49
54
|
end
|
50
55
|
end
|