i18n-tasks 0.8.3 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +4 -0
- data/i18n-tasks.gemspec +1 -1
- data/lib/i18n/tasks.rb +9 -2
- data/lib/i18n/tasks/command/collection.rb +1 -0
- data/lib/i18n/tasks/command/commands/missing.rb +2 -0
- data/lib/i18n/tasks/command/dsl.rb +1 -3
- data/lib/i18n/tasks/command/options/common.rb +1 -0
- data/lib/i18n/tasks/data.rb +3 -3
- data/lib/i18n/tasks/data/file_system_base.rb +7 -4
- data/lib/i18n/tasks/data/tree/traversal.rb +1 -1
- data/lib/i18n/tasks/scanners/pattern_scanner.rb +5 -1
- data/lib/i18n/tasks/split_key.rb +1 -1
- data/lib/i18n/tasks/used_keys.rb +1 -1
- data/lib/i18n/tasks/version.rb +1 -1
- data/spec/fixtures/config/i18n-tasks.yml +1 -0
- data/spec/i18n_tasks_spec.rb +1 -1
- data/spec/relative_keys_spec.rb +39 -0
- data/spec/support/capture_std.rb +1 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6927148f79d82a7dfc85f9ed1551c65ab5534e34
|
4
|
+
data.tar.gz: 16af9b34933d2e3101c55e8c0edd0da014faa286
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fac88101d8d8087cf436299a25be28a56e70305f28b2c15c43d0888e1b3da34bb6ca23683d7dca216ecc27b7fa32324645882a77ee87b76c7dc7ead85e81b87
|
7
|
+
data.tar.gz: 4692ca4f35efcce3f1069f6d6068c4db6e492f99be500f57c4c88bf2bdf57d31ca7215edc23f8cdc5d16e3213c4c1ff3fded90378cf71a653638253cc368c11d
|
data/CHANGES.md
CHANGED
data/i18n-tasks.gemspec
CHANGED
@@ -37,7 +37,7 @@ TEXT
|
|
37
37
|
s.add_dependency 'activesupport'
|
38
38
|
s.add_dependency 'easy_translate', '>= 0.5.0'
|
39
39
|
s.add_dependency 'term-ansicolor'
|
40
|
-
s.add_dependency 'terminal-table'
|
40
|
+
s.add_dependency 'terminal-table', '~> 1.4.5'
|
41
41
|
s.add_dependency 'highline'
|
42
42
|
s.add_dependency 'i18n'
|
43
43
|
s.add_development_dependency 'axlsx', '~> 2.0'
|
data/lib/i18n/tasks.rb
CHANGED
@@ -24,12 +24,19 @@ module I18n
|
|
24
24
|
end
|
25
25
|
|
26
26
|
|
27
|
+
require 'active_support/inflector'
|
27
28
|
require 'active_support/core_ext/hash'
|
28
|
-
require 'active_support/core_ext/string'
|
29
29
|
require 'active_support/core_ext/array/access'
|
30
|
+
require 'active_support/core_ext/array/extract_options'
|
30
31
|
require 'active_support/core_ext/module/delegation'
|
31
|
-
require 'active_support/core_ext/object/try'
|
32
32
|
require 'active_support/core_ext/object/blank'
|
33
|
+
begin
|
34
|
+
# activesupport >= 3
|
35
|
+
require 'active_support/core_ext/object/try'
|
36
|
+
rescue LoadError => _e
|
37
|
+
# activesupport ~> 2.3.2
|
38
|
+
require 'active_support/core_ext/try'
|
39
|
+
end
|
33
40
|
require 'term/ansicolor'
|
34
41
|
require 'erubis'
|
35
42
|
|
data/lib/i18n/tasks/data.rb
CHANGED
@@ -10,11 +10,11 @@ module I18n::Tasks
|
|
10
10
|
@data ||= begin
|
11
11
|
data_config = (config[:data] || {}).with_indifferent_access
|
12
12
|
data_config.merge!(base_locale: base_locale, locales: config[:locales])
|
13
|
-
adapter_class = data_config[:adapter].presence || data_config[:class].presence ||
|
13
|
+
adapter_class = data_config[:adapter].presence || data_config[:class].presence || 'file_system'
|
14
14
|
adapter_class = adapter_class.to_s
|
15
|
-
adapter_class =
|
15
|
+
adapter_class = 'I18n::Tasks::Data::FileSystem' if adapter_class == 'file_system'
|
16
16
|
data_config.except!(:adapter, :class)
|
17
|
-
|
17
|
+
ActiveSupport::Inflector.constantize(adapter_class).new data_config
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -122,13 +122,16 @@ module I18n::Tasks
|
|
122
122
|
self.router = router_was
|
123
123
|
end
|
124
124
|
|
125
|
+
|
126
|
+
ROUTER_NAME_ALIASES = {
|
127
|
+
'conservative_router' => 'I18n::Tasks::Data::Router::ConservativeRouter',
|
128
|
+
'pattern_router' => 'I18n::Tasks::Data::Router::PatternRouter'
|
129
|
+
}
|
125
130
|
def router
|
126
131
|
@router ||= begin
|
127
132
|
name = @config[:router].presence || 'conservative_router'
|
128
|
-
|
129
|
-
|
130
|
-
end
|
131
|
-
name.constantize.new(self, @config.merge(base_locale: base_locale, locales: locales))
|
133
|
+
name = ROUTER_NAME_ALIASES[name] || name
|
134
|
+
ActiveSupport::Inflector.constantize(name).new(self, @config.merge(base_locale: base_locale, locales: locales))
|
132
135
|
end
|
133
136
|
end
|
134
137
|
attr_writer :router
|
@@ -128,7 +128,7 @@ module I18n::Tasks
|
|
128
128
|
def set_each_value!(val_pattern, key_pattern = nil, &value_proc)
|
129
129
|
value_proc ||= proc { |node|
|
130
130
|
node_value = node.value
|
131
|
-
human_key = node.key.to_s
|
131
|
+
human_key = ActiveSupport::Inflector.humanize(node.key.to_s)
|
132
132
|
StringInterpolation.interpolate_soft(
|
133
133
|
val_pattern,
|
134
134
|
value: node_value,
|
@@ -47,7 +47,7 @@ module I18n::Tasks::Scanners
|
|
47
47
|
|
48
48
|
def absolute_key(key, path, location)
|
49
49
|
if key.start_with?('.')
|
50
|
-
if controller_file?(path)
|
50
|
+
if controller_file?(path) || mailer_file?(path)
|
51
51
|
absolutize_key(key, path, relative_roots, closest_method(location))
|
52
52
|
else
|
53
53
|
absolutize_key(key, path)
|
@@ -61,6 +61,10 @@ module I18n::Tasks::Scanners
|
|
61
61
|
/controllers/.match(path)
|
62
62
|
end
|
63
63
|
|
64
|
+
def mailer_file?(path)
|
65
|
+
/mailers/.match(path)
|
66
|
+
end
|
67
|
+
|
64
68
|
def closest_method(location)
|
65
69
|
method = File.readlines(location[:src_path], encoding: 'UTF-8').first(location[:line_num] - 1).reverse_each.find { |x| x=~ /\bdef\b/ }
|
66
70
|
method &&= method.strip.sub(/^def\s*/, '').sub(/[\(\s;].*$/, '')
|
data/lib/i18n/tasks/split_key.rb
CHANGED
data/lib/i18n/tasks/used_keys.rb
CHANGED
@@ -22,7 +22,7 @@ module I18n::Tasks
|
|
22
22
|
@scanner ||= begin
|
23
23
|
search_config = (config[:search] || {}).with_indifferent_access
|
24
24
|
class_name = search_config[:scanner] || '::I18n::Tasks::Scanners::PatternWithScopeScanner'
|
25
|
-
|
25
|
+
ActiveSupport::Inflector.constantize(class_name).new search_config
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
data/lib/i18n/tasks/version.rb
CHANGED
data/spec/i18n_tasks_spec.rb
CHANGED
@@ -158,7 +158,7 @@ describe 'i18n-tasks' do
|
|
158
158
|
}
|
159
159
|
run_cmd 'add-missing', 'base'
|
160
160
|
in_test_app_dir {
|
161
|
-
expect(YAML.load_file('config/locales/en.yml')['en']['used_but_missing']['key']).to eq
|
161
|
+
expect(YAML.load_file('config/locales/en.yml')['en']['used_but_missing']['key']).to eq 'Key'
|
162
162
|
expect(YAML.load_file('config/locales/en.yml')['en']['present_in_es_but_not_en']['a']).to eq 'ES_TEXT'
|
163
163
|
}
|
164
164
|
end
|
data/spec/relative_keys_spec.rb
CHANGED
@@ -55,5 +55,44 @@ describe 'Relative keys' do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
context 'relative key in mailer' do
|
60
|
+
it 'works' do
|
61
|
+
key = scanner.absolutize_key(
|
62
|
+
'.subject',
|
63
|
+
'app/mailers/user_mailer.rb',
|
64
|
+
%w(app/mailers),
|
65
|
+
'welcome'
|
66
|
+
)
|
67
|
+
|
68
|
+
expect(key).to eq('user_mailer.welcome.subject')
|
69
|
+
end
|
70
|
+
|
71
|
+
context 'multiple words in mailer name' do
|
72
|
+
it 'works' do
|
73
|
+
key = scanner.absolutize_key(
|
74
|
+
'.subject',
|
75
|
+
'app/mailers/admin_user_mailer.rb',
|
76
|
+
%w(app/mailers),
|
77
|
+
'welcome'
|
78
|
+
)
|
79
|
+
|
80
|
+
expect(key).to eq('admin_user_mailer.welcome.subject')
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
context 'nested in module' do
|
85
|
+
it 'works' do
|
86
|
+
key = scanner.absolutize_key(
|
87
|
+
'.subject',
|
88
|
+
'app/mailers/nested/user_mailer.rb',
|
89
|
+
%w(app/mailers),
|
90
|
+
'welcome'
|
91
|
+
)
|
92
|
+
|
93
|
+
expect(key).to eq('nested.user_mailer.welcome.subject')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
58
97
|
end
|
59
98
|
end
|
data/spec/support/capture_std.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.8.
|
4
|
+
version: 0.8.4
|
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-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: terminal-table
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.4.5
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.4.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: highline
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|