i18n-tasks 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: 053f1f934ed84abbf4f86a11762c37c78cc286f8f809d3c8c5ca2918af57cb2a
4
- data.tar.gz: 0f70179fa394de1faafc750185774d9a47f359de6b41c8542e038e8189933186
3
+ metadata.gz: 66781586bda6c38de2ca767c265c7e1fbaf6e11184997f00a77c215e2270a7d7
4
+ data.tar.gz: 3a94d73244c34887758d208cdc807a930467ac6cde95545dea6acdbed5563c36
5
5
  SHA512:
6
- metadata.gz: 45934bf36576b5dfdf8e88f019779603ddcfe989c4d6ce5c3da75d07571b5097b1f06a7147663fadaef4995532d3d2661fc1733e2bf49396820202c14d33c005
7
- data.tar.gz: 4853657f6fb46102d63d4a6f44ca0b07e3915ab7029369c815ec7530654973af30aee1184d826cc2df1a4a8c393525a3afa05005ef30aaabcf14435a66f693e6
6
+ metadata.gz: b51f3bf32fc208a9845b79f9a074ed2bcd2f0ff648309b93dbf7431df7154103a63c298bdb197cfae611012423d315df1552ad600a20135dfd76592df5d853d8
7
+ data.tar.gz: 4cc284d8c283c4159333310f4deb2e78ec064f60c024ccdadd4007d883955ca08d1e765b69529744dff2f953973d3cab6ff46138919c5cc41c3c4f986ea2a88a
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', '~> 1.0.1'
27
+ gem 'i18n-tasks', '~> 1.0.2'
28
28
  ```
29
29
 
30
30
  Copy the default [configuration file](#configuration):
@@ -9,7 +9,7 @@ module I18n::Tasks::Scanners
9
9
  include AST::Processor::Mixin
10
10
  def initialize
11
11
  super()
12
- @ruby_parser = LocalRubyParser.new
12
+ @ruby_parser = LocalRubyParser.new(ignore_blocks: true)
13
13
  @comments = []
14
14
  end
15
15
 
@@ -4,14 +4,23 @@ require 'parser/current'
4
4
 
5
5
  module I18n::Tasks::Scanners
6
6
  class LocalRubyParser
7
- def initialize
7
+ # ignore_blocks feature inspired by shopify/better-html
8
+ # https://github.com/Shopify/better-html/blob/087943ffd2a5877fa977d71532010b0c91239519/lib/better_html/test_helper/ruby_node.rb#L24
9
+ BLOCK_EXPR = /\s*((\s+|\))do|\{)(\s*\|[^|]*\|)?\s*\Z/.freeze
10
+
11
+ def initialize(ignore_blocks: false)
8
12
  @parser = ::Parser::CurrentRuby.new
13
+ @ignore_blocks = ignore_blocks
9
14
  end
10
15
 
11
16
  # Parse string and normalize location
12
17
  def parse(source, location: nil)
13
18
  buffer = ::Parser::Source::Buffer.new('(string)')
14
- buffer.source = source
19
+ buffer.source = if @ignore_blocks
20
+ source.sub(BLOCK_EXPR, '')
21
+ else
22
+ source
23
+ end
15
24
 
16
25
  @parser.reset
17
26
  ast, comments = @parser.parse_with_comments(buffer)
@@ -48,7 +48,7 @@ module I18n::Tasks
48
48
  # rubocop:enable Metrics/ParameterLists
49
49
 
50
50
  def inspect
51
- "Occurrence(#{@path}:#{@line_num}:#{@line_pos}:#{@pos}:#{@raw_key}:#{@default_arg}:#{@line})"
51
+ "Occurrence(path: #{@path}, line_num: #{@line_num}, line_pos: #{@line_pos}, pos: #{@pos}, raw_key: #{@raw_key}, default_arg: #{@default_arg}, line: #{@line})"
52
52
  end
53
53
 
54
54
  def ==(other)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module Tasks
5
- VERSION = '1.0.1'
5
+ VERSION = '1.0.2'
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: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebm