i18n-tasks 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/i18n/tasks/scanners/erb_ast_processor.rb +1 -1
- data/lib/i18n/tasks/scanners/erb_ast_scanner.rb +1 -1
- data/lib/i18n/tasks/scanners/local_ruby_parser.rb +13 -2
- data/lib/i18n/tasks/scanners/results/occurrence.rb +1 -1
- data/lib/i18n/tasks/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adca7ca6bf65af74c2a4e88e30179281471f1b391a9dec1885031f6e4b5d104c
|
4
|
+
data.tar.gz: 82bfb0f4dd4d614fc93b34427e9e4d6aee2c2e3f9a9115d3b89bb1938edfeb8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac7dfdb7bcfa4ccf412b9afeb5d309d86d6a49dbbfe6c39d2128aff5e5cf8b1ee29cc8a7089975e1c0677c79c63985f19ebf6175010e9a7e21e02ebf2aca3323
|
7
|
+
data.tar.gz: f05bc85a3df41d6eb857fb3f52f20328093c28ee3595c5dc3acbbbab8a2dfd5462712052e6237b53cff2f53c5971f006dd5a840fc09987ef6b246d5a4b6fd214
|
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.3'
|
28
28
|
```
|
29
29
|
|
30
30
|
Copy the default [configuration file](#configuration):
|
@@ -223,7 +223,7 @@ See the full list of tasks with `i18n-tasks --help`.
|
|
223
223
|
|
224
224
|
### Features and limitations
|
225
225
|
|
226
|
-
`i18n-tasks` uses an AST scanner for `.rb` files, and a regexp-based scanner for other files, such as `.haml`.
|
226
|
+
`i18n-tasks` uses an AST scanner for `.rb` and `.html.erb` files, and a regexp-based scanner for other files, such as `.haml`.
|
227
227
|
|
228
228
|
#### Relative keys
|
229
229
|
|
@@ -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)
|
@@ -43,6 +52,8 @@ module I18n::Tasks::Scanners
|
|
43
52
|
# @param local_location {Parser::Source::Map} Local location in the parsed string
|
44
53
|
# @return {Parser::Source::Map}
|
45
54
|
def updated_location(global_location, local_location)
|
55
|
+
return global_location if local_location.expression.nil?
|
56
|
+
|
46
57
|
range = ::Parser::Source::Range.new(
|
47
58
|
global_location.expression.source_buffer,
|
48
59
|
global_location.expression.to_range.begin + local_location.expression.to_range.begin,
|
@@ -48,7 +48,7 @@ module I18n::Tasks
|
|
48
48
|
# rubocop:enable Metrics/ParameterLists
|
49
49
|
|
50
50
|
def inspect
|
51
|
-
"Occurrence(#{@path}:#{@line_num}
|
51
|
+
"Occurrence(#{@path}:#{@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
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|