wovnrb 0.1.79 → 0.1.80

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: c03a1eafe91ca1d7f61f89cc576db72d77acaaae
4
- data.tar.gz: 7b455e147054346b3e26cf3704c03feea154922f
3
+ metadata.gz: f0d481a935a4b41b24d790ef3652d6922d1435c3
4
+ data.tar.gz: a885a5859edc04170ce1a078c8a84ce4d554b0c0
5
5
  SHA512:
6
- metadata.gz: 66146ca7b69bc644b0b7ae93183208bd391ee26f0f9b713ab4c25b624716995b604db6a9729903cf26ebd6193f93ac93be167a31dbbbb59b4d82d3c96d7a60c8
7
- data.tar.gz: 565ccafae8afb898e57977aa95ed3046ca3af4566220b169fd076ca2f22406d904807eab4ec5abe43b5b1cbcedcef4f108fca987f31695c00fd6485ea2aec3cf
6
+ metadata.gz: 4ea5bbe493481c7f827a1ffae7c0ad443de64e5977368165aba51ae94cf577489c025aafbbf6cfaca43f2b5226a8efcd24dc3d46d541f4e48261f77c570706cc
7
+ data.tar.gz: 15e76d5ea1a873e738d02820b07d00bc11305faec6facea7efbf2b115746455cac3693c1f323cf2da44f38d8e17a68f5cdd50abe38108a14566b06412e352a39
data/.gitignore CHANGED
@@ -18,4 +18,5 @@
18
18
  *.a
19
19
  *.swp
20
20
  mkmf.log
21
- .idea/
21
+ .idea/
22
+ .ruby-version
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ before_install:
5
+ - gem update bundler
data/circle.yml ADDED
@@ -0,0 +1,8 @@
1
+ machine:
2
+ ruby:
3
+ version: 2.1.0
4
+
5
+ test:
6
+ override:
7
+ - bundle exec rake test
8
+
data/lib/wovnrb.rb CHANGED
@@ -12,8 +12,10 @@ module Wovnrb
12
12
  STORE = Store.new
13
13
 
14
14
  class Interceptor
15
- def initialize(app)
15
+ def initialize(app, opts={})
16
16
  @app = app
17
+ opts = opts.each_with_object({}){|(k,v),memo| memo[k.to_s]=v}
18
+ STORE.settings(opts)
17
19
  end
18
20
 
19
21
  def call(env)
@@ -139,7 +141,7 @@ module Wovnrb
139
141
  d.encoding = "UTF-8"
140
142
 
141
143
  # If this page has wovn-ignore in the html tag, don't do anything
142
- if ignore_all || d.xpath('//html[@wovn-ignore]').present?
144
+ if ignore_all || !d.xpath('//html[@wovn-ignore]').empty?
143
145
  ignore_all = true
144
146
  output = d.to_html.gsub(/href="([^"]*)"/) { |m| "href=\"#{URI.decode($1)}\"" }
145
147
  new_body.push(output)
@@ -168,7 +170,7 @@ module Wovnrb
168
170
  # swap meta tag values
169
171
  d.xpath('//meta').select { |t|
170
172
  next if check_wovn_ignore(t)
171
- (t.get_attribute('name') || t.get_attribute('property') || '') =~ /^(description|keywords|og:title|og:description)$/
173
+ (t.get_attribute('name') || t.get_attribute('property') || '') =~ /^(description|title|og:title|og:description|twitter:title|twitter:description)$/
172
174
  }.each do |node|
173
175
  node_content = node.get_attribute('content').strip
174
176
  # shouldn't need size check, but for now...
@@ -199,6 +201,12 @@ module Wovnrb
199
201
  node.attribute('src').value = "#{img_src_prefix}#{src_index[src][lang][0]['data']}"
200
202
  end
201
203
  end
204
+ if node.get_attribute('alt')
205
+ alt = node.get_attribute('alt').strip
206
+ if text_index[alt] && text_index[alt][lang] && text_index[alt][lang].size > 0
207
+ node.attribute('alt').value = alt.gsub(/^(\s*)[\S\s]*(\s*)$/, '\1' + text_index[alt][lang][0]['data'] + '\2')
208
+ end
209
+ end
202
210
  end
203
211
 
204
212
  # REMOVE WIDGET
data/lib/wovnrb/store.rb CHANGED
@@ -1,13 +1,11 @@
1
- require 'redis'
2
1
  require 'net/http'
3
- require 'socket'
2
+ require 'uri'
4
3
  require 'cgi'
