i18n-tasks 0.9.0.rc1 → 0.9.0.rc2

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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -47
  3. data/bin/i18n-tasks +4 -0
  4. data/config/locales/en.yml +103 -103
  5. data/config/locales/ru.yml +1 -1
  6. data/i18n-tasks.gemspec +6 -5
  7. data/lib/i18n/tasks/cli.rb +10 -6
  8. data/lib/i18n/tasks/command/commander.rb +2 -2
  9. data/lib/i18n/tasks/command/commands/missing.rb +17 -5
  10. data/lib/i18n/tasks/command/option_parsers/locale.rb +8 -1
  11. data/lib/i18n/tasks/command_error.rb +1 -1
  12. data/lib/i18n/tasks/configuration.rb +12 -5
  13. data/lib/i18n/tasks/data.rb +5 -2
  14. data/lib/i18n/tasks/data/file_system_base.rb +7 -5
  15. data/lib/i18n/tasks/data/tree/siblings.rb +3 -3
  16. data/lib/i18n/tasks/data/tree/traversal.rb +9 -3
  17. data/lib/i18n/tasks/google_translation.rb +2 -2
  18. data/lib/i18n/tasks/key_pattern_matching.rb +9 -9
  19. data/lib/i18n/tasks/logging.rb +2 -2
  20. data/lib/i18n/tasks/missing_keys.rb +5 -5
  21. data/lib/i18n/tasks/scanners/file_scanner.rb +62 -0
  22. data/lib/i18n/tasks/scanners/files/caching_file_finder_provider.rb +10 -2
  23. data/lib/i18n/tasks/scanners/files/file_finder.rb +3 -3
  24. data/lib/i18n/tasks/scanners/occurrence_from_position.rb +25 -0
  25. data/lib/i18n/tasks/scanners/pattern_scanner.rb +18 -62
  26. data/lib/i18n/tasks/scanners/pattern_with_scope_scanner.rb +3 -10
  27. data/lib/i18n/tasks/scanners/relative_keys.rb +28 -28
  28. data/lib/i18n/tasks/scanners/results/key_occurrences.rb +53 -0
  29. data/lib/i18n/tasks/scanners/results/occurrence.rb +59 -0
  30. data/lib/i18n/tasks/scanners/ruby_ast_call_finder.rb +62 -0
  31. data/lib/i18n/tasks/scanners/ruby_ast_scanner.rb +193 -0
  32. data/lib/i18n/tasks/scanners/scanner.rb +3 -3
  33. data/lib/i18n/tasks/scanners/scanner_multiplexer.rb +2 -12
  34. data/lib/i18n/tasks/scanners/slim_temple_scanner.rb +24 -0
  35. data/lib/i18n/tasks/scanners/temple_scanner.rb +33 -0
  36. data/lib/i18n/tasks/used_keys.rb +67 -43
  37. data/lib/i18n/tasks/version.rb +1 -1
  38. data/templates/config/i18n-tasks.yml +2 -5
  39. metadata +46 -108
  40. data/.coveralls.yml +0 -1
  41. data/.gitattributes +0 -2
  42. data/.gitignore +0 -35
  43. data/.travis.yml +0 -18
  44. data/CHANGES.md +0 -351
  45. data/Gemfile +0 -13
  46. data/config/i18n-tasks.yml +0 -22
  47. data/lib/i18n/tasks/scanners/key_occurrences.rb +0 -35
  48. data/lib/i18n/tasks/scanners/occurence.rb +0 -50
  49. data/spec/commands/data_commands_spec.rb +0 -38
  50. data/spec/commands/tree_commands_spec.rb +0 -69
  51. data/spec/conservative_router_spec.rb +0 -50
  52. data/spec/file_system_data_spec.rb +0 -101
  53. data/spec/fixtures/app/assets/javascripts/application.js +0 -3
  54. data/spec/fixtures/app/controllers/events_controller.rb +0 -38
  55. data/spec/fixtures/app/views/index.html.slim +0 -29
  56. data/spec/fixtures/app/views/relative/index.html.slim +0 -3
  57. data/spec/fixtures/app/views/usages.html.slim +0 -2
  58. data/spec/fixtures/config/i18n-tasks.yml +0 -63
  59. data/spec/fixtures/lib/test_i18n_plugin.rb +0 -12
  60. data/spec/google_translate_spec.rb +0 -69
  61. data/spec/i18n_spec.rb +0 -17
  62. data/spec/i18n_tasks_spec.rb +0 -302
  63. data/spec/key_pattern_matching_spec.rb +0 -63
  64. data/spec/locale_pathname_spec.rb +0 -24
  65. data/spec/locale_tree/siblings_spec.rb +0 -115
  66. data/spec/pattern_scanner_spec.rb +0 -57
  67. data/spec/plural_keys_spec.rb +0 -44
  68. data/spec/readme_spec.rb +0 -9
  69. data/spec/relative_keys_spec.rb +0 -103
  70. data/spec/scanners/files/caching_file_finder_provider_spec.rb +0 -18
  71. data/spec/scanners/files/caching_file_finder_spec.rb +0 -39
  72. data/spec/scanners/files/caching_file_reader_spec.rb +0 -18
  73. data/spec/scanners/files/file_finder_spec.rb +0 -52
  74. data/spec/scanners/files/file_reader_spec.rb +0 -15
  75. data/spec/scanners/scanner_multiplexer_spec.rb +0 -26
  76. data/spec/spec_helper.rb +0 -24
  77. data/spec/split_key_spec.rb +0 -33
  78. data/spec/support/capture_std.rb +0 -22
  79. data/spec/support/fixtures.rb +0 -14
  80. data/spec/support/i18n_tasks_output_matcher.rb +0 -37
  81. data/spec/support/key_pattern_matcher.rb +0 -7
  82. data/spec/support/keys_and_occurrences.rb +0 -27
  83. data/spec/support/test_codebase.rb +0 -82
  84. data/spec/support/trees.rb +0 -20
  85. data/spec/used_keys_spec.rb +0 -74
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 032b4f63664580dc57f296ae0379fc282bdadf26
4
- data.tar.gz: 217065770a8d92a96b8cf9009ddb7d2dc7dfea30
3
+ metadata.gz: d6bf06f3a6c91c128dd0f3323f4ec13f462c6378
4
+ data.tar.gz: 820875215de90ebc773b2abf25144fd8107fa953
5
5
  SHA512:
