i18n-tasks 0.7.11 → 0.7.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 +4 -4
- data/.travis.yml +2 -1
- data/CHANGES.md +8 -2
- data/README.md +1 -1
- data/lib/i18n/tasks/data/file_formats.rb +9 -3
- data/lib/i18n/tasks/scanners/base_scanner.rb +1 -1
- data/lib/i18n/tasks/scanners/relative_keys.rb +1 -1
- data/lib/i18n/tasks/version.rb +1 -1
- data/spec/google_translate_spec.rb +1 -1
- data/spec/locale_tree/siblings_spec.rb +25 -5
- data/spec/readme_spec.rb +1 -1
- data/spec/relative_keys_spec.rb +14 -3
- data/spec/support/capture_std.rb +4 -0
- data/spec/support/test_codebase.rb +1 -1
- data/spec/support/trees.rb +6 -0
- metadata +3 -4
- data/.jrubyrc +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9d57ea517b4561e2eb31ddee6376bb9d65ef9c7
|
4
|
+
data.tar.gz: ddaf2b27bca1586c84625864809c970ac697e8de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 669191968390c3ed44ba2537ecd51603a76f56f542c82499dbf3ce89d5c0b303085ba6d37ba40a0099c7947cf319a42e2b3513756aacf2c2f40c89dd592e9396
|
7
|
+
data.tar.gz: 88f3289f9e4734a074056d6be1d0310c2c8299c98679988664f62819cf39fa9b11ebb58df353bed86dc4fca21f72bed5bc784c5af0ba9820434e0fd18a6ead89
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
+
## 0.7.12
|
2
|
+
|
3
|
+
* Handle relative keys in controllers nested in modules by [Alexander Tipugin](https://github.com/atipugin). [#128](https://github.com/glebm/i18n-tasks/issues/128).
|
4
|
+
* Only write files that changed [#125](https://github.com/glebm/i18n-tasks/issues/125).
|
5
|
+
* Allow `[]` in the non-strict scanner pattern [#127](https://github.com/glebm/i18n-tasks/issues/127).
|
6
|
+
|
1
7
|
## 0.7.11
|
2
8
|
|
3
|
-
* Set slop dependency to 3.5 to ensure Ruby 1.9 compatibility
|
9
|
+
* Set slop dependency to 3.5 to ensure Ruby 1.9 compatibility ([#121](https://github.com/glebm/i18n-tasks/pull/121)).
|
4
10
|
MRI 1.9 EOL is [February 23, 2015](https://www.ruby-lang.org/en/news/2014/01/10/ruby-1-9-3-will-end-on-2015/).
|
5
11
|
We will support 1.9 until rbx and jruby support 2.0.
|
6
12
|
|
@@ -10,7 +16,7 @@
|
|
10
16
|
|
11
17
|
## 0.7.9
|
12
18
|
|
13
|
-
* Support relative keys in Rails controller actions by [Jessie A. Young](https://github.com/jessieay). [#46](https://github.com/glebm/i18n-tasks/issues/46)
|
19
|
+
* Support relative keys in Rails controller actions by [Jessie A. Young](https://github.com/jessieay). [#46](https://github.com/glebm/i18n-tasks/issues/46).
|
14
20
|
* Minor fixes
|
15
21
|
|
16
22
|
## 0.7.8
|
data/README.md
CHANGED
@@ -22,7 +22,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
|
|
22
22
|
Add it to the Gemfile:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
gem 'i18n-tasks', '~> 0.7.
|
25
|
+
gem 'i18n-tasks', '~> 0.7.12'
|
26
26
|
```
|
27
27
|
|
28
28
|
Copy default [configuration file](#configuration) (optional):
|
@@ -38,10 +38,16 @@ module I18n
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def write_tree(path, tree)
|
41
|
+
hash = tree.to_hash(true)
|
42
|
+
adapter = self.class.adapter_name_for_path(path)
|
43
|
+
content = adapter_dump(hash, adapter)
|
44
|
+
# Ignore unchanged data
|
45
|
+
return if File.file?(path) &&
|
46
|
+
# Comparing hashes for equality directly would ignore key order.
|
47
|
+
# Round-trip through the adapter and compare the strings instead:
|
48
|
+
content == adapter_dump(load_file(path), adapter)
|
41
49
|
::FileUtils.mkpath(File.dirname path)
|
42
|
-
::File.open(path, 'w') { |f|
|
43
|
-
f.write adapter_dump(tree.to_hash(true), self.class.adapter_name_for_path(path))
|
44
|
-
}
|
50
|
+
::File.open(path, 'w') { |f| f.write content }
|
45
51
|
end
|
46
52
|
|
47
53
|
module ClassMethods
|
@@ -128,7 +128,7 @@ module I18n::Tasks::Scanners
|
|
128
128
|
|
129
129
|
VALID_KEY_CHARS = /[-\w.?!;]/
|
130
130
|
VALID_KEY_RE_STRICT = /^#{VALID_KEY_CHARS}+$/
|
131
|
-
VALID_KEY_RE = /^(#{VALID_KEY_CHARS}|[:\#{@}])+$/
|
131
|
+
VALID_KEY_RE = /^(#{VALID_KEY_CHARS}|[:\#{@}\[\]])+$/
|
132
132
|
|
133
133
|
def valid_key?(key, strict = false)
|
134
134
|
return false if @key_filter && @key_filter_pattern !~ key
|
@@ -42,7 +42,7 @@ module I18n
|
|
42
42
|
file_name = normalized_path.gsub(%r(#{path_root(normalized_path, roots)}/|(\.[^/]+)*$), '')
|
43
43
|
|
44
44
|
if options[:closest_method].present?
|
45
|
-
"#{file_name.split('_').first}.#{options[:closest_method]}"
|
45
|
+
"#{file_name.split('_').first}.#{options[:closest_method]}".tr('/', '.')
|
46
46
|
else
|
47
47
|
file_name.tr('/', '.').gsub(%r(\._), '.')
|
48
48
|
end
|
data/lib/i18n/tasks/version.rb
CHANGED
@@ -9,7 +9,7 @@ describe 'Google Translation' do
|
|
9
9
|
nil_value_test = ['nil-value-key', nil, nil],
|
10
10
|
text_test = ['key', "Hello - %{user} O'neill!", "Hola - %{user} O'neill!"],
|
11
11
|
html_test = ['html-key.html', "Hello - <b>%{user} O'neill</b>", "Hola - <b>%{user} O'neill</b>"],
|
12
|
-
array_test = ['array-key', ['Hello.', nil, '', 'Goodbye.'], ['
|
12
|
+
array_test = ['array-key', ['Hello.', nil, '', 'Goodbye.'], ['Hola.', nil, '', 'Adiós.']],
|
13
13
|
fixnum_test = ['numeric-key', 1, 1],
|
14
14
|
]
|
15
15
|
|
@@ -6,12 +6,32 @@ describe 'Tree siblings / forest' do
|
|
6
6
|
context 'Node' do
|
7
7
|
it '::new with children' do
|
8
8
|
children = I18n::Tasks::Data::Tree::Siblings.from_key_attr([['a', value: 1]])
|
9
|
-
node =
|
9
|
+
node = new_node(
|
10
10
|
key: 'fr',
|
11
11
|
children: children
|
12
12
|
)
|
13
13
|
expect(node.to_siblings.first.children.parent.key).to eq 'fr'
|
14
14
|
end
|
15
|
+
|
16
|
+
it '== (false by value)' do
|
17
|
+
expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not(
|
18
|
+
eq(build_node({'a' => {'b' => {'c' => 2}}})))
|
19
|
+
end
|
20
|
+
|
21
|
+
it '== (false by key)' do
|
22
|
+
expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not(
|
23
|
+
eq(build_node({'a' => {'b' => {'d' => 1}}})))
|
24
|
+
end
|
25
|
+
|
26
|
+
it '== (false by children)' do
|
27
|
+
expect(build_node({'a' => {'b' => {'c' => 1}}})).to_not(
|
28
|
+
eq(build_node({'a' => {'b' => {'c' => 1}, 'x' => 2}})))
|
29
|
+
end
|
30
|
+
|
31
|
+
it '== (true)' do
|
32
|
+
expect(build_node({'a' => {'b' => {'c' => 1}, 'x' => 2}})).to_not(
|
33
|
+
eq(build_node({'a' => {'b' => {'d' => 1}, 'x' => 2}})))
|
34
|
+
end
|
15
35
|
end
|
16
36
|
|
17
37
|
context 'a tree' do
|
@@ -55,7 +75,7 @@ describe 'Tree siblings / forest' do
|
|
55
75
|
|
56
76
|
it '#set conflict value <- scope' do
|
57
77
|
a = build_tree(a: 1)
|
58
|
-
expect { silence_stderr { a.set('a.b',
|
78
|
+
expect { silence_stderr { a.set('a.b', new_node(key: 'b', value: 1)) } }.to_not raise_error
|
59
79
|
end
|
60
80
|
|
61
81
|
it '#intersect' do
|
@@ -72,18 +92,18 @@ describe 'Tree siblings / forest' do
|
|
72
92
|
end
|
73
93
|
|
74
94
|
it '#append!' do
|
75
|
-
expect(build_tree({'a' => 1}).append!(
|
95
|
+
expect(build_tree({'a' => 1}).append!(new_node(key: 'b', value: 2)).to_hash).to eq('a' => 1, 'b' => 2)
|
76
96
|
end
|
77
97
|
|
78
98
|
it '#set replace value' do
|
79
|
-
expect(build_tree(a: {b: 1}).tap {|t| t['a.b'] =
|
99
|
+
expect(build_tree(a: {b: 1}).tap {|t| t['a.b'] = new_node(key: 'b', value: 2) }.to_hash).to(
|
80
100
|
eq('a' => {'b' => 2})
|
81
101
|
)
|
82
102
|
end
|
83
103
|
|
84
104
|
it '#set get' do
|
85
105
|
t = build_tree(a: {x: 1})
|
86
|
-
node =
|
106
|
+
node = new_node(key: 'd', value: 'e')
|
87
107
|
t['a.b.c.' + node.key] = node
|
88
108
|
expect(t['a.b.c.d'].value).to eq('e')
|
89
109
|
end
|
data/spec/readme_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'spec_helper'
|
3
3
|
describe 'README.md' do
|
4
|
-
let(:readme) { File.read('README.md') }
|
4
|
+
let(:readme) { File.read('README.md', encoding: 'UTF-8') }
|
5
5
|
it 'has valid YAML in ```yaml blocks' do
|
6
6
|
readme.scan /```yaml\n(.*)(?=^)\n```/ do |m|
|
7
7
|
expect { YAML.load(m[0]) }.to_not raise_errors
|
data/spec/relative_keys_spec.rb
CHANGED
@@ -19,9 +19,7 @@ describe 'Relative keys' do
|
|
19
19
|
|
20
20
|
context 'relative key in controller' do
|
21
21
|
it 'works' do
|
22
|
-
|
23
|
-
|
24
|
-
key = base_scanner.absolutize_key(
|
22
|
+
key = scanner.absolutize_key(
|
25
23
|
'.success',
|
26
24
|
'app/controllers/users_controller.rb',
|
27
25
|
%w(app/controllers),
|
@@ -30,6 +28,19 @@ describe 'Relative keys' do
|
|
30
28
|
|
31
29
|
expect(key).to eq('users.create.success')
|
32
30
|
end
|
31
|
+
|
32
|
+
context 'nested in module' do
|
33
|
+
it 'works' do
|
34
|
+
key = scanner.absolutize_key(
|
35
|
+
'.success',
|
36
|
+
'app/controllers/nested/users_controller.rb',
|
37
|
+
%w(app/controllers),
|
38
|
+
'create'
|
39
|
+
)
|
40
|
+
|
41
|
+
expect(key).to eq('nested.users.create.success')
|
42
|
+
end
|
43
|
+
end
|
33
44
|
end
|
34
45
|
end
|
35
46
|
end
|
data/spec/support/capture_std.rb
CHANGED
data/spec/support/trees.rb
CHANGED
@@ -10,6 +10,12 @@ module Trees
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def build_node(attr = {})
|
13
|
+
raise 'invalid node (more than 1 root)' if attr.size > 1
|
14
|
+
key, value = attr.first
|
15
|
+
I18n::Tasks::Data::Tree::Node.from_key_value(key, value)
|
16
|
+
end
|
17
|
+
|
18
|
+
def new_node(attr = {})
|
13
19
|
I18n::Tasks::Data::Tree::Node.new(attr)
|
14
20
|
end
|
15
21
|
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.7.
|
4
|
+
version: 0.7.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|
@@ -206,7 +206,6 @@ extra_rdoc_files: []
|
|
206
206
|
files:
|
207
207
|
- ".coveralls.yml"
|
208
208
|
- ".gitignore"
|
209
|
-
- ".jrubyrc"
|
210
209
|
- ".travis.yml"
|
211
210
|
- CHANGES.md
|
212
211
|
- Gemfile
|
@@ -334,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
334
333
|
version: '0'
|
335
334
|
requirements: []
|
336
335
|
rubyforge_project:
|
337
|
-
rubygems_version: 2.4.
|
336
|
+
rubygems_version: 2.4.5
|
338
337
|
signing_key:
|
339
338
|
specification_version: 4
|
340
339
|
summary: Manage localization and translation with the awesome power of static analysis
|
data/.jrubyrc
DELETED