5
- require 'Logger' unless defined?(Logger)
4
+ require 'logger' unless defined?(Logger)
6
5
 
7
6
  module Wovnrb
8
7
 
9
8
  class Store
10
- attr_reader :settings
11
9
 
12
10
  def initialize
13
11
  @settings =
@@ -21,8 +19,7 @@ module Wovnrb
21
19
  #'url_pattern' => 'subdomain',
22
20
  #'url_pattern_reg' => "^(?<lang>[^.]+)\.",
23
21
  'query' => [],
24
- 'backend_host' => 'rs1.wovn.io',
25
- 'backend_port' => '6379',
22
+ 'api_url' => 'https://api.wovn.io/v0/values',
26
23
  'default_lang' => 'en',
27
24
  'supported_langs' => ['en'],
28
25
  'test_mode' => false,
@@ -54,13 +51,9 @@ module Wovnrb
54
51
  valid = false
55
52
  errors.push("query config #{settings['query']} is not valid.");
56
53
  end
57
- if !settings.has_key?('backend_host') || settings['backend_host'].length == 0
54
+ if !settings.has_key?('api_url') || settings['api_url'].length == 0
58
55
  valid = false
59
- errors.push("Backend host is not configured.");
60
- end
61
- if !settings.has_key?('backend_port') || settings['backend_port'].length == 0
62
- valid = false
63
- errors.push("Backend port is not configured.");
56
+ errors.push("API URL is not configured.")
64
57
  end
65
58
  if !settings.has_key?('default_lang') || settings['default_lang'].length == 0
66
59
  valid = false
@@ -83,7 +76,12 @@ module Wovnrb
83
76
  # Returns the settings object, pulling from Rails config the first time this is called
84
77
  #
85
78
  # @return [Hash] The settings which are pulled from the config file given by the user and filled in by defaults
86
- def settings
79
+ def settings(*opts)
80
+ if !opts.first.nil?
81
+ @settings.merge!(opts.first)
82
+ @config_loaded = false
83
+ end
84
+
87
85
  if !@config_loaded
88
86
  # get Rails config.wovnrb
89
87
  if Object.const_defined?('Rails') && Rails.configuration.respond_to?(:wovnrb)
@@ -98,7 +96,6 @@ module Wovnrb
98
96
  end
99
97
 
100
98
  # fix settings object
101
- @settings['backend_port'] = @settings['backend_port'].to_s
102
99
  @settings['default_lang'] = Lang.get_code(@settings['default_lang'])
103
100
  if !@settings.has_key?('supported_langs')
104
101
  @settings['supported_langs'] = [@settings['default_lang']]
@@ -127,30 +124,25 @@ module Wovnrb
127
124
  # @return [Hash] The values Hash for the passed in url
128
125
  def get_values(url)
129
126
  url = url.gsub(/\/$/, '')
130
- redis_key = 'WOVN:BACKEND:STORAGE:' + url + ':' + settings['user_token']
131
- cli = Redis.new(host: settings['backend_host'], port: settings['backend_port'])
132
127
 
133
128
  begin
134
- vals = cli.get(redis_key) || '{}'
135
- vals = JSON.parse(vals)
129
+ uri = URI.parse("#{settings['api_url']}?token=#{settings['user_token']}&url=#{url}")
130
+ http = Net::HTTP.new(uri.host, uri.port)
131
+ http.use_ssl = true if uri.scheme == 'https'
132
+ res = http.start {
133
+ http.get(uri.request_uri)
134
+ }
135
+ if res.code == "200"
136
+ vals = JSON.parse(res.body || '{}')
137
+ else
138
+ vals = {}
139
+ end
136
140
  rescue
137
- logger = Logger.new('../error.log')
138
- logger.error("Redis GET request failed with the following parameters:\nhost: #{settings['backend_host']}\nport: #{settings['backend_port']}\nkey: #{redis_key}")
139
141
  vals = {}
142
+ logger = Logger.new('../error.log')
143
+ logger.error("API server GET request failed with the following parameters:\napi_url: #{settings['api_url']}\ntoken: #{settings['user_token']}\nurl: #{url}")
140
144
  end