6
- metadata.gz: f20aadc5aa981419c3b6e5641ba3f18c8012d533b54d1e7a7df4490e56b1fe8d60bb2bb8bd7422e61534ac05ec16f3983bd1f360699e1e9dcb4d262ba466b6af
7
- data.tar.gz: 34f9ab86382cf2ac7c307d4106c2eb470dc270ad97b72a8d4d462d5f5116a7651aa849624623bcbb0a68d48dd25c4775fe113db560395df7196ca44bcc7a88f3
6
+ metadata.gz: e6b2821d3a098e3fbd371c5909d1f9858c70a2627b41f9863ece9cd5b3b2b142430dd081613d1c29dbc6ab5e72d3c9036e6fae603a6d5f8aee5d1273524f9262
7
+ data.tar.gz: 01841c0c2850a891620310c7a99a682c7b7afdd798701fbc44d317f6961cb600c0897d67b99263d85e80e13c94de4f4b21d9ea8500e4d0f571b0f0a6cf918d33
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  i18n-tasks helps you find and manage missing and unused translations.
6
6
 
7
- <img width="539" height="331" src="https://raw.github.com/glebm/i18n-tasks/master/doc/img/i18n-tasks.png">
7
+ <img width="539" height="331" src="https://i.imgur.com/XZBd8l7.png">
8
8
 
9
9
  This gem analyses code statically for key usages, such as `I18n.t('some.key')`, in order to:
10
10
 
@@ -24,7 +24,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
24
24
  Add i18n-tasks to the Gemfile:
25
25
 
26
26
  ```ruby
27
- gem 'i18n-tasks', '~> 0.9.0.rc1'
27
+ gem 'i18n-tasks', '~> 0.9.0.rc2'
28
28
  ```
29
29
 
30
30
  Copy the default [configuration file](#configuration):
@@ -72,7 +72,7 @@ $ i18n-tasks add-missing --help
72
72
  Usage: i18n-tasks add-missing [options] [locale ...]
73
73
  -l, --locales Comma-separated list of locale(s) to process. Default: all. Special: base.
74
74
  -f, --format Output format: terminal-table, yaml, json, keys, inspect. Default: terminal-table.
75
- -v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}. Default: %{value_or_human_key}.
75
+ -v, --value Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}, %{key}. Default: %{value_or_human_key}.
76
76
  -h, --help Display this help message.
