wovnrb 2.0.2 → 2.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/wovnrb/services/html_converter.rb +9 -11
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/services/html_converter_test.rb +12 -12
- data/test/lib/wovnrb_test.rb +1 -1
- data/wovnrb.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ce58b69eb2db35e989b96207cb185a4dd0c14ec
|
4
|
+
data.tar.gz: a5ddf4caeb09e8aae80593150ef74602025cc60b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a2ad9c9bf3dd9db5f6c13fe2378e776a0d9ff88e566c24f9fcebe929adf0bd88fbdfbf74d117ac6615851b7e070e5dcfddb5a19866db5c5eb4b1b26b664e450
|
7
|
+
data.tar.gz: 545ec6538d2d3a95da5203759cd3f32b68b18327238d618a7bb94a299b5c95c8c23b88a0a5907e92f1429d55bdfde28aabaaf272c4f269b15bc84407cc1c8277
|
data/README.md
CHANGED
@@ -16,10 +16,10 @@ After logging into WOVN.io, add a page that you would like translated.
|
|
16
16
|
|
17
17
|
### 1.3. Ruby Application Settings
|
18
18
|
|
19
|
-
To use the WOVN.io Ruby Library, insert the following line into your Ruby Application's Gemfile. WOVN.io currently supports version 0.
|
19
|
+
To use the WOVN.io Ruby Library, insert the following line into your Ruby Application's Gemfile. WOVN.io currently supports version 2.0.1 and up.
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
gem 'wovnrb', '>= 0.
|
22
|
+
gem 'wovnrb', '>= 2.0.1'
|
23
23
|
```
|
24
24
|
|
25
25
|
After setting the above, execute the following command to install the WOVN.io Ruby Library.
|
@@ -177,17 +177,15 @@ module Wovnrb
|
|
177
177
|
url_pattern = @store.settings['url_pattern']
|
178
178
|
lang_code_aliases_json = JSON.generate(@store.settings['custom_lang_aliases'])
|
179
179
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
].join('&')
|
190
|
-
)
|
180
|
+
[
|
181
|
+
"key=#{token}",
|
182
|
+
'backend=true',
|
183
|
+
"currentLang=#{current_lang}",
|
184
|
+
"defaultLang=#{default_lang}",
|
185
|
+
"urlPattern=#{url_pattern}",
|
186
|
+
"langCodeAliases=#{lang_code_aliases_json}",
|
187
|
+
"version=WOVN.rb_#{VERSION}"
|
188
|
+
].join('&')
|
191
189
|
end
|
192
190
|
end
|
193
191
|
end
|
data/lib/wovnrb/version.rb
CHANGED
@@ -6,7 +6,7 @@ module Wovnrb
|
|
6
6
|
converter = prepare_html_converter('<html><body><a class="test">hello</a></body></html>', supported_langs: %w[en vi])
|
7
7
|
converted_html, = converter.build_api_compatible_html
|
8
8
|
|
9
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
9
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a class=\"test\">hello</a></body></html>"
|
10
10
|
assert_equal(expected_html, converted_html)
|
11
11
|
end
|
12
12
|
|
@@ -15,7 +15,7 @@ module Wovnrb
|
|
15
15
|
converter = prepare_html_converter('<html><body><p>' + long_string + '</p></body></html>', supported_langs: %w[en vi])
|
16
16
|
converted_html, = converter.build_api_compatible_html
|
17
17
|
|
18
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
18
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><p>" + long_string + '</p></body></html>'
|
19
19
|
assert_equal(expected_html, converted_html)
|
20
20
|
end
|
21
21
|
|
@@ -31,7 +31,7 @@ module Wovnrb
|
|
31
31
|
converter = prepare_html_converter(html, ignore_class: ['ignore-me'])
|
32
32
|
converted_html, = converter.build_api_compatible_html
|
33
33
|
|
34
|
-
expected_convert_html = "<html><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
34
|
+
expected_convert_html = "<html><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><p>Hello <span wovn-ignore=\"\"><!-- __wovn-backend-ignored-key-0 --></span></p><p></p><div><span class=\"ignore-me\"><!-- __wovn-backend-ignored-key-1 --></span></div><span>Have a nice day!</span></body></html>"
|
35
35
|
assert_equal(expected_convert_html, converted_html)
|
36
36
|
end
|
37
37
|
|
@@ -48,7 +48,7 @@ module Wovnrb
|
|
48
48
|
converter = prepare_html_converter(html, ignore_class: [])
|
49
49
|
converted_html, = converter.build_api_compatible_html
|
50
50
|
|
51
|
-
expected_convert_html = "<html><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
51
|
+
expected_convert_html = "<html><head><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><form action=\"/test\" method=\"POST\"><!-- __wovn-backend-ignored-key-0 --></form></body></html>"
|
52
52
|
assert_equal(expected_convert_html, converted_html)
|
53
53
|
end
|
54
54
|
|
@@ -63,7 +63,7 @@ module Wovnrb
|
|
63
63
|
converter = prepare_html_converter(html, ignore_class: [])
|
64
64
|
converted_html, = converter.build_api_compatible_html
|
65
65
|
|
66
|
-
expected_convert_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
66
|
+
expected_convert_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"fr\" href=\"http://my-site.com/?wovn=fr\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><input id=\"user-id\" type=\"hidden\" value=\"<!-- __wovn-backend-ignored-key-0 -->\"><input id=\"name\" type=\"text\" value=\"wovn.io\"></body></html>"
|
67
67
|
assert_equal(expected_convert_html, converted_html)
|
68
68
|
end
|
69
69
|
|
@@ -71,7 +71,7 @@ module Wovnrb
|
|
71
71
|
converter = prepare_html_converter('<html><body><a>hello</a></body></html>', supported_langs: %w[en vi])
|
72
72
|
translated_html = converter.build
|
73
73
|
|
74
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
74
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
75
75
|
assert_equal(expected_html, translated_html)
|
76
76
|
end
|
77
77
|
|
@@ -79,7 +79,7 @@ module Wovnrb
|
|
79
79
|
converter = prepare_html_converter('<html><body><a>hello</a></body></html>', supported_langs: [])
|
80
80
|
translated_html = converter.build
|
81
81
|
|
82
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
82
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script></head><body><a>hello</a></body></html>"
|
83
83
|
assert_equal(expected_html, translated_html)
|
84
84
|
end
|
85
85
|
|
@@ -87,7 +87,7 @@ module Wovnrb
|
|
87
87
|
converter = prepare_html_converter('<html><head><title>TITLE</title></head><body><a>hello</a></body></html>', supported_langs: %w[en vi])
|
88
88
|
translated_html = converter.build
|
89
89
|
|
90
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
90
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><title>TITLE</title><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body><a>hello</a></body></html>"
|
91
91
|
assert_equal(expected_html, translated_html)
|
92
92
|
end
|
93
93
|
|
@@ -95,7 +95,7 @@ module Wovnrb
|
|
95
95
|
converter = prepare_html_converter('<html>hello<a>world</a></html>', supported_langs: [])
|
96
96
|
translated_html = converter.build
|
97
97
|
|
98
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
98
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script></head><body>hello<a>world</a></body></html>"
|
99
99
|
assert_equal(expected_html, translated_html)
|
100
100
|
end
|
101
101
|
|
@@ -110,7 +110,7 @@ module Wovnrb
|
|
110
110
|
converter = HtmlConverter.new(dom, store, headers)
|
111
111
|
translated_html = converter.build
|
112
112
|
|
113
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
113
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/?wovn=ja\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/?wovn=vi\"></head><body>hello<a>world</a></body></html>"
|
114
114
|
assert_equal(expected_html, translated_html)
|
115
115
|
end
|
116
116
|
|
@@ -125,7 +125,7 @@ module Wovnrb
|
|
125
125
|
converter = HtmlConverter.new(dom, store, headers)
|
126
126
|
translated_html = converter.build
|
127
127
|
|
128
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
128
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=path&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://my-site.com/\"><link rel=\"alternate\" hreflang=\"ja\" href=\"http://my-site.com/ja/\"><link rel=\"alternate\" hreflang=\"vi\" href=\"http://my-site.com/vi/\"></head><body>hello<a>world</a></body></html>"
|
129
129
|
assert_equal(expected_html, translated_html)
|
130
130
|
end
|
131
131
|
|
@@ -133,7 +133,7 @@ module Wovnrb
|
|
133
133
|
converter = prepare_html_converter('<html><head><script src="/a"></script><script src="//j.wovn.io/1" async="true"</head></html>')
|
134
134
|
converter.send(:replace_snippet)
|
135
135
|
|
136
|
-
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
136
|
+
expected_html = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=en&defaultLang=en&urlPattern=query&langCodeAliases={}&version=WOVN.rb_#{VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><script src=\"/a\"></script></head><body></body></html>"
|
137
137
|
assert_equal(expected_html, converter.send(:html))
|
138
138
|
end
|
139
139
|
|
data/test/lib/wovnrb_test.rb
CHANGED
@@ -38,7 +38,7 @@ class WovnrbTest < Minitest::Test
|
|
38
38
|
bodies = ['<html><body><h1>Mr. Belvedere Fan Club</h1>',
|
39
39
|
'<div><p>Hello</p></div>',
|
40
40
|
'</body></html>'].join
|
41
|
-
expected_bodies = ["<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&
|
41
|
+
expected_bodies = ["<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=123456&backend=true&currentLang=ja&defaultLang=en&urlPattern=subdomain&langCodeAliases={}&version=WOVN.rb_#{Wovnrb::VERSION}\" data-wovnio-type=\"fallback_snippet\"></script><link rel=\"alternate\" hreflang=\"en\" href=\"http://page.com/\"></head><body><h1>Mr. Belvedere Fan Club</h1><div><p>Hello</p></div></body></html>"].join
|
42
42
|
|
43
43
|
assert_switch_lang('en', 'ja', bodies, expected_bodies, true)
|
44
44
|
end
|
data/wovnrb.gemspec
CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency 'pry-nav'
|
37
37
|
spec.add_development_dependency 'pry-remote'
|
38
38
|
spec.add_development_dependency 'rake', '~> 10.0'
|
39
|
+
spec.add_development_dependency 'rb-readline'
|
39
40
|
spec.add_development_dependency 'shoulda-context'
|
40
41
|
spec.add_development_dependency 'terminal-notifier'
|
41
42
|
spec.add_development_dependency 'test-unit'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wovnrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Sandford
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -241,6 +241,20 @@ dependencies:
|
|
241
241
|
- - "~>"
|
242
242
|
- !ruby/object:Gem::Version
|
243
243
|
version: '10.0'
|
244
|
+
- !ruby/object:Gem::Dependency
|
245
|
+
name: rb-readline
|
246
|
+
requirement: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
251
|
+
type: :development
|
252
|
+
prerelease: false
|
253
|
+
version_requirements: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - ">="
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: '0'
|
244
258
|
- !ruby/object:Gem::Dependency
|
245
259
|
name: shoulda-context
|
246
260
|
requirement: !ruby/object:Gem::Requirement
|