i18n-tasks 0.9.11 → 0.9.12
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8fdd3b0e7a3f582d6ebf37b2fa35117f626ce72
|
4
|
+
data.tar.gz: 2e487915be57d0b7392bba89bb666a28fd143d23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 445084513fabeddd582963ed14d6fbb8345f45781c294b7d20bd97aeb5fa88820dcd75d268a9a1e701175d982ef9f3e1f2f46e31e07f1bae03b1af6b82978772
|
7
|
+
data.tar.gz: 23e916f594cd903f57d9b130a39d2ee89b834c319db8e15c9791caa963bb183f9161718079d81c1b8ce2318fb01a25a94027836fa9794b85bf4c6a85acb7662c
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
|
|
24
24
|
Add i18n-tasks to the Gemfile:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
gem 'i18n-tasks', '~> 0.9.
|
27
|
+
gem 'i18n-tasks', '~> 0.9.12'
|
28
28
|
```
|
29
29
|
|
30
30
|
Copy the default [configuration file](#configuration):
|
@@ -10,14 +10,17 @@ module I18n::Tasks::Data::Tree
|
|
10
10
|
attr_accessor :value
|
11
11
|
attr_reader :key, :children, :parent
|
12
12
|
|
13
|
-
|
13
|
+
# rubocop:disable Metrics/ParameterLists
|
14
|
+
def initialize(key:, value: nil, data: nil, parent: nil, children: nil, warn_about_add_children_to_leaf: true)
|
14
15
|
@key = key
|
15
16
|
@key = @key.to_s.freeze if @key
|
16
17
|
@value = value
|
17
18
|
@data = data
|
18
19
|
@parent = parent
|
20
|
+
@warn_about_add_children_to_leaf = warn_about_add_children_to_leaf
|
19
21
|
self.children = (children if children)
|
20
22
|
end
|
23
|
+
# rubocop:enable Metrics/ParameterLists
|
21
24
|
|
22
25
|
def attributes
|
23
26
|
{ key: @key, value: @value, data: @data.try(:clone), parent: @parent, children: @children }
|
@@ -34,7 +37,11 @@ module I18n::Tasks::Data::Tree
|
|
34
37
|
when NilClass
|
35
38
|
nil
|
36
39
|
else
|
37
|
-
Siblings.new(
|
40
|
+
Siblings.new(
|
41
|
+
nodes: children,
|
42
|
+
parent: self,
|
43
|
+
warn_about_add_children_to_leaf: @warn_about_add_children_to_leaf
|
44
|
+
)
|
38
45
|
end
|
39
46
|
dirty!
|
40
47
|
end
|
@@ -18,6 +18,7 @@ module I18n::Tasks::Data::Tree
|
|
18
18
|
@parent = opts[:parent] || first.try(:parent)
|
19
19
|
@list.map! { |node| node.parent == @parent ? node : node.derive(parent: @parent) }
|
20
20
|
@key_to_node = @list.each_with_object({}) { |node, h| h[node.key] = node }
|
21
|
+
@warn_about_add_children_to_leaf = opts.fetch(:warn_about_add_children_to_leaf, true)
|
21
22
|
end
|
22
23
|
|
23
24
|
def attributes
|
@@ -104,11 +105,16 @@ module I18n::Tasks::Data::Tree
|
|
104
105
|
|
105
106
|
if rest
|
106
107
|
unless child
|
107
|
-
child = Node.new(
|
108
|
+
child = Node.new(
|
109
|
+
key: key_part,
|
110
|
+
parent: parent,
|
111
|
+
children: [],
|
112
|
+
warn_about_add_children_to_leaf: @warn_add_children_to_leaf
|
113
|
+
)
|
108
114
|
append! child
|
109
115
|
end
|
110
116
|
unless child.children
|
111
|
-
warn_add_children_to_leaf child
|
117
|
+
warn_add_children_to_leaf child if @warn_about_add_children_to_leaf
|
112
118
|
child.children = []
|
113
119
|
end
|
114
120
|
child.children.set rest, node
|
@@ -254,7 +260,7 @@ module I18n::Tasks::Data::Tree
|
|
254
260
|
# @param key_occurrences [I18n::Tasks::Scanners::KeyOccurrences]
|
255
261
|
# @return [Siblings]
|
256
262
|
def from_key_occurrences(key_occurrences)
|
257
|
-
build_forest do |forest|
|
263
|
+
build_forest(warn_about_add_children_to_leaf: false) do |forest|
|
258
264
|
key_occurrences.each do |key_occurrence|
|
259
265
|
forest[key_occurrence.key] = ::I18n::Tasks::Data::Tree::Node.new(
|
260
266
|
key: split_key(key_occurrence.key).last,
|
data/lib/i18n/tasks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|