141
- if vals['expired'] || vals.empty?
142
- host = 'ee.wovn.io'
143
- post_data = "{\"user_token\":\"#{settings['user_token']}\", \"url\":#{url.to_json}}"
144
- headers = "Host: #{host}\r\nContent-Type: application/json;charset=UTF-8\r\nContent-Length: #{post_data.bytesize}\r\nConnection: close\r\n\r\n"
145
- s = TCPSocket.new(host, 80)
146
- s.puts "POST /pages/cache_backend HTTP/1.1\r\n#{headers}#{post_data}"
147
- s.close
148
- end
149
- # handle this on the widget
150
- #if vals.empty?
151
- # uri = URI.parse('http://api.wovn.io/v0/page/add')
152
- # Net::HTTP.post_form(uri, :user_token => user_token, :secret_key => @settings['secret_key'], :url => url)
153
- #end
145
+
154
146
  vals
155
147
  end
156
148
 
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = "0.1.79"
2
+ VERSION = "0.1.80"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,2 @@
1
1
  require 'pry'
2
- require 'Wovnrb'
2
+ require 'wovnrb'
@@ -5821,8 +5821,7 @@ class HeadersTest < Minitest::Test
5821
5821
  settings['url_pattern'] = 'path'
5822
5822
  settings['url_pattern_reg'] = "/(?<lang>[^/.?]+)"
5823
5823
  settings['query'] = []
5824
- settings['backend_host'] = 'localhost'
5825
- settings['backend_port'] = '6379'
5824
+ settings['api_url'] = 'http://localhost/v0/values'
5826
5825
  settings['default_lang'] = 'en'
5827
5826
  settings['supported_langs'] = []
5828
5827
  settings['secret_key'] = ''
@@ -0,0 +1,37 @@
1
+ require 'wovnrb/store'
2
+ require 'minitest/autorun'
3
+
4
+ class StoreTest < Minitest::Test
5
+ def test_initialize
6
+ s = Wovnrb::Store.new
7
+ refute_nil(s)
8
+ end
9
+
10
+ def test_settings_no_parameters
11
+ s = Wovnrb::Store.new
12
+ assert_equal('path', s.settings['url_pattern'])
13
+ assert_equal('/(?<lang>[^/.?]+)', s.settings['url_pattern_reg'])
14
+ end
15
+
16
+ def test_settings_url_pattern_path
17
+ s = Wovnrb::Store.new
18
+ s.settings({'url_pattern' => 'path'})
19
+ assert_equal('path', s.settings['url_pattern'])
20
+ assert_equal('/(?<lang>[^/.?]+)', s.settings['url_pattern_reg'])
21
+ end
22
+
23
+ def test_settings_url_pattern_subdomain
24
+ s = Wovnrb::Store.new
25
+ s.settings({'url_pattern' => 'subdomain'})
26
+ assert_equal("^(?<lang>[^.]+)\.", s.settings['url_pattern_reg'])
27
+ assert_equal('subdomain', s.settings['url_pattern'])
28
+ end
29
+
30
+ def test_settings_url_pattern_query
31
+ s = Wovnrb::Store.new
32
+ s.settings({'url_pattern' => 'query'})
33
+ assert_equal('((\\?.*&)|\\?)wovn=(?<lang>[^&]+)(&|$)', s.settings['url_pattern_reg'])
34
+ assert_equal('query', s.settings['url_pattern'])
35
+ end
36
+ end
37
+
@@ -294,7 +294,7 @@ class WovnrbTest < Minitest::Test
294
294
  body = "<html lang=\"ja\">
295
295
  <head>
296
296
  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
297
- <script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
297
+ <script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
298
298
  </head>
299
299
  <body>
300
300
  <h1>ベルベデアさんファンクラブ</h1>
@@ -306,7 +306,7 @@ class WovnrbTest < Minitest::Test
306
306
  body = "<html lang=\"ja\">
307
307
  <head>
308
308
  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
309
- <script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
309
+ <script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">
310
310
  </head>
311
311
  <body>
312
312
  <h1>ベルベデアさんファンクラブ</h1>
@@ -318,7 +318,7 @@ class WovnrbTest < Minitest::Test
318
318
  body = "<html lang=\"ja\">
319
319
  <head>
320
320
  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">
321
- <script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
321
+ <script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">
322
322
  </head>
323
323
  <body wovn-ignore=\"\">
324
324
  <h1>Mr. Belvedere Fan Club</h1>
@@ -337,15 +337,23 @@ class WovnrbTest < Minitest::Test
337
337
  when "value_double_quote"
338
338
  body = "<html><body><h1>Mr.BelvedereFanClub</h1><div wovn-ignore=\"value\"><p>Hello</p></div></body></html>"
339
339
  when "empty_translated"
340
- body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
340
+ body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
341
341
  when "empty_single_quote_translated"
