i18n-tasks 0.4.0.beta1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +2 -2
- data/i18n-tasks.gemspec +1 -1
- data/lib/i18n/tasks/scanners/base_scanner.rb +1 -1
- data/lib/i18n/tasks/version.rb +1 -1
- data/spec/conservative_router_spec.rb +4 -4
- data/spec/file_system_data_spec.rb +4 -4
- data/spec/fixtures/app/views/index.html.slim +1 -0
- data/spec/google_translate_spec.rb +2 -2
- data/spec/i18n_tasks_spec.rb +7 -5
- data/spec/key_pattern_matching_spec.rb +18 -18
- data/spec/relative_keys_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -1
- data/spec/support/i18n_tasks_output_matcher.rb +2 -2
- data/spec/support/key_pattern_matcher.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efe7070e53b66680ce9137f81c21755823c27cb2
|
4
|
+
data.tar.gz: 925f44e4027a20cff615a97b2ad2dcf3c8e10ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e079e4bb84bde0365ac3628c63670317b7827db35fc1eef6789e1ce3eb82144a42de4e7ace9240e737c0b08db5e711b13a7be38465881f49b5989f856beb0cf9
|
7
|
+
data.tar.gz: 1878f3455bb41be8824e5dd59a235f4afafd1ca0830e1b881fc9e0f26688c50b7e7e95de97d8ee0a38f10b416f8bab7f3de4fb011237e3378586efc014e9ca81
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ i18n-tasks can be used with any project using [i18n][i18n-gem] (default in Rails
|
|
18
18
|
Add to Gemfile:
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
gem 'i18n-tasks', '~> 0.
|
21
|
+
gem 'i18n-tasks', '~> 0.4.0'
|
22
22
|
```
|
23
23
|
|
24
24
|
i18n-tasks does not load or execute any of the application's code but performs static-only analysic.
|
@@ -188,7 +188,7 @@ data:
|
|
188
188
|
- 'config/locales/%{locale}.yml'
|
189
189
|
```
|
190
190
|
|
191
|
-
##### Conservative router
|
191
|
+
##### Conservative router
|
192
192
|
|
193
193
|
Conservative router keeps the keys where they are found, or infers the path from base locale.
|
194
194
|
If the key is completely new, conservative router will fall back to the pattern router behaviour.
|
data/i18n-tasks.gemspec
CHANGED
@@ -37,6 +37,6 @@ It can also can pre-fill missing keys, including from Google Translate, and it c
|
|
37
37
|
s.add_development_dependency 'axlsx', '~> 2.0'
|
38
38
|
s.add_development_dependency 'bundler', '~> 1.3'
|
39
39
|
s.add_development_dependency 'rake'
|
40
|
-
s.add_development_dependency 'rspec'
|
40
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
41
41
|
s.add_development_dependency 'yard'
|
42
42
|
end
|
data/lib/i18n/tasks/version.rb
CHANGED
@@ -26,7 +26,7 @@ describe 'Conservative router' do
|
|
26
26
|
TestCodebase.in_test_app_dir do
|
27
27
|
data['es'] = data['es']
|
28
28
|
data.reload
|
29
|
-
data['es']['es.c'].data[:path].
|
29
|
+
expect(data['es']['es.c'].data[:path]).to eq('config/locales/other.es.yml')
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -34,8 +34,8 @@ describe 'Conservative router' do
|
|
34
34
|
TestCodebase.in_test_app_dir do
|
35
35
|
data['es'] = data['es'].merge!(build_tree(es: {a: 1, b: 2}))
|
36
36
|
data.reload
|
37
|
-
data['es']['es.a'].data[:path].
|
38
|
-
data['es']['es.b'].data[:path].
|
37
|
+
expect(data['es']['es.a'].data[:path]).to eq('config/locales/es.yml')
|
38
|
+
expect(data['es']['es.b'].data[:path]).to eq('config/locales/other.es.yml')
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -43,7 +43,7 @@ describe 'Conservative router' do
|
|
43
43
|
TestCodebase.in_test_app_dir do
|
44
44
|
data['es'] = data['es'].merge!(build_tree(es: {z: 2}))
|
45
45
|
data.reload
|
46
|
-
data['es']['es.z'].data[:path].
|
46
|
+
expect(data['es']['es.z'].data[:path]).to eq('config/locales/not_found.es.yml')
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -58,8 +58,8 @@ describe 'File system i18n' do
|
|
58
58
|
TestCodebase.in_test_app_dir {
|
59
59
|
data[:en] = data[:en].merge!('en' => locale_data)
|
60
60
|
files = %w(pizza.en.yml sushi.en.yml)
|
61
|
-
Dir['*.yml'].sort.
|
62
|
-
files.each { |f| YAML.load_file(f)['en'].
|
61
|
+
expect(Dir['*.yml'].sort).to eq(files.sort)
|
62
|
+
files.each { |f| expect(YAML.load_file(f)['en']).to eq({File.basename(f, '.en.yml') => keys}) }
|
63
63
|
}
|
64
64
|
end
|
65
65
|
end
|
@@ -93,8 +93,8 @@ describe 'File system i18n' do
|
|
93
93
|
TestCodebase.in_test_app_dir {
|
94
94
|
data[:en] = data[:en].merge!('en' => locale_data)
|
95
95
|
files = %w(pizza.en.json sushi.en.json)
|
96
|
-
Dir['*.json'].sort.
|
97
|
-
files.each { |f| JSON.parse(File.read f)['en'].
|
96
|
+
expect(Dir['*.json'].sort).to eq(files.sort)
|
97
|
+
files.each { |f| expect(JSON.parse(File.read f)['en']).to eq({File.basename(f, '.en.json') => keys}) }
|
98
98
|
}
|
99
99
|
end
|
100
100
|
end
|
@@ -2,6 +2,7 @@ p #{t('ca.a')} #{t 'ca.b'} #{t "ca.c"}
|
|
2
2
|
p #{t 'ca.d'} #{t 'ca.f', i: 'world'} #{t 'ca.e', i: 'world'}
|
3
3
|
p #{t 'missing_in_es.a'} #{t 'same_in_es.a'} #{t 'blank_in_es.a'}
|
4
4
|
p = t 'used_but_missing.key'
|
5
|
+
p = t 'missing-key-with-a-dash.key'
|
5
6
|
p = t 'x', scope: 'scoped'
|
6
7
|
p = t 'x', scope: [:very, :scoped]
|
7
8
|
p = t 'x', scope: [:scoped, code]
|
@@ -13,9 +13,9 @@ describe 'Google Translation' do
|
|
13
13
|
|
14
14
|
context 'API' do
|
15
15
|
it 'works' do
|
16
|
-
google_translate(
|
16
|
+
expect(google_translate(
|
17
17
|
[['common.hello', TEST_STRING]], from: :en, to: :es, key: ENV['GOOGLE_TRANSLATE_API_KEY']
|
18
|
-
).
|
18
|
+
)).to eq([['common.hello', TEST_RESULT]])
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/spec/i18n_tasks_spec.rb
CHANGED
@@ -12,7 +12,9 @@ describe 'i18n-tasks' do
|
|
12
12
|
es.missing_in_es.a es.same_in_es.a
|
13
13
|
en.hash.pattern_missing.a en.hash.pattern_missing.b
|
14
14
|
en.missing_symbol_key en.missing_symbol.key_two en.missing_symbol.key_three
|
15
|
-
es.missing_in_es_plural_1.a es.missing_in_es_plural_2.a
|
15
|
+
es.missing_in_es_plural_1.a es.missing_in_es_plural_2.a
|
16
|
+
en.missing-key-with-a-dash.key
|
17
|
+
)
|
16
18
|
}
|
17
19
|
it 'detects missing or identical' do
|
18
20
|
capture_stderr do
|
@@ -39,8 +41,8 @@ describe 'i18n-tasks' do
|
|
39
41
|
in_test_app_dir do
|
40
42
|
t = i18n_task
|
41
43
|
expected_unused_keys.each do |key|
|
42
|
-
expect(t.key_value?(key, :en)).to
|
43
|
-
expect(t.key_value?(key, :es)).to
|
44
|
+
expect(t.key_value?(key, :en)).to be true
|
45
|
+
expect(t.key_value?(key, :es)).to be true
|
44
46
|
end
|
45
47
|
ENV['CONFIRM'] = '1'
|
46
48
|
capture_stderr {
|
@@ -48,8 +50,8 @@ describe 'i18n-tasks' do
|
|
48
50
|
}
|
49
51
|
t.data.reload
|
50
52
|
expected_unused_keys.each do |key|
|
51
|
-
expect(t.key_value?(key, :en)).to
|
52
|
-
expect(t.key_value?(key, :es)).to
|
53
|
+
expect(t.key_value?(key, :en)).to be false
|
54
|
+
expect(t.key_value?(key, :es)).to be false
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -6,58 +6,58 @@ describe 'Key pattern' do
|
|
6
6
|
describe 'matching' do
|
7
7
|
describe '*' do
|
8
8
|
it 'as suffix' do
|
9
|
-
'devise.*'.
|
9
|
+
expect('devise.*').to match_key 'devise.some.key'
|
10
10
|
end
|
11
11
|
it 'as prefix' do
|
12
|
-
'*.some.key'.
|
12
|
+
expect('*.some.key').to match_key 'devise.some.key'
|
13
13
|
end
|
14
14
|
it 'as infix' do
|
15
|
-
'*.some.*'.
|
15
|
+
expect('*.some.*').to match_key 'devise.some.key'
|
16
16
|
end
|
17
17
|
it 'matches multiple namespaces' do
|
18
|
-
'a.*.e*'.
|
18
|
+
expect('a.*.e*').to match_key 'a.b.c.d.eeee'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe ':' do
|
23
23
|
it 'as suffix' do
|
24
|
-
'a.b.:'.
|
25
|
-
'a.b.:'.
|
24
|
+
expect('a.b.:').to match_key 'a.b.c'
|
25
|
+
expect('a.b.:').not_to match_key 'a.b.c.d'
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'as prefix' do
|
29
|
-
':.b.c'.
|
30
|
-
':.b.c'.
|
29
|
+
expect(':.b.c').to match_key 'a.b.c'
|
30
|
+
expect(':.b.c').not_to match_key 'x.a.b.c'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'as infix' do
|
34
|
-
'a.:.c'.
|
35
|
-
'a.:.c'.
|
34
|
+
expect('a.:.c').to match_key 'a.b.c'
|
35
|
+
expect('a.:.c').not_to match_key 'a.b.x.c'
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
describe '{sets}' do
|
40
40
|
it 'matches' do
|
41
41
|
p = 'a.{x,y}.b'
|
42
|
-
p.
|
43
|
-
p.
|
44
|
-
p.
|
42
|
+
expect(p).to match_key 'a.x.b'
|
43
|
+
expect(p).to match_key 'a.y.b'
|
44
|
+
expect(p).not_to match_key 'a.z.b'
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'supports :' do
|
48
|
-
'a.{:}.c'.
|
49
|
-
'a.{:}.c'.
|
48
|
+
expect('a.{:}.c').to match_key 'a.b.c'
|
49
|
+
expect('a.{:}.c').not_to match_key 'a.b.x.c'
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'supports *' do
|
53
|
-
'a.{*}.c'.
|
54
|
-
'a.{*}.c'.
|
53
|
+
expect('a.{*}.c').to match_key 'a.b.c'
|
54
|
+
expect('a.{*}.c').to match_key 'a.b.x.y.c'
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'captures' do
|
58
58
|
p = 'a.{x,y}.{:}'
|
59
59
|
compile_key_pattern(p) =~ 'a.x.c'
|
60
|
-
[$1, $2].
|
60
|
+
expect([$1, $2]).to eq(['x', 'c'])
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/spec/relative_keys_spec.rb
CHANGED
@@ -6,13 +6,13 @@ describe 'Relative keys' do
|
|
6
6
|
|
7
7
|
context 'default settings' do
|
8
8
|
it 'works' do
|
9
|
-
scanner.absolutize_key('.title', 'app/views/movies/show.html.slim', %w(app/views)).
|
9
|
+
expect(scanner.absolutize_key('.title', 'app/views/movies/show.html.slim', %w(app/views))).to eq('movies.show.title')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'custom roots' do
|
14
14
|
it 'works' do
|
15
|
-
scanner.absolutize_key('.title', 'app/views-mobile/movies/show.html.slim', %w(app/views app/views-mobile)).
|
15
|
+
expect(scanner.absolutize_key('.title', 'app/views-mobile/movies/show.html.slim', %w(app/views app/views-mobile))).to eq('movies.show.title')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/spec/spec_helper.rb
CHANGED
@@ -26,10 +26,10 @@ RSpec::Matchers.define :be_i18n_keys do |expected|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
match do |actual|
|
29
|
-
extract_keys(actual).sort.
|
29
|
+
expect(extract_keys(actual).sort).to eq(expected.sort)
|
30
30
|
end
|
31
31
|
|
32
|
-
|
32
|
+
failure_message do |actual|
|
33
33
|
e = expected.sort
|
34
34
|
a = extract_keys(actual).sort
|
35
35
|
|
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.4.0
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
159
|
+
version: '3.0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
166
|
+
version: '3.0'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: yard
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -285,9 +285,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
285
285
|
version: '0'
|
286
286
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
287
287
|
requirements:
|
288
|
-
- - "
|
288
|
+
- - ">="
|
289
289
|
- !ruby/object:Gem::Version
|
290
|
-
version:
|
290
|
+
version: '0'
|
291
291
|
requirements: []
|
292
292
|
rubyforge_project:
|
293
293
|
rubygems_version: 2.2.2
|