wovnrb 0.2.03 → 0.2.04

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: 331efba8ea791590ae759615aa853a4379a8633f
4
- data.tar.gz: 95325d00b3d635fa06b2acd30ffde80a17d722ac
3
+ metadata.gz: 5b14f7b1db39f462612fbfb5437c8b9a57ab0545
4
+ data.tar.gz: 216b7d095a9ab39fe039ecd7a86cb421f93edbba
5
5
  SHA512:
6
- metadata.gz: 9aa88813f3efce6b9990c31f2e82d6ec80f0fe445cb15bee1814a5bd82eae9fa825275f236e4b747b03933e7f6e922ce14ec7d9499ac0dec5c0d0efc58f358ba
7
- data.tar.gz: 9dfc5c07628474fc96203be53f18bdec97a98c198bf997c2a0bf448d02c6226c5222bda14fdc9974c9cee2cb08181afa93ac72dfe5427302818f227970556a3f
6
+ metadata.gz: 03c36df5a7edb5fc443124eafdf338d272d009b7c612188512cf24ec272f68538808b4c7dd312fa37822b96cf25200afde4185a6c8c6593d9939f00a1f0e5015
7
+ data.tar.gz: 79114a464d34be6fb01dd0091bec13f58823d14f61f6308a964cff85cf24d69f43b35838e4bde1ab80eddc49aede2fe984a82a5057276bedce15d98e5d7d4ac8
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
4
  - 2.1.0
4
5
  before_install:
data/README.md CHANGED
@@ -38,8 +38,8 @@ Insert the following into either config/application.rb or config/environments/.
38
38
  ...
39
39
 
40
40
  config.wovnrb = {
41
- :user_token => '2Wle3',
42
- :secret_key => 'secret',
41
+ :user_token => '2Wle3',
42
+ :secret_key => 'secret',
43
43
  }
44
44
 
45
45
  ...
@@ -55,8 +55,8 @@ Insert the following into either the Application File or config.ru.
55
55
  require 'wovnrb'
56
56
 
57
57
  use Wovnrb::Interceptor, {
58
- :user_token => '2Wle3',
59
- :secret_key => 'secret',
58
+ :user_token => '2Wle3',
59
+ :secret_key => 'secret',
60
60
  }
61
61
 
62
62
  ...
@@ -100,15 +100,15 @@ parameters | Translated page's URL | Notes
100
100
 
101
101
  ### 2.4. query
102
102
 
103
- Using the query parameter, you can setup query parameters you wish to be ignored within the URL when translating via WOVN.io. There is no default value, in this case, all query parameters are included within the translated page's URL.
103
+ WOVN.io ignores query parameters when searching translated page. If you want to add query parameter to translated page's URL, you should configure "query" parameter. (You need to configure WOVN.io too)
104
104
 
105
105
  https://wovn.io/ja/contact?os=mac&keyboard=us
106
106
 
107
- If the defualt_lang is 'en', and the query is set to 'os=mac&keyboard=us', the above URL will be modified into the following URL to search for the page's translation.
107
+ If the defualt_lang is 'en', and the query is set to '', the above URL will be modified into the following URL to search for the page's translation.
108
108
 
109
- https://wovn.io/contact?os=mac&keyboard=us
109
+ https://wovn.io/contact
110
110
 
111
- If the default_lang is 'en', and the query is set to 'os=mac', the above URL will be modified into the following URL to search for the page's translation.
111
+ If the default_lang is 'en', and the query is set to 'os', the above URL will be modified into the following URL to search for the page's translation.
112
112
 
113
113
  https://wovn.io/contact?os=mac
114
114
 
@@ -55,6 +55,8 @@ module Wovnrb
55
55
  end
56
56
  if query_vals.length > 0
57
57
  @query = "?#{query_vals.sort.join('&')}"
58
+ else
59
+ @query = ''
58
60
  end
59
61
  else
60
62
  @query = ''