342
- body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
342
+ body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
343
343
  when "empty_double_quote_translated"
344
- body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
344
+ body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"\"><p>Hello</p></div>\n</body>\n</html>\n"
345
345
  when "value_single_quote_translated"
346
- body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
346
+ body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
347
347
  when "value_double_quote_translated"
348
- body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/0\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
348
+ body = "<html lang=\"ja\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.ignore-page.com/\">\n</head>\n<body>\n<h1>Mr.BelvedereFanClub</h1>\n<div wovn-ignore=\"value\"><p>Hello</p></div>\n</body>\n</html>\n"
349
+ when "meta_img_alt_tags_translated"
350
+ body = "<html lang=\"ja\">\n<head>\n<script src=\"//j.wovn.io/1\" async=\"true\" data-wovnio=\"key=&amp;backend=true&amp;currentLang=ja&amp;defaultLang=en&amp;urlPattern=path&amp;version=#{Wovnrb::VERSION}\"> </script><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<meta name=\"description\" content=\"こんにちは\">\n<meta name=\"title\" content=\"こんにちは\">\n<meta property=\"og:title\" content=\"こんにちは\">\n<meta property=\"og:description\" content=\"こんにちは\">\n<meta property=\"twitter:title\" content=\"こんにちは\">\n<meta property=\"twitter:description\" content=\"こんにちは\">\n<link rel=\"alternate\" hreflang=\"ja\" href=\"http://ja.page.com/\">\n</head>\n<body>\n<h1>ベルベデアさんファンクラブ</h1>\n<div><p>こんにちは</p></div>\n<img src=\"http://example.com/photo.png\" alt=\"こんにちは\">\n</body>\n</html>\n"
351
+ when "meta_img_alt_tags"
352
+ body = "<html><head><meta name =\"description\" content=\"Hello\">\n<meta name=\"title\" content=\"Hello\">\n<meta property=\"og:title\" content=\"Hello\">\n<meta property=\"og:description\" content=\"Hello\">\n<meta property=\"twitter:title\" content=\"Hello\">\n<meta property=\"twitter:description\" content=\"Hello\"></head>
353
+ <body><h1>Mr. Belvedere Fan Club</h1>
354
+ <div><p>Hello</p></div>
355
+ <img src=\"http://example.com/photo.png\" alt=\"Hello\">
356
+ </body></html>"
349
357
  else # "" case
350
358
  body = "<html><body><h1>Mr. Belvedere Fan Club</h1>
351
359
  <div><p>Hello</p></div>
@@ -371,6 +379,16 @@ class WovnrbTest < Minitest::Test
371
379
  assert_equal(generate_body('translated_in_japanese'), swapped_body)
372
380
  end
373
381
 
