i18n-tasks 0.4.4 → 0.4.5
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/README.md +8 -1
- data/bin/i18n-tasks +5 -1
- data/lib/i18n/tasks/commands.rb +1 -1
- data/lib/i18n/tasks/commands_base.rb +4 -0
- data/lib/i18n/tasks/reports/base.rb +1 -0
- data/lib/i18n/tasks/reports/terminal.rb +6 -6
- data/lib/i18n/tasks/version.rb +1 -1
- data/spec/i18n_tasks_spec.rb +3 -2
- data/spec/support/i18n_tasks_output_matcher.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b205200e5f46e458947cd7efa0a3f4781555bed
|
4
|
+
data.tar.gz: 3c233c02ca02b64ce1e5b02d2e068bbee0b1db2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 774d211a16131bcfbf7df07fdb9a0fd7d4926d227df2bb499772af12e12b77f1911dc0b9cf6e39d4f232ed41feb3bbf86781e9ca6d364b7b4d70894690f0b864
|
7
|
+
data.tar.gz: bc56dfc3f345175e329904430678ddbafefcb85a73c068055cd31062dec2b8bd7ab0d6ddb924af410222bdb17b709dd6821ecbadff7b0a9668c9f20a9da9b497
|
data/CHANGES.md
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.4.
|
21
|
+
gem 'i18n-tasks', '~> 0.4.5'
|
22
22
|
```
|
23
23
|
|
24
24
|
i18n-tasks does not load or execute any of the application's code but performs static-only analysic.
|
@@ -124,6 +124,13 @@ Translation data storage, key usage search, and other [settings](#configuration)
|
|
124
124
|
Configuration is read from `config/i18n-tasks.yml` or `config/i18n-tasks.yml.erb`.
|
125
125
|
Inspect configuration with `i18n-tasks config`.
|
126
126
|
|
127
|
+
|
128
|
+
You can generate a config file with:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
i18n-tasks config > config/i18n-tasks.yml
|
132
|
+
```
|
133
|
+
|
127
134
|
### Locales
|
128
135
|
|
129
136
|
By default, `base_locale` is set to `en` and `locales` are inferred from the paths to data files.
|
data/bin/i18n-tasks
CHANGED
@@ -6,7 +6,11 @@ require 'i18n/tasks/commands'
|
|
6
6
|
require 'slop'
|
7
7
|
|
8
8
|
err = proc { |message, exit_code|
|
9
|
-
STDERR.
|
9
|
+
if STDERR.isatty
|
10
|
+
STDERR.puts Term::ANSIColor.yellow('i18n-tasks: ' + message)
|
11
|
+
else
|
12
|
+
STDERR.puts message
|
13
|
+
end
|
10
14
|
exit exit_code
|
11
15
|
}
|
12
16
|
|
data/lib/i18n/tasks/commands.rb
CHANGED
@@ -113,7 +113,7 @@ module I18n::Tasks
|
|
113
113
|
require 'axlsx'
|
114
114
|
rescue LoadError
|
115
115
|
message = %Q(For spreadsheet report please add axlsx gem to Gemfile:\ngem 'axlsx', '~> 2.0')
|
116
|
-
|
116
|
+
log_stderr Term::ANSIColor.red Term::ANSIColor.bold message
|
117
117
|
exit 1
|
118
118
|
end
|
119
119
|
spreadsheet_report.save_report opt[:path]
|
@@ -35,10 +35,14 @@ module I18n::Tasks
|
|
35
35
|
@next_def = {}
|
36
36
|
define_method name do |*args|
|
37
37
|
begin
|
38
|
+
coloring_was = Term::ANSIColor.coloring?
|
39
|
+
Term::ANSIColor.coloring = STDOUT.isatty
|
38
40
|
instance_exec *args, &block
|
39
41
|
rescue CommandError => e
|
40
42
|
log_error e.message
|
41
43
|
exit 78
|
44
|
+
ensure
|
45
|
+
Term::ANSIColor.coloring = coloring_was
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end
|
@@ -70,19 +70,19 @@ module I18n
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def print_title(title)
|
73
|
-
|
73
|
+
log_stderr "#{bold cyan title.strip} #{dark "|"} #{bold "i18n-tasks v#{I18n::Tasks::VERSION}"}"
|
74
74
|
end
|
75
75
|
|
76
76
|
def print_success(message)
|
77
|
-
|
77
|
+
log_stderr(bold green message)
|
78
78
|
end
|
79
79
|
|
80
80
|
def print_error(message)
|
81
|
-
|
81
|
+
log_stderr(bold red message)
|
82
82
|
end
|
83
|
-
|
84
|
-
def print_info(
|
85
|
-
|
83
|
+
|
84
|
+
def print_info(message)
|
85
|
+
log_stderr message
|
86
86
|
end
|
87
87
|
|
88
88
|
def indent(txt, n = 2)
|
data/lib/i18n/tasks/version.rb
CHANGED
data/spec/i18n_tasks_spec.rb
CHANGED
@@ -125,7 +125,7 @@ describe 'i18n-tasks' do
|
|
125
125
|
|
126
126
|
describe 'config' do
|
127
127
|
it 'prints config' do
|
128
|
-
expect(YAML.load(run_cmd :config)).to(
|
128
|
+
expect(YAML.load(Term::ANSIColor.uncolor(run_cmd :config))).to(
|
129
129
|
eq(in_test_app_dir { i18n_task.config_for_inspect })
|
130
130
|
)
|
131
131
|
end
|
@@ -134,7 +134,8 @@ describe 'i18n-tasks' do
|
|
134
134
|
describe 'find' do
|
135
135
|
it 'prints usages' do
|
136
136
|
capture_stderr do
|
137
|
-
|
137
|
+
result = Term::ANSIColor.uncolor(run_cmd :find, arguments: ['used.*'])
|
138
|
+
expect(result).to eq(<<-TXT)
|
138
139
|
used.a 2
|
139
140
|
app/views/usages.html.slim:1 p = t 'used.a'
|
140
141
|
app/views/usages.html.slim:2 b = t 'used.a'
|
@@ -5,7 +5,7 @@ RSpec::Matchers.define :be_i18n_keys do |expected|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def extract_keys(actual)
|
8
|
-
actual = actual.split("\n").map(&:presence).compact
|
8
|
+
actual = Term::ANSIColor.uncolor(actual).split("\n").map(&:presence).compact
|
9
9
|
actual = actual[3..-2] if actual[0] = /^\s*[+-]+\s*$/
|
10
10
|
actual = actual.map { |row|
|
11
11
|
row.gsub(/(?:\s|^)\|(?:\s|$)/, ' ').gsub(/\s+/, ' ').strip.split(' ').map(&:presence).compact
|