i18n-tasks 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/i18n/tasks/scanners/pattern_scanner.rb +13 -4
- data/lib/i18n/tasks/scanners/ruby_ast_scanner.rb +5 -3
- data/lib/i18n/tasks/used_keys.rb +7 -12
- data/lib/i18n/tasks/version.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: 7cc5711c56c707bafd3ee3c344220c54976c2a7a
|
4
|
+
data.tar.gz: 8d90bbc68292fd2ee20a843f1770013542cd50bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71bcef7b28fe7a5ad8fcd0b0c3c69d13b15e279cd288b07616999234faea165c84c8bba2860fc76353366c7242746210264cabedc46f63ea8111c397b173db85
|
7
|
+
data.tar.gz: a603c30adaa7d37be7439bc9063da2d41406cce3a2021bbff4f6f655bb4e699ce5c72a1bc3797a997eb92fa056f0f14e55285f3c0ea57efd9a6b6a5c5bcebc29
|
data/README.md
CHANGED
@@ -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.
|
27
|
+
gem 'i18n-tasks', '~> 0.9.15'
|
28
28
|
```
|
29
29
|
|
30
30
|
Copy the default [configuration file](#configuration):
|
@@ -12,10 +12,20 @@ module I18n::Tasks::Scanners
|
|
12
12
|
include OccurrenceFromPosition
|
13
13
|
include RubyKeyLiterals
|
14
14
|
|
15
|
+
TRANSLATE_CALL_RE = /(?<=^|[^\w'\-.]|[^\w'\-]I18n\.|I18n\.)t(?:ranslate)?/
|
16
|
+
IGNORE_LINES = {
|
17
|
+
'opal' => /^\s*#(?!\si18n-tasks-use)/,
|
18
|
+
'haml' => /^\s*-\s*#(?!\si18n-tasks-use)/,
|
19
|
+
'slim' => %r{^\s*(?:-#|/)(?!\si18n-tasks-use)},
|
20
|
+
'coffee' => /^\s*#(?!\si18n-tasks-use)/,
|
21
|
+
'erb' => /^\s*<%\s*#(?!\si18n-tasks-use)/
|
22
|
+
}.freeze
|
23
|
+
|
15
24
|
def initialize(**args)
|
16
25
|
super
|
26
|
+
@translate_call_re = config[:translate_call].present? ? Regexp.new(config[:translate_call]) : TRANSLATE_CALL_RE
|
17
27
|
@pattern = config[:pattern].present? ? Regexp.new(config[:pattern]) : default_pattern
|
18
|
-
@ignore_lines_res = (config[:ignore_lines] ||
|
28
|
+
@ignore_lines_res = (config[:ignore_lines] || IGNORE_LINES).each_with_object({}) do |(ext, re), h|
|
19
29
|
h[ext.to_s] = Regexp.new(re)
|
20
30
|
end
|
21
31
|
end
|
@@ -75,9 +85,8 @@ module I18n::Tasks::Scanners
|
|
75
85
|
method && method.strip.sub(/^def\s*/, '').sub(/[\(\s;].*$/, '')
|
76
86
|
end
|
77
87
|
|
78
|
-
|
79
|
-
|
80
|
-
end
|
88
|
+
# This method only exists for backwards compatibility with monkey-patches and plugins
|
89
|
+
attr_reader :translate_call_re
|
81
90
|
|
82
91
|
def default_pattern
|
83
92
|
# capture only the first argument
|
@@ -17,11 +17,13 @@ module I18n::Tasks::Scanners
|
|
17
17
|
MAGIC_COMMENT_PREFIX = /\A.\s*i18n-tasks-use\s+/
|
18
18
|
RECEIVER_MESSAGES = [nil, AST::Node.new(:const, [nil, :I18n])].product(%i[t translate])
|
19
19
|
|
20
|
-
def initialize(
|
20
|
+
def initialize(**args)
|
21
21
|
super(args)
|
22
|
-
@parser
|
22
|
+
@parser = ::Parser::CurrentRuby.new
|
23
23
|
@magic_comment_parser = ::Parser::CurrentRuby.new
|
24
|
-
@call_finder
|
24
|
+
@call_finder = RubyAstCallFinder.new(
|
25
|
+
receiver_messages: config[:receiver_messages] || RECEIVER_MESSAGES
|
26
|
+
)
|
25
27
|
end
|
26
28
|
|
27
29
|
protected
|
data/lib/i18n/tasks/used_keys.rb
CHANGED
@@ -15,19 +15,14 @@ require 'i18n/tasks/scanners/pattern_mapper'
|
|
15
15
|
module I18n::Tasks
|
16
16
|
module UsedKeys # rubocop:disable Metrics/ModuleLength
|
17
17
|
SEARCH_DEFAULTS = {
|
18
|
-
paths:
|
18
|
+
paths: %w[app/].freeze,
|
19
19
|
relative_roots: %w[app/controllers app/helpers app/mailers app/presenters app/views].freeze,
|
20
|
-
scanners:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
'haml' => %q(^\s*-\s*#(?!\si18n-tasks-use)),
|
27
|
-
'slim' => %q(^\s*(?:-#|/)(?!\si18n-tasks-use)),
|
28
|
-
'coffee' => %q(^\s*#(?!\si18n-tasks-use)),
|
29
|
-
'erb' => %q(^\s*<%\s*#(?!\si18n-tasks-use)) }.freeze]
|
30
|
-
end
|
20
|
+
scanners: [
|
21
|
+
['::I18n::Tasks::Scanners::RubyAstScanner', only: %w[*.rb]],
|
22
|
+
['::I18n::Tasks::Scanners::PatternWithScopeScanner', exclude: %w[*.rb]]
|
23
|
+
],
|
24
|
+
strict: true
|
25
|
+
}.freeze
|
31
26
|
|
32
27
|
ALWAYS_EXCLUDE = %w[*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
|
33
28
|
*.yml *.json *.zip *.tar.gz *.swf *.flv].freeze
|
data/lib/i18n/tasks/version.rb
CHANGED