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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f6dc7facc584ec90bee3fd89b5222c645c0207d
4
- data.tar.gz: 0c09aea76d0b9c8494f6544c99e7b698374887dc
3
+ metadata.gz: 7cc5711c56c707bafd3ee3c344220c54976c2a7a
4
+ data.tar.gz: 8d90bbc68292fd2ee20a843f1770013542cd50bc
5
5
  SHA512:
6
- metadata.gz: b1f5f755ef3f26541331ecf6aaee38bf68958018b28bd22d94b8aa2b6e930277789d36186debb785fb7a139ec68fdf1024df8e18d5145a263a99d8c4d91f8237
7
- data.tar.gz: 976c51c8ad42d3c538713d353172b7db8bc0b519fc50cf37e613b03e665b9a19d535352138fd484aa9534a9c51e65a1a18091440b32fbc03cf21f1cbbe053553
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.14'
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] || []).each_with_object({}) do |(ext, re), h|
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
- def translate_call_re
79
- /(?<=^|[^\w'\-.]|[^\w'\-]I18n\.|I18n\.)t(?:ranslate)?/
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(receiver_messages: RECEIVER_MESSAGES, **args)
20
+ def initialize(**args)
21
21
  super(args)
22
- @parser = ::Parser::CurrentRuby.new
22
+ @parser = ::Parser::CurrentRuby.new
23
23
  @magic_comment_parser = ::Parser::CurrentRuby.new
24
- @call_finder = RubyAstCallFinder.new(receiver_messages: receiver_messages)
24
+ @call_finder = RubyAstCallFinder.new(
25
+ receiver_messages: config[:receiver_messages] || RECEIVER_MESSAGES
26
+ )
25
27
  end
26
28
 
27
29
  protected
@@ -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: %w[app/].freeze,
18
+ paths: %w[app/].freeze,
19
19
  relative_roots: %w[app/controllers app/helpers app/mailers app/presenters app/views].freeze,
20
- scanners: [['::I18n::Tasks::Scanners::RubyAstScanner', only: %w[*.rb]]],
21
- strict: true
22
- }.tap do |defaults|
23
- defaults[:scanners] << ['::I18n::Tasks::Scanners::PatternWithScopeScanner',
24
- exclude: defaults[:scanners].map { |(_, opts)| opts[:only] }.reduce(:+).freeze,
25
- ignore_lines: { 'opal' => %q(^\s*#(?!\si18n-tasks-use)),
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module Tasks
5
- VERSION = '0.9.14'
5
+ VERSION = '0.9.15'
6
6
  end
7
7
  end
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.9.14
4
+ version: 0.9.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm