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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5b450d463f4c435b2c29cb8625c0fc3b2f1f0fc
4
- data.tar.gz: 8f3a640623471a782e3a3321aae671f51bf4c94d
3
+ metadata.gz: 7b205200e5f46e458947cd7efa0a3f4781555bed
4
+ data.tar.gz: 3c233c02ca02b64ce1e5b02d2e068bbee0b1db2a
5
5
  SHA512:
6
- metadata.gz: 6d95d020a9f643480f5e8022b69976355aafe6ed66955eeeb12a25f12c3aa4bce11f3d10e5807c29636690f087f289e089b21fc0634b251b26090f83690037a5
7
- data.tar.gz: 0f2186c5897c723eb587af3471214c6b372590ce8f79e615aeb32afb7627aba003772061a44f2165908aeb000bd2067a64d077bbd7395fd85f04ef2d86617b64
6
+ metadata.gz: 774d211a16131bcfbf7df07fdb9a0fd7d4926d227df2bb499772af12e12b77f1911dc0b9cf6e39d4f232ed41feb3bbf86781e9ca6d364b7b4d70894690f0b864
7
+ data.tar.gz: bc56dfc3f345175e329904430678ddbafefcb85a73c068055cd31062dec2b8bd7ab0d6ddb924af410222bdb17b709dd6821ecbadff7b0a9668c9f20a9da9b497
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.5
2
+
3
+ * Respect tty color setting
4
+
1
5
  ## 0.4.4
2
6
 
3
7
  * Fix google translate issues with plural keys and translating from non-base locale
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.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.puts Term::ANSIColor.yellow('i18n-tasks: ' + message)
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
 
@@ -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
- STDERR.puts Term::ANSIColor.red Term::ANSIColor.bold message
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
@@ -1,6 +1,7 @@
1
1
  # coding: utf-8
2
2
  module I18n::Tasks::Reports
3
3
  class Base
4
+ include I18n::Tasks::Logging
4
5
 
5
6
  def initialize(task = I18n::Tasks::BaseTask.new)
6
7
  @task = task
@@ -70,19 +70,19 @@ module I18n
70
70
  private
71
71
 
72
72
  def print_title(title)
73
- print_info "#{bold cyan title.strip} #{dark "|"} #{bold "i18n-tasks v#{I18n::Tasks::VERSION}"}"
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
- print_info(bold green message)
77
+ log_stderr(bold green message)
78
78
  end
79
79
 
80
80
  def print_error(message)
81
- print_info(bold red message)
81
+ log_stderr(bold red message)
82
82
  end
83
-
84
- def print_info(*args)
85
- $stderr.puts(*args)
83
+
84
+ def print_info(message)
85
+ log_stderr message
86
86
  end
87
87
 
88
88
  def indent(txt, n = 2)
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module I18n
3
3
  module Tasks
4
- VERSION = '0.4.4'
4
+ VERSION = '0.4.5'
5
5
  end
6
6
  end
@@ -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
- expect(run_cmd :find, arguments: ['used.*']).to eq(<<-TXT)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm