i18n-tasks 1.0.1 → 1.0.2
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66781586bda6c38de2ca767c265c7e1fbaf6e11184997f00a77c215e2270a7d7
|
4
|
+
data.tar.gz: 3a94d73244c34887758d208cdc807a930467ac6cde95545dea6acdbed5563c36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
27
|
+
gem 'i18n-tasks', '~> 1.0.2'
|
28
28
|
```
|
29
29
|
|
30
30
|
Copy the default [configuration file](#configuration):
|
@@ -4,14 +4,23 @@ require 'parser/current'
|
|
4
4
|
|
5
5
|
module I18n::Tasks::Scanners
|
6
6
|
class LocalRubyParser
|
7
|
-
|
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 =
|
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}
|
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)
|
data/lib/i18n/tasks/version.rb
CHANGED