wovnrb 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/wovnrb.rb +6 -1
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/wovnrb_test.rb +26 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: defbedc8036c41719105e7e6d46099794ed96f35
|
4
|
+
data.tar.gz: 654a31188a9335806a072f2633f05bc0070b695b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5198b929a0951dbe20a169ac4dfff0791dc9b62e8c85385da7d377386cc3a06d034646f7208be708f0eb5b471873940e2ccca38ac61499ced92838ab20d759d8
|
7
|
+
data.tar.gz: 15fe8f3cfe2cbb159046f6aa11711d075493f3b99bb91e8705415f1a19a4fd89a9f9c1b0f72bc6c3b86a3cb354875c25ab410459abc1cd819df6335ed80d663e
|
data/lib/wovnrb.rb
CHANGED
@@ -85,7 +85,12 @@ module Wovnrb
|
|
85
85
|
lang = Lang.new(lang)
|
86
86
|
ignore_all = false
|
87
87
|
new_body = []
|
88
|
-
|
88
|
+
|
89
|
+
# generate full_body to intercept
|
90
|
+
full_body = ''
|
91
|
+
body.each { |b| full_body += b }
|
92
|
+
|
93
|
+
[full_body].each do |b|
|
89
94
|
# temporarily remove noscripts
|
90
95
|
noscripts = []
|
91
96
|
b_without_noscripts = b
|
data/lib/wovnrb/version.rb
CHANGED
data/test/lib/wovnrb_test.rb
CHANGED
@@ -146,6 +146,32 @@ class WovnrbTest < Minitest::Test
|
|
146
146
|
assert_equal([expected_body], swapped_body)
|
147
147
|
end
|
148
148
|
|
149
|
+
def test_switch_lang_splitted_body
|
150
|
+
i = Wovnrb::Interceptor.new(get_app)
|
151
|
+
h = Wovnrb::Headers.new(Wovnrb.get_env('url' => 'http://page.com'), Wovnrb.get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
152
|
+
bodies = ["<html><body><h1>Mr. Belvedere Fan Club</h1>",
|
153
|
+
"<div><p>Hello</p></div>",
|
154
|
+
"</body></html>"]
|
155
|
+
values = generate_values
|
156
|
+
url = h.url
|
157
|
+
swapped_body = i.switch_lang(bodies, values, url, 'ja', h)
|
158
|
+
|
159
|
+
expected_body = "<html lang=\"ja\">
|
160
|
+
<head>
|
161
|
+
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
|
162
|
+
<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&backend=true&currentLang=ja&defaultLang=en&urlPattern=path&langCodeAliases={}&version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
|
163
|
+
<link rel=\"alternate\" hreflang=\"en\" href=\"http://page.com/\">
|
164
|
+
</head>
|
165
|
+
<body>
|
166
|
+
<h1>
|
167
|
+
<!--wovn-src:Mr. Belvedere Fan Club-->ベルベデアさんファンクラブ</h1>
|
168
|
+
<div><p><!--wovn-src:Hello-->こんにちは</p></div>
|
169
|
+
</body>
|
170
|
+
</html>
|
171
|
+
"
|
172
|
+
assert_equal([expected_body], swapped_body)
|
173
|
+
end
|
174
|
+
|
149
175
|
def test_switch_lang_missing_values
|
150
176
|
i = Wovnrb::Interceptor.new(get_app)
|
151
177
|
h = Wovnrb::Headers.new(Wovnrb.get_env('url' => 'http://page.com'), Wovnrb.get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
|
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: 1.0.
|
4
|
+
version: 1.0.8
|
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: 2018-08-
|
12
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogumbo
|
@@ -412,7 +412,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
412
412
|
version: '0'
|
413
413
|
requirements: []
|
414
414
|
rubyforge_project:
|
415
|
-
rubygems_version: 2.
|
415
|
+
rubygems_version: 2.6.11
|
416
416
|
signing_key:
|
417
417
|
specification_version: 4
|
418
418
|
summary: Gem for WOVN.io
|