382
+ def test_switch_lang_meta_img_alt_tags
383
+ i = Wovnrb::Interceptor.new(get_app)
384
+ h = Wovnrb::Headers.new(get_env('url' => 'http://page.com'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
385
+ body = generate_body('meta_img_alt_tags')
386
+ values = generate_values
387
+ url = h.url
388
+ swapped_body = i.switch_lang(body, values, url, 'ja', h)
389
+ assert_equal(generate_body('meta_img_alt_tags_translated'), swapped_body)
390
+ end
391
+
374
392
  def test_switch_lang_wovn_ignore
375
393
  i = Wovnrb::Interceptor.new(get_app)
376
394
  h = Wovnrb::Headers.new(get_env('url' => 'http://ignore-page.com'), get_settings('url_pattern' => 'subdomain', 'url_pattern_reg' => '^(?<lang>[^.]+).'))
@@ -447,8 +465,7 @@ class WovnrbTest < Minitest::Test
447
465
  settings['url_pattern'] = 'path'
448
466
  settings['url_pattern_reg'] = "/(?<lang>[^/.?]+)"
449
467
  settings['query'] = []
450
- settings['backend_host'] = 'localhost'
451
- settings['backend_port'] = '6379'
468
+ settings['api_url'] = 'http://localhost/v0/values'
452
469
  settings['default_lang'] = 'en'
453
470
  settings['supported_langs'] = []
454
471
  settings['secret_key'] = ''
@@ -1,4 +1,4 @@
1
- require 'wovnrb/services/URL'
1
+ require 'wovnrb/services/url'
2
2
 
3
3
  class URLTest < Minitest::Test
4
4
 
data/wovnrb.gemspec CHANGED
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
26
26
  #spec.extensions = spec.files.grep(%r{/extconf\.rb$})
27
27
 
28
28
  spec.add_dependency "nokogumbo", "1.3.0"
29
- spec.add_dependency "redis"
30
29
 
31
30
  spec.add_development_dependency "bundler", "~> 1.7"
32
31
  spec.add_development_dependency "rake", "~> 10.0"
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.1.79
4
+ version: 0.1.80
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-02-02 00:00:00.000000000 Z
12
+ date: 2016-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogumbo
@@ -25,200 +25,186 @@ dependencies:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
27
  version: 1.3.0
28
- - !ruby/object:Gem::Dependency
29
- name: redis
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - '>='
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '>='
40
- - !ruby/object:Gem::Version
41
- version: '0'
42
28
  - !ruby/object:Gem::Dependency
43
29
  name: bundler
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
- - - ~>
32
+ - - "~>"
47
33
  - !ruby/object:Gem::Version
48
34
  version: '1.7'
49
35
  type: :development
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
- - - ~>
39
+ - - "~>"
54
40
  - !ruby/object:Gem::Version
55
41
  version: '1.7'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: rake
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
- - - ~>
46
+ - - "~>"
61
47
  - !ruby/object:Gem::Version
62
48
  version: '10.0'
63
49
  type: :development
64
50
  prerelease: false
65
51
  version_requirements: !ruby/object:Gem::Requirement
66
52
  requirements:
67
- - - ~>
53
+ - - "~>"
68
54
  - !ruby/object:Gem::Version
69
55
  version: '10.0'
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: test-unit
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
- - - '>='
60
+ - - ">="
75
61
  - !ruby/object:Gem::Version
76
62
  version: '0'
77
63
  type: :development
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
- - - '>='
67
+ - - ">="
82
68
  - !ruby/object:Gem::Version
83
69
  version: '0'
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: test-unit-notify
86
72
  requirement: !ruby/object:Gem::Requirement
87
73
  requirements:
88
- - - '>='
74
+ - - ">="
89
75
  - !ruby/object:Gem::Version
90
76
  version: '0'
91
77
  type: :development
92
78
  prerelease: false
93
79
  version_requirements: !ruby/object:Gem::Requirement
94
80
  requirements:
95
- - - '>='
81
+ - - ">="
96
82
  - !ruby/object:Gem::Version
97
83
  version: '0'
98
84
  - !ruby/object:Gem::Dependency
99
85
  name: minitest
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
- - - '>='
88
+ - - ">="
103
89
  - !ruby/object:Gem::Version
104
90
  version: '0'
105
91
  type: :development
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
- - - '>='
95
+ - - ">="
110
96
  - !ruby/object:Gem::Version
111
97
  version: '0'
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: terminal-notifier
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
- - - '>='
102
+ - - ">="
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
108
  requirements:
123
- - - '>='
109
+ - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: guard
128
114
  requirement: !ruby/object:Gem::Requirement
129
115
  requirements:
130
- - - '>='
116
+ - - ">="
131
117
  - !ruby/object:Gem::Version
132
118
  version: '0'
133
119
  type: :development
134
120
  prerelease: false
135
121
  version_requirements: !ruby/object:Gem::Requirement
136
122
  requirements:
137
- - - '>='
123
+ - - ">="
138
124
  - !ruby/object:Gem::Version
139
125
  version: '0'
140
126
  - !ruby/object:Gem::Dependency
141
127
  name: guard-rspec
142
128
  requirement: !ruby/object:Gem::Requirement
143
129
  requirements:
144
- - - '>='
130
+ - - ">="
145
131
  - !ruby/object:Gem::Version
146
132
  version: '0'
147
133
  type: :development
148
134
  prerelease: false
149
135
  version_requirements: !ruby/object:Gem::Requirement
150
136
  requirements:
151
- - - '>='
137
+ - - ">="
152
138
  - !ruby/object:Gem::Version
153
139
  version: '0'
154
140
  - !ruby/object:Gem::Dependency
155
141
  name: pry
156
142
  requirement: !ruby/object:Gem::Requirement
157
143
  requirements:
158
- - - '>='
144
+ - - ">="
159
145
  - !ruby/object:Gem::Version
160
146
  version: '0'
161
147
  type: :development
162
148
  prerelease: false
163
149
  version_requirements: !ruby/object:Gem::Requirement
164
150
  requirements:
165
- - - '>='
151
+ - - ">="
166
152
  - !ruby/object:Gem::Version
167
153
  version: '0'
168
154
  - !ruby/object:Gem::Dependency
169
155
  name: pry-remote
170
156
  requirement: !ruby/object:Gem::Requirement
171
157
  requirements:
172
- - - '>='
158
+ - - ">="
173
159
  - !ruby/object:Gem::Version
174
160
  version: '0'
175
161
  type: :development
176
162
  prerelease: false
177
163
  version_requirements: !ruby/object:Gem::Requirement
178
164
  requirements:
179
- - - '>='
165
+ - - ">="
180
166
  - !ruby/object:Gem::Version
181
167
  version: '0'
182
168
  - !ruby/object:Gem::Dependency
183
169
  name: pry-nav
184
170
  requirement: !ruby/object:Gem::Requirement
185
171
  requirements:
186
- - - '>='
172
+ - - ">="
187
173
  - !ruby/object:Gem::Version
188
174
  version: '0'
189
175
  type: :development
190
176
  prerelease: false
191
177
  version_requirements: !ruby/object:Gem::Requirement
192
178
  requirements:
193
- - - '>='
179
+ - - ">="
194
180
  - !ruby/object:Gem::Version
195
181
  version: '0'
196
182
  - !ruby/object:Gem::Dependency
197
183
  name: rake-compiler
198
184
  requirement: !ruby/object:Gem::Requirement
199
185
  requirements:
200
- - - '>='
186
+ - - ">="
201
187
  - !ruby/object:Gem::Version
202
188
  version: '0'
203
189
  type: :development
204
190
  prerelease: false
205
191
  version_requirements: !ruby/object:Gem::Requirement
206
192
  requirements:
207
- - - '>='
193
+ - - ">="
208
194
  - !ruby/object:Gem::Version
209
195
  version: '0'
210
196
  - !ruby/object:Gem::Dependency
211
197
  name: geminabox
212
198
  requirement: !ruby/object:Gem::Requirement
213
199
  requirements:
214
- - - '>='
200
+ - - ">="
215
201
  - !ruby/object:Gem::Version
216
202
  version: '0'
217
203
  type: :development
218
204
  prerelease: false
219
205
  version_requirements: !ruby/object:Gem::Requirement
220
206
  requirements:
221
- - - '>='
207
+ - - ">="
222
208
  - !ruby/object:Gem::Version
223
209
  version: '0'
224
210
  description: ALPHA VERSION, not in a useable form.
@@ -228,12 +214,13 @@ executables: []
228
214
  extensions: []
229
215
  extra_rdoc_files: []
230
216
  files:
231
- - .gitignore
232
- - .ruby-version
217
+ - ".gitignore"
218
+ - ".travis.yml"
233
219
  - Gemfile
234
220
  - LICENSE.txt
235
221
  - README.md
236
222
  - Rakefile
223
+ - circle.yml
237
224
  - ext/dom/Makefile
238
225
  - lib/wovnrb.rb
239
226
  - lib/wovnrb/headers.rb
@@ -247,6 +234,7 @@ files:
247
234
  - test/lib/headers_test.rb
248
235
  - test/lib/lang_test.rb
249
236
  - test/lib/services/url_test.rb
237
+ - test/lib/store_test.rb
250
238
  - test/lib/wovnrb_test.rb
251
239
  - test/services/url_test.rb
252
240
  - test/test_helper.rb
@@ -262,17 +250,17 @@ require_paths:
262
250
  - lib
263
251
  required_ruby_version: !ruby/object:Gem::Requirement
264
252
  requirements:
265
- - - '>='
253
+ - - ">="
266
254
  - !ruby/object:Gem::Version
267
255
  version: '0'
268
256
  required_rubygems_version: !ruby/object:Gem::Requirement
269
257
  requirements:
270
- - - '>='
258
+ - - ">="
271
259
  - !ruby/object:Gem::Version
272
260
  version: '0'
273
261
  requirements: []
274
262
  rubyforge_project:
275
- rubygems_version: 2.0.14
263
+ rubygems_version: 2.2.0
276
264
  signing_key:
277
265
  specification_version: 4
278
266
  summary: Gem for WOVN.io
@@ -282,6 +270,7 @@ test_files:
282
270
  - test/lib/headers_test.rb
283
271
  - test/lib/lang_test.rb
284
272
  - test/lib/services/url_test.rb
273
+ - test/lib/store_test.rb
285
274
  - test/lib/wovnrb_test.rb
286
275
  - test/services/url_test.rb
287
276
  - test/test_helper.rb
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.0.0-p451