i18n-tasks 0.9.11 → 0.9.12

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: 43ba419e2a8a2c55b5a06ae4bebd614498107330
4
- data.tar.gz: 1f61d868e4ed17245c9932eb2a0fc7e5d79ecb7b
3
+ metadata.gz: a8fdd3b0e7a3f582d6ebf37b2fa35117f626ce72
4
+ data.tar.gz: 2e487915be57d0b7392bba89bb666a28fd143d23
5
5
  SHA512:
6
- metadata.gz: 013ee29af74037df89abd7e74c9bede1423d7274fa752fba8aca4d0f04c13408dc509df796cacd817ed090e766c89d7e3df5562543cec87aa58c6d288c1fe761
7
- data.tar.gz: ef12279c48c34e3691ad826569d30b88b01cc9a082756c0d8d7bb5f3807de0fbd6c2076ad9bf66e5b2a59b3dde225752c7ebb752013b9958c58130f628b83a69
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.11'
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
- def initialize(key:, value: nil, data: nil, parent: nil, children: nil)
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(nodes: children, parent: self)
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(key: key_part, parent: parent, children: [])
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,
@@ -45,7 +45,7 @@ module I18n::Tasks::Scanners
45
45
  /(?:
46
46
  :scope\s*=>\s* | (?# :scope => :home )
47
47
  scope:\s* (?# scope: :home )
48
- ) ([^\n)%#]*)/x
48
+ ) (\[[^\n)%#]*\]|[^\n)%#,]*)/x
49
49
  end
50
50
 
51
51
  # match code expression
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.9.11'
4
+ VERSION = '0.9.12'
5
5
  end
6
6
  end
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.11
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-02 00:00:00.000000000 Z
11
+ date: 2017-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport