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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c14ecac3246987fee264fb6376876b98567fdf2
4
- data.tar.gz: ba0bc444c4b4e899bfbceffea570ab65d5bd9ce2
3
+ metadata.gz: c8af3f584ce0b6195aae0a48e4ca78dc9494c5d8
4
+ data.tar.gz: f4f95b02260107b3f19fc69bfa3aef3ca74a906e
5
5
  SHA512:
6
- metadata.gz: 2cea730b137cb0b01262d7f7dcb07becbd0656d3bc327bebb04bf865ac35fb179de1de4df27a0efc10652d1aa1580af2dbff847ad830b421636e8efe05edbb1e
7
- data.tar.gz: dfa5085ca8ab53dc0f9338326196b98cf9a05fead69ec6b49e20d5c3f4c5f26a0bb81c985f239a06517777cf77387e6258746e28e21487cc691d8960da8b0f3e
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
- thing = YAML.load_file(file)
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(thing, [], array_of_hashes_of_values_with_keys)
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
- # puts "#{line}"
21
-
22
- line_hash = YAML::load line
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
@@ -1,3 +1,3 @@
1
1
  module AnnotateYaml
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annotate_yaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pierre URBAN