77
77
  ```
78
78
 
@@ -96,7 +96,7 @@ $ i18n-tasks find 'auth.*'
96
96
  $ i18n-tasks find '{number,currency}.format.*'
97
97
  ```
98
98
 
99
- <img width="437" height="129" src="https://raw.github.com/glebm/i18n-tasks/master/doc/img/i18n-usages.png">
99
+ <img width="437" height="129" src="https://i.imgur.com/VxBrSfY.png">
100
100
 
101
101
  ### Remove unused keys
102
102
 
@@ -145,9 +145,11 @@ See the full list of tasks with `i18n-tasks --help`.
145
145
 
146
146
  ### Features and limitations
147
147
 
148
+ `i18n-tasks` uses an AST scanner for `.rb` files, and a regexp-based scanner for other files, such as `.haml`.
149
+
148
150
  #### Relative keys
149
151
 
150
- `i18n-tasks` offers partial support for relative keys, such as `t '.title'`.
152
+ `i18n-tasks` offers support for relative keys, such as `t '.title'`.
151
153
 
152
154
  ✔ Keys relative to the file path they are used in (see [relative roots configuration](#usage-search)) are supported.
153
155
 
@@ -159,23 +161,17 @@ See the full list of tasks with `i18n-tasks --help`.
159
161
 
160
162
  #### `t()` keyword arguments
161
163
 
162
- ✔ `scope` keyword argument is supported, but only when it is the first argument.
163
-
164
- ✘ `default` and other arguments are not supported.
164
+ ✔ `scope` keyword argument is fully supported by the AST scanner, and also by the Regexp scanner but only when it is the first argument.
165
165
 
166
- Parsing keyword arguments correctly with Regexp is difficult. This can be improved with an s-expression parser.
166
+ `default` argument can be used to pre-fill locale files (AST scanner only).
167
167
 
168
168
  #### Dynamic keys
169
169
 
170
- By default, unused report will detect some dynamic keys and not report them, e.g.:
171
-
172
- ```ruby
173
- t 'category.' + category.key # all 'category.:' keys considered used (: denotes one key segment)
174
- t "category.#{category.key}.name" # all 'category.:.name' keys considered used
175
- ```
170
+ By default, dynamic keys such as `t "cats.#{cat}.name"` are not recognized.
171
+ I encourage you to mark these with [i18n-tasks-use hints](#fine-tuning).
176
172
 
177
- This will not be on by default in future versions, in favour of encouraging explicit [i18n-tasks-use hints](#fine-tuning).
178
- For now, you can disable dynamic key inference by passing `-s` or `--strict` to `unused` tasks.
173
+ Alternatively, you can enable dynamic key inference by setting `search.strict` to `false` in the config. In this case,
174
+ all the dynamic parts of the key will be considered used, e.g. `cats.tenderlove.name` would not be reported as unused.
179
175
 
180
176
  ## Configuration
181
177
 
@@ -256,7 +252,7 @@ If you have implemented a custom adapter please share it on [the wiki][wiki].
256
252
  ### Usage search
257
253
 
258
254
  See the `search` section in the [config file][config] for all available configuration options.
259
- An example of a custom scanner can be found here: https://github.com/glebm/i18n-tasks/issues/138#issuecomment-87255708.
255
+ Custom scanners are easy to add, an example of one can be found [here](https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example).
260
256
 
261
257
  ### Fine-tuning
262
258
 
@@ -305,34 +301,7 @@ $ i18n-tasks xlsx-report
305
301
  ## Add new tasks
306
302
 
307
303
  Tasks that come with the gem are defined in [lib/i18n/tasks/command/commands](lib/i18n/tasks/command/commands).
308
-
309
- Add a custom task like the ones defined by the gem:
310
-
311
- ```ruby
312
- # my_commands.rb
313
- module MyCommands
314
- include ::I18n::Tasks::Command::Collection
315
- cmd :my_task, desc: 'my custom task'
316
- def my_task(opts = {})
317
- end
318
- end
319
- ```
320
-
321
- ```yaml
322
- # config/i18n-tasks.yml
323
- <%
324
- require './my_commands'
325
- I18n::Tasks::Commands.send :include, MyCommands
326
- %>
327
- ```
328
-
329
- Run with:
330
-
331
- ```console
332
- $ i18n-tasks my-task
333
- ```
334
-
335
- See more examples of custom tasks [on the wiki](https://github.com/glebm/i18n-tasks/wiki#custom-tasks).
304
+ Custom tasks can be added easily, see the examples [on the wiki](https://github.com/glebm/i18n-tasks/wiki#custom-tasks).
336
305
 
337
306
  [MIT license]: /LICENSE.txt
338
307
  [travis]: https://travis-ci.org/glebm/i18n-tasks
@@ -346,5 +315,6 @@ See more examples of custom tasks [on the wiki](https://github.com/glebm/i18n-ta
346
315
  [config]: https://github.com/glebm/i18n-tasks/blob/master/templates/config/i18n-tasks.yml
347
316
  [wiki]: https://github.com/glebm/i18n-tasks/wiki "i18n-tasks wiki"
348
317
  [i18n-gem]: https://github.com/svenfuchs/i18n "svenfuchs/i18n on Github"
349
- [screenshot-find]: https://raw.github.com/glebm/i18n-tasks/master/doc/img/i18n-usages.png "i18n-tasks find output screenshot"
318
+ [screenshot-i18n-tasks]: https://i.imgur.com/XZBd8l7.png "i18n-tasks screenshot"
319
+ [screenshot-find]: https://i.imgur.com/VxBrSfY.png "i18n-tasks find output screenshot"
350
320
  [adapter-example]: https://github.com/glebm/i18n-tasks/blob/master/lib/i18n/tasks/data/file_system_base.rb
data/bin/i18n-tasks CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ if ENV['I18N_TASKS_BIN_SIMPLECOV_COVERAGE']
4
+ require_relative '../spec/bin_simplecov_helper'
5
+ end
6
+
3
7
  # prevent i18n gem warning
4
8
  require 'i18n'
5
9
  i18n_gem_config = I18n.config
@@ -1,103 +1,103 @@
1
- ---
2
- en:
3
- i18n_tasks:
4
- add_missing:
5
- added:
6
- one: Added %{count} key
7
- other: Added %{count} keys
8
- cmd:
9
- args:
10
- default_text: 'Default: %{value}'
11
- desc:
12
- confirm: Confirm automatically
13
- data_format: 'Data format: %{valid_text}.'
14
- key_pattern: Filter by key pattern (e.g. 'common.*')
15
- key_pattern_to_rename: Full key (pattern) to rename. Required
16
- locale: Locale
17
- locale_to_translate_from: Locale to translate from
18
- locales_filter: 'Locale(s) to process. Special: base'
19
- missing_types: 'Filter by types: %{valid}'
20
- new_key_name: New name, interpolates original name as %{key}. Required
21
- nostdin: Do not read from stdin
22
- out_format: 'Output format: %{valid_text}'
23
- pattern_router: 'Use pattern router: keys moved per config data.write'
24
- strict: Avoid inferring dynamic key usages such as t("cats.#{cat}.name"). Takes precedence over the
25
- config setting if set.
26
- value: 'Value. Interpolates: %{value}, %{human_key}, %{value_or_human_key}'
27
- desc:
28
- add_missing: add missing keys to locale data
29
- config: display i18n-tasks configuration
30
- data: show locale data
31
- data_merge: merge locale data with trees
32
- data_remove: remove keys present in tree from data
33
- data_write: replace locale data with tree
34
- eq_base: show translations equal to base value
35
- find: show where keys are used in the code
36
- gem_path: show path to the gem
37
- health: is everything OK?
38
- irb: start REPL session within i18n-tasks context
39
- missing: show missing translations
40
- normalize: 'normalize translation data: sort and move to the right files'
41
- remove_unused: remove unused keys
42
- translate_missing: translate missing keys with Google Translate
43
- tree_convert: convert tree between formats
44
- tree_filter: filter tree by key pattern
45
- tree_merge: merge trees
46
- tree_rename_key: rename tree node
47
- tree_set_value: set values of keys, optionally match a pattern
48
- tree_subtract: tree A minus the keys in tree B
49
- tree_translate: Google Translate a tree to root locales
50
- unused: show unused translations
51
- xlsx_report: save missing and unused translations to an Excel file
52
- encourage:
53
- - Good job!
54
- - Well done!
55
- - Perfect!
56
- enum_list_opt:
57
- invalid: "%{invalid} is not in: %{valid}."
58
- enum_opt:
59
- invalid: "%{invalid} is not one of: %{valid}."
60
- errors:
61
- invalid_format: 'invalid format: %{invalid}. valid: %{valid}.'
62
- invalid_locale: 'invalid locale: %{invalid}'
63
- invalid_missing_type:
64
- one: 'invalid type: %{invalid}. valid: %{valid}.'
65
- other: 'unknown types: %{invalid}. valid: %{valid}.'
66
- pass_forest: pass locale forest
67
- common:
68
- base_value: Base Value
69
- continue_q: Continue?
70
- key: Key
71
- locale: Locale
72
- n_more: "%{count} more"
73
- type: Type
74
- value: Value
75
- data_stats:
76
- text: has %{key_count} keys across %{locale_count} locales. On average, values are %{value_chars_avg}
77
- characters long, keys have %{key_segments_avg} segments, a locale has %{per_locale_avg} keys.
78
- text_single_locale: has %{key_count} keys in total. On average, values are %{value_chars_avg}
79
- characters long, keys have %{key_segments_avg} segments.
80
- title: Forest (%{locales})
81
- google_translate:
82
- errors:
83
- no_api_key: Set Google API key via GOOGLE_TRANSLATE_API_KEY environment variable or translation.api_key
84
- in config/i18n-tasks.yml. Get the key at https://code.google.com/apis/console.
85
- no_results: Google Translate returned no results. Make sure billing information is set at
86
- https://code.google.com/apis/console.
87
- health:
88
- no_keys_detected: No keys detected. Check data.read in config/i18n-tasks.yml.
89
- missing:
90
- details_title: Value in other locales or source
91
- none: No translations are missing.
92
- remove_unused:
93
- confirm:
94
- one: "%{count} translation will be removed from %{locales}."
95
- other: "%{count} translation will be removed from %{locales}."
96
- noop: No unused keys to remove
97
- removed: Removed %{count} keys
98
- translate_missing:
99
- translated: Translated %{count} keys
100
- unused:
101
- none: Every translation is in use.
102
- usages:
103
- none: No key usages found.
1
+ ---
2
+ en:
3
+ i18n_tasks:
4
+ add_missing:
5
+ added:
6
+ one: Added %{count} key
7
+ other: Added %{count} keys
8
+ cmd:
9
+ args:
10
+ default_text: 'Default: %{value}'
11
+ desc:
12
+ confirm: Confirm automatically
13
+ data_format: 'Data format: %{valid_text}.'
14
+ key_pattern: Filter by key pattern (e.g. 'common.*')
15
+ key_pattern_to_rename: Full key (pattern) to rename. Required
16
+ locale: Locale
17
+ locale_to_translate_from: Locale to translate from
18
+ locales_filter: 'Locale(s) to process. Special: base'
19
+ missing_types: 'Filter by types: %{valid}'
20
+ new_key_name: New name, interpolates original name as %{key}. Required
21
+ nostdin: Do not read from stdin
22
+ out_format: 'Output format: %{valid_text}'
23
+ pattern_router: 'Use pattern router: keys moved per config data.write'
24
+ strict: Avoid inferring dynamic key usages such as t("cats.#{cat}.name"). Takes precedence over the
25
+ config setting if set.
26
+ value: 'Value. Interpolates: %{value}, %{human_key}, %{key}, %{default}, %{value_or_human_key}, %{value_or_default_or_human_key}'
27
+ desc:
28
+ add_missing: add missing keys to locale data
29
+ config: display i18n-tasks configuration
30
+ data: show locale data
31
+ data_merge: merge locale data with trees
32
+ data_remove: remove keys present in tree from data
33
+ data_write: replace locale data with tree
34
+ eq_base: show translations equal to base value
35
+ find: show where keys are used in the code
36
+ gem_path: show path to the gem
37
+ health: is everything OK?
38
+ irb: start REPL session within i18n-tasks context
39
+ missing: show missing translations
40
+ normalize: 'normalize translation data: sort and move to the right files'
41
+ remove_unused: remove unused keys
42
+ translate_missing: translate missing keys with Google Translate
43
+ tree_convert: convert tree between formats
44
+ tree_filter: filter tree by key pattern
45
+ tree_merge: merge trees
46
+ tree_rename_key: rename tree node
47
+ tree_set_value: set values of keys, optionally match a pattern
48
+ tree_subtract: tree A minus the keys in tree B
49
+ tree_translate: Google Translate a tree to root locales
50
+ unused: show unused translations
51
+ xlsx_report: save missing and unused translations to an Excel file
52
+ encourage:
53
+ - Good job!
54
+ - Well done!
55
+ - Perfect!
56
+ enum_list_opt:
57
+ invalid: "%{invalid} is not in: %{valid}."
58
+ enum_opt:
59
+ invalid: "%{invalid} is not one of: %{valid}."
60
+ errors:
61
+ invalid_format: 'invalid format: %{invalid}. valid: %{valid}.'
62
+ invalid_locale: 'invalid locale: %{invalid}'
63
+ invalid_missing_type:
64
+ one: 'invalid type: %{invalid}. valid: %{valid}.'
65
+ other: 'unknown types: %{invalid}. valid: %{valid}.'
66
+ pass_forest: pass locale forest
67
+ common:
68
+ base_value: Base Value
69
+ continue_q: Continue?
70
+ key: Key
71
+ locale: Locale
72
+ n_more: "%{count} more"
73
+ type: Type
74
+ value: Value
75
+ data_stats:
76
+ text: has %{key_count} keys across %{locale_count} locales. On average, values are %{value_chars_avg}
77
+ characters long, keys have %{key_segments_avg} segments, a locale has %{per_locale_avg} keys.
78
+ text_single_locale: has %{key_count} keys in total. On average, values are %{value_chars_avg}
79
+ characters long, keys have %{key_segments_avg} segments.
80
+ title: Forest (%{locales})
81
+ google_translate:
82
+ errors:
83
+ no_api_key: Set Google API key via GOOGLE_TRANSLATE_API_KEY environment variable or translation.api_key
84
+ in config/i18n-tasks.yml. Get the key at https://code.google.com/apis/console.
85
+ no_results: Google Translate returned no results. Make sure billing information is set at
86
+ https://code.google.com/apis/console.
87
+ health:
88
+ no_keys_detected: No keys detected. Check data.read in config/i18n-tasks.yml.
89
+ missing:
90
+ details_title: Value in other locales or source
91
+ none: No translations are missing.
92
+ remove_unused:
93
+ confirm:
94
+ one: "%{count} translation will be removed from %{locales}."
95
+ other: "%{count} translation will be removed from %{locales}."
96
+ noop: No unused keys to remove
97
+ removed: Removed %{count} keys
98
+ translate_missing:
99
+ translated: Translated %{count} keys
100
+ unused:
101
+ none: Every translation is in use.
102
+ usages:
103
+ none: No key usages found.
@@ -21,7 +21,7 @@ ru:
21
21
  out_format: "Формат вывода: %{valid_text}. %{default_text}."
22
22
  pattern_router: "Использовать pattern_router: ключи распределятся по файлам согласно data.write"
23
23
  strict: Не угадывать динамические использования ключей, например `t("category.#{category.key}")`
24
- value: "Значение, интерполируется с %{value}, %{human_key}, %{value_or_human_key}"
24
+ value: "Значение, интерполируется с %{value}, %{human_key}, %{key}, %{default}, %{value_or_human_key}, %{value_or_default_or_human_key}"
25
25
  desc:
26
26
  add_missing: "добавить недостающие ключи к переводам"
27
27
  config: "показать конфигурацию"
data/i18n-tasks.gemspec CHANGED
@@ -27,18 +27,19 @@ TEXT
27
27
  s.license = 'MIT'
28
28
 
29
29
  s.files = `git ls-files`.split($/)
30
- s.files -= s.files.grep(%r{^doc/img/})
31
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
30
+ s.files -= s.files.grep(%r{^(doc/|\.|spec/)}) + %w(CHANGES.md config/i18n-tasks.yml Gemfile)
31
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) } - %w(i18n-tasks.cmd)
32
32
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
33
33
  s.require_paths = ['lib']
34
34
 
35
- s.add_dependency 'erubis'
36
35
  s.add_dependency 'activesupport', '>= 4.0.2'
37
36
  s.add_dependency 'easy_translate', '>= 0.5.0'
38
- s.add_dependency 'term-ansicolor', '>= 1.3.2'
39
- s.add_dependency 'terminal-table', '>= 1.5.1'
37
+ s.add_dependency 'erubis'
40
38
  s.add_dependency 'highline', '>= 1.7.3'
41
39
  s.add_dependency 'i18n'
40
+ s.add_dependency 'parser', '>= 2.2.2.6'
41
+ s.add_dependency 'term-ansicolor', '>= 1.3.2'
42
+ s.add_dependency 'terminal-table', '>= 1.5.1'
42
43
  s.add_development_dependency 'axlsx', '~> 2.0'
43
44
  s.add_development_dependency 'bundler', '~> 1.3'
44
45
  s.add_development_dependency 'rake'
@@ -50,7 +50,7 @@ class I18n::Tasks::CLI
50
50
  base_task
51
51
  @commands ||= ::I18n::Tasks::Commands.cmds.dup.tap do |cmds|
52
52
  # Hash#transform_keys is only available since activesupport v4.0.0
53
- cmds.keys.each { |k| cmds[k.to_s.tr('_', '-')] = cmds.delete(k) }
53
+ cmds.keys.each { |k| cmds[k.to_s.tr('_'.freeze, '-'.freeze)] = cmds.delete(k) }
54
54
  end
55
55
  end
56
56
 
@@ -64,7 +64,7 @@ class I18n::Tasks::CLI
64
64
  command = parse_command! argv
65
65
  options = optparse! command, argv
66
66
  parse_options! options, command, argv
67
- [command.tr('-', '_'), options.update(arguments: argv)]
67
+ [command.tr('-'.freeze, '_'.freeze), options.update(arguments: argv)]
68
68
  end
69
69
 
70
70
  def optparse!(command, argv)
@@ -103,12 +103,14 @@ class I18n::Tasks::CLI
103
103
 
104
104
  def allow_help_arg_first!(argv)
105
105
  # allow `i18n-tasks --help command` in addition to `i18n-tasks command --help`
106
- argv[0], argv[1] = argv[1], argv[0] if %w(-h --help).include?(argv[0]) && argv[1] && !argv[1].start_with?('-')
106
+ if %w(-h --help).include?(argv[0]) && argv[1] && !argv[1].start_with?('-'.freeze)
107
+ argv[0], argv[1] = argv[1], argv[0]
108
+ end
107
109
  end
108
110
 
109
111
  def parse_command!(argv)
110
112
  allow_help_arg_first! argv
111
- if argv[0] && !argv[0].start_with?('-')
113
+ if argv[0] && !argv[0].start_with?('-'.freeze)
112
114
  if commands.keys.include?(argv[0])
113
115
  argv.shift
114
116
  else
@@ -162,7 +164,7 @@ class I18n::Tasks::CLI
162
164
  def parse_option(flag, val, argv, context)
163
165
  conf = flag.last.is_a?(Hash) ? flag.last : {}
164
166
  if conf[:consume_positional]
165
- val = Array(val) + Array(flag.include?(Array) ? argv.flat_map { |x| x.split(',') } : argv)
167
+ val = Array(val) + Array(flag.include?(Array) ? argv.flat_map { |x| x.split(','.freeze) } : argv)
166
168
  end
167
169
  val = conf[:default] if val.nil? && conf.key?(:default)
168
170
  val = conf[:parser].call(val, context) if conf.key?(:parser)
@@ -170,7 +172,9 @@ class I18n::Tasks::CLI
170
172
  end
171
173
 
172
174
  def option_name(flag)
173
- flag.detect { |f| f.start_with?('--') }.sub(/\A--(\[no-\])?/, '').sub(/[^\-\w].*\z/, '').to_sym
175
+ flag.detect { |f|
176
+ f.start_with?('--'.freeze)
177
+ }.sub(/\A--(\[no-\])?/, ''.freeze).sub(/[^\-\w].*\z/, ''.freeze).to_sym
174
178
  end
175
179
 
176
180
  def try_call(v)