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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d57533c589ec6dfd2171967b855c3cf7dac3b5da
4
- data.tar.gz: 4697b8fbd091071187d742bd3bbcb34a71ac7c1e
3
+ metadata.gz: defbedc8036c41719105e7e6d46099794ed96f35
4
+ data.tar.gz: 654a31188a9335806a072f2633f05bc0070b695b
5
5
  SHA512:
6
- metadata.gz: 9c970c7c8772d0ed103b9b6700abf632c2d6834ce2343ad0b06c94fe0ae1e53a4d124a1a759d5c089ac0916f068d81f2f36c89161d59c06fd1218ef1818c3784
7
- data.tar.gz: e927ee8669e85fbd1c516773c896f8bc2e78378121cf1240555d12e99ae7a84deb8118bc767979d704e8ad70a9dc70d2e486d9d1c4ecae61f5518f6b31ad3ff7
6
+ metadata.gz: 5198b929a0951dbe20a169ac4dfff0791dc9b62e8c85385da7d377386cc3a06d034646f7208be708f0eb5b471873940e2ccca38ac61499ced92838ab20d759d8
7
+ data.tar.gz: 15fe8f3cfe2cbb159046f6aa11711d075493f3b99bb91e8705415f1a19a4fd89a9f9c1b0f72bc6c3b86a3cb354875c25ab410459abc1cd819df6335ed80d663e
@@ -85,7 +85,12 @@ module Wovnrb
85
85
  lang = Lang.new(lang)
86
86
  ignore_all = false
87
87
  new_body = []
88
- body.each do |b|
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
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
@@ -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=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;langCodeAliases={}&amp;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.7
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-08 00:00:00.000000000 Z
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.5.2
415
+ rubygems_version: 2.6.11
416
416
  signing_key:
417
417
  specification_version: 4
418
418
  summary: Gem for WOVN.io