google_translate_diff 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
  SHA1:
3
- metadata.gz: 00ebbfbeaac94fc00141bbb2bfddedcfb9e733a6
4
- data.tar.gz: d73f0d12f6d2df80bd43614856113931c3209067
3
+ metadata.gz: 1886972d6b13f5558879a22a90c4b1dad5e0ef20
4
+ data.tar.gz: fba14de63dcba2f52ad7752cc38ef95c44d2bcc5
5
5
  SHA512:
6
- metadata.gz: dd4fd53436d30887c3d7d3990ef84387fbfa5b8c4b355c7258f2a05346f490cdd9288158ab910f6ee18886e5f3096f2ac1e603aeea3e64a71d897a6917233968
7
- data.tar.gz: 9e60481244ce4520439c0d0184ea6a8e0dcf587c0717be6000e94051fe1b8dd915bf30fedd5b5f4f0024227e5be03428ab29779065169c7eef9b02143d053366
6
+ metadata.gz: 43d184d364e9b85d1544306540df86bac03b9e58cd33ebbf57cbad15e3abb5c976162bb907789002104fcf9edb9eee933720b4d598aa37e61fa401b948b58ee7
7
+ data.tar.gz: 411f437b92949a07bffc122ca533f4109d9b62fbb946fc2781f4b4005892efa533563c7c4645060bbbfc7e2f7ac0b0bfaf8fc1d58545924a3be221207fea2f02
data/README.md CHANGED
@@ -37,6 +37,8 @@ Or install it yourself as:
37
37
 
38
38
  ## Usage
39
39
 
40
+ *Warning*. *Modifies `Ox.default_options`.*
41
+
40
42
  ```ruby
41
43
  require "google_translate_diff"
42
44
 
@@ -10,11 +10,11 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
10
10
  attr_reader :texts, :tokens, :prev, :pos
11
11
 
12
12
  def start_element(name)
13
- @skip = true if name == :script
13
+ @skip = true if SKIP.include?(name)
14
14
  end
15
15
 
16
16
  def end_element(name)
17
- @skip = false if name == :script
17
+ @skip = false if SKIP.include?(name)
18
18
  end
19
19
 
20
20
  def text(value)
@@ -65,10 +65,13 @@ class GoogleTranslateDiff::Tokenizer < ::Ox::Sax
65
65
  def tokenize(value)
66
66
  return [] if value.nil?
67
67
  tokenizer = new(value).tap do |h|
68
+ Ox.default_options = { mode: :generic, effort: :tolerant, smart: true }
68
69
  Ox.sax_parse(h, StringIO.new(value))
69
70
  h.cut_last_token
70
71
  end
71
72
  tokenizer.tokens
72
73
  end
73
74
  end
75
+
76
+ SKIP = %i(script style).freeze
74
77
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleTranslateDiff
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".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.1
4
+ version: 1.0.2
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-03-27 00:00:00.000000000 Z
11
+ date: 2017-05-29 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.10
199
+ rubygems_version: 2.6.12
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Google Translate API wrapper for Ruby which helps to translate only changes