@@ -170,6 +172,9 @@ module Wovnrb
170
172
  if @env.has_key?('ORIGINAL_FULLPATH')
171
173
  @env['ORIGINAL_FULLPATH'] = remove_lang(@env['ORIGINAL_FULLPATH'])
172
174
  end
175
+ if @env.has_key?('HTTP_REFERER')
176
+ @env["HTTP_REFERER"] = remove_lang(@env["HTTP_REFERER"])
177
+ end
173
178
  end
174
179
  @env
175
180
  end
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = "0.2.03"
2
+ VERSION = "0.2.04"
3
3
  end
@@ -82,7 +82,25 @@ class HeadersTest < Minitest::Test
82
82
  assert_equal('wovn.io', h.unmasked_host)
83
83
  assert_equal('localhost', env['HTTP_HOST'])
84
84
  assert_equal('localhost', env['SERVER_NAME'])
85
- end
85
+ end
86
+
87
+ def test_initialize_without_query
88
+ env = Wovnrb.get_env
89
+ h = Wovnrb::Headers.new(env, Wovnrb.get_settings)
90
+ assert_equal('wovn.io/dashboard', h.redis_url)
91
+ end
92
+
93
+ def test_initialize_with_query
94
+ env = Wovnrb.get_env
95
+ h = Wovnrb::Headers.new(env, Wovnrb.get_settings('query' => ['param']))
96
+ assert_equal('wovn.io/dashboard?param=val', h.redis_url)
97
+ end
98
+
99
+ def test_initialize_with_not_matching_query
100
+ env = Wovnrb.get_env
101
+ h = Wovnrb::Headers.new(env, Wovnrb.get_settings('query' => ['aaa']))
102
+ assert_equal('wovn.io/dashboard', h.redis_url)
103
+ end
86
104
 
87
105
  #########################
88
106
  # REQUEST_OUT
@@ -106,6 +124,31 @@ class HeadersTest < Minitest::Test
106
124
  assert_equal('wovn.io', env['HTTP_X_FORWARDED_HOST'])
107
125
  end
108
126
 
127
+ def test_request_out_http_referer_subdomain
128
+ h = Wovnrb::Headers.new(
129
+ Wovnrb.get_env(
130
+ 'SERVER_NAME' => 'ja.wovn.io',
131
+ 'REQUEST_URI' => '/test',
132
+ 'HTTP_REFERER' => 'http://ja.wovn.io/test',
133
+ ),
134
+ Wovnrb.get_settings(
135
+ 'url_pattern' => 'subdomain',
136
+ 'url_pattern_reg' => '^(?<lang>[^.]+).',
137
+ ),
138
+ )
139
+ env = h.request_out('ja')
140
+ assert_equal('http://wovn.io/test', env['HTTP_REFERER'])
141
+ end
142
+
143
+ def test_request_out_http_referer_path
144
+ h = Wovnrb::Headers.new(
145
+ Wovnrb.get_env('REQUEST_URI' => '/ja/test', 'HTTP_REFERER' => 'http://wovn.io/ja/test'),
146
+ Wovnrb.get_settings,
147
+ )
148
+ env = h.request_out('ja')
149
+ assert_equal('http://wovn.io/test', env['HTTP_REFERER'])
150
+ end
151
+
109
152
  #########################
110
153
  # GET SETTINGS
111
154
  #########################
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: 0.2.03
4
+ version: 0.2.04
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: 2016-04-27 00:00:00.000000000 Z
12
+ date: 2016-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogumbo
@@ -350,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
350
350
  version: '0'
351
351
  requirements: []
352
352
  rubyforge_project:
353
- rubygems_version: 2.4.5.1
353
+ rubygems_version: 2.2.0
354
354
  signing_key:
355
355
  specification_version: 4
356
356
  summary: Gem for WOVN.io
@@ -374,3 +374,4 @@ test_files:
374
374
  - test/lib/wovnrb_test.rb
375
375
  - test/services/url_test.rb
376
376
  - test/test_helper.rb
377
+ has_rdoc: