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: 8761fef8e3824178915b5b960589d8cdeeafbf71
4
- data.tar.gz: 4838baa06669d3d301defb6bce893e33fa9a3eec
3
+ metadata.gz: bc126f78f09507a6cdfe8116479b3629d0eac062
4
+ data.tar.gz: a92719bc7447df9c530127ec0ce48e4f3e341329
5
5
  SHA512:
6
- metadata.gz: 3ff86b2bdcd522aafc078d5963a6cfee52479f802059c75407fecbbabb22f0ebf9b2636a53dcf5cc2d68e88b3a266d9a2ee508a4c56f8c1470a91b5d98fdc62c
7
- data.tar.gz: 1335fa3af8f242771609e2d5d96365a033c971c3a1c3ea85b3fb0d44ec83abc62f8763b3b440acf2a89b549620494c68e782c570f48d3ec3532e9273dcec8561
6
+ metadata.gz: 0d120b67393f006ced3d955ece7afcc9913d7d6c43c4421ee8f87e7f5028743c0b7bfc6add578ccb2ea59bc814a76e7e51a9e04294676c1ae427ff59c433fe4a
7
+ data.tar.gz: d7230c98ea93cfc03de94a0496779e14ef3abb7fe70d4cca769a72a8708b08539222e4e369e0423b8ddcd870a995f0608dc83ccbd88b6cbaac95ea3e53944f0a
@@ -19,7 +19,7 @@ class GoogleTranslateDiff::Spacing
19
19
  end
20
20
 
21
21
  def trailing(value)
22
- pos = value =~ /[[:space:]]+$/ui
22
+ pos = value =~ /[[:space:]]+\z/ui
23
23
  return "" if pos.nil?
24
24
  value[pos..-1]
25
25
  end
@@ -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))
@@ -1,3 +1,3 @@
1
1
  module GoogleTranslateDiff
2
- VERSION = "1.0.8".freeze
2
+ VERSION = "1.0.9".freeze
3
3
  end
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.8
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-09-06 00:00:00.000000000 Z
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.12
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