google_translate_diff 1.0.8 → 1.0.9
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc126f78f09507a6cdfe8116479b3629d0eac062
|
4
|
+
data.tar.gz: a92719bc7447df9c530127ec0ce48e4f3e341329
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d120b67393f006ced3d955ece7afcc9913d7d6c43c4421ee8f87e7f5028743c0b7bfc6add578ccb2ea59bc814a76e7e51a9e04294676c1ae427ff59c433fe4a
|
7
|
+
data.tar.gz: d7230c98ea93cfc03de94a0496779e14ef3abb7fe70d4cca769a72a8708b08539222e4e369e0423b8ddcd870a995f0608dc83ccbd88b6cbaac95ea3e53944f0a
|
@@ -2,7 +2,7 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
|
|
2
2
|
def initialize(source)
|
3
3
|
@pos = nil
|
4
4
|
@source = source
|
5
|
-
@tokens =
|
5
|
+
@tokens = nil
|
6
6
|
@context = []
|
7
7
|
@sequence = []
|
8
8
|
@indicies = []
|
@@ -27,14 +27,15 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
|
|
27
27
|
@sequence[-1] = :notranslate
|
28
28
|
end
|
29
29
|
|
30
|
-
def text(
|
30
|
+
def text(value)
|
31
|
+
return if value == ""
|
31
32
|
@sequence << (SKIP.include?(@context.last) ? :markup : :text)
|
32
33
|
@indicies << @pos - 1
|
33
34
|
end
|
34
35
|
|
35
36
|
# rubocop:disable Metrics/AbcSize
|
36
37
|
def tokens
|
37
|
-
raw_tokens.each_with_object([]) do |token, tokens|
|
38
|
+
@tokens ||= raw_tokens.each_with_object([]) do |token, tokens|
|
38
39
|
if tokens.empty?
|
39
40
|
tokens << token
|
40
41
|
elsif tokens.last[1] == token[1]
|
@@ -70,7 +71,7 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
|
|
70
71
|
# rubocop:enable Metrics/MethodLength
|
71
72
|
|
72
73
|
def raw_tokens
|
73
|
-
@indicies.map.with_index do |i, n|
|
74
|
+
@raw_tokens ||= @indicies.map.with_index do |i, n|
|
74
75
|
first = i
|
75
76
|
last = (@indicies[n + 1] || 0) - 1
|
76
77
|
value = fix_utf(@source.byteslice(first..last))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_translate_diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Sokolov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.6.
|
199
|
+
rubygems_version: 2.6.13
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Google Translate API wrapper for Ruby which helps to translate only changes
|