wovnrb 0.2.02 → 0.2.03

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: d1df053b985e8697f9164898024e44c06f61e249
4
- data.tar.gz: 0a516cb7c4712ba7f52c5a70e767721dba64cc42
3
+ metadata.gz: 331efba8ea791590ae759615aa853a4379a8633f
4
+ data.tar.gz: 95325d00b3d635fa06b2acd30ffde80a17d722ac
5
5
  SHA512:
6
- metadata.gz: 62e2aa38e740242c0ef89c88e076aeaeb9e69d72c9bc0ac2164547165bc531f8a8d39346541530b5ab0e6164213e6ca074e9c3be93da0a3b5a4b39ccb014eac3
7
- data.tar.gz: 14ac3a44106d4a114023b91c73aa00740bec2f6c3387861d7002cfee0a8792a73fac3a8f8607620ec2ae62d8915e2d913378ae0890bdfec70e678f796d24dc47
6
+ metadata.gz: 9aa88813f3efce6b9990c31f2e82d6ec80f0fe445cb15bee1814a5bd82eae9fa825275f236e4b747b03933e7f6e922ce14ec7d9499ac0dec5c0d0efc58f358ba
7
+ data.tar.gz: 9dfc5c07628474fc96203be53f18bdec97a98c198bf997c2a0bf448d02c6226c5222bda14fdc9974c9cee2cb08181afa93ac72dfe5427302818f227970556a3f
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ mkmf.log
17
17
  .idea/
18
18
  *.iml
19
19
  .ruby-version
20
+ /*.gem
@@ -35,7 +35,7 @@ module Wovnrb
35
35
  if node.get_attribute('alt')
36
36
  alt = node.get_attribute('alt').strip
37
37
  if @text_index[alt] && @text_index[alt][lang.lang_code] && @text_index[alt][lang.lang_code].size > 0
38
- node.attribute('alt').value = alt.gsub(/^(\s*)[\S\s]*(\s*)$/, '\1' + @text_index[alt][lang.lang_code][0]['data'] + '\2')
38
+ node.attribute('alt').value = replace_text(alt, @text_index[alt][lang.lang_code][0]['data'])
39
39
  end
40
40
  end
41
41
  end
@@ -12,7 +12,7 @@ module Wovnrb
12
12
  node_content = node.get_attribute('content').strip
13
13
  # shouldn't need size check, but for now...
14
14
  if @text_index[node_content] && @text_index[node_content][lang.lang_code] && @text_index[node_content][lang.lang_code].size > 0
15
- node.set_attribute('content', node.get_attribute('content').gsub(/^(\s*)[\S\s]*?(\s*)$/, '\1' + @text_index[node_content][lang.lang_code][0]['data'] + '\2'))
15
+ node.set_attribute('content', replace_text(node.get_attribute('content'), @text_index[node_content][lang.lang_code][0]['data']))
16
16
  end
17
17
  end
18
18
  end
@@ -13,5 +13,9 @@ module Wovnrb
13
13
  end
14
14
  wovn_ignore?(node.parent)
15
15
  end
16
+
17
+ def replace_text(from, to)
18
+ from.gsub(/\A(\s*)[\S\s]*?(\s*)\Z/, '\1' + to + '\2')
19
+ end
16
20
  end
17
21
  end
@@ -11,7 +11,7 @@ module Wovnrb
11
11
  node_text = node.content.strip
12
12
  # shouldn't need size check, but for now...
13
13
  if @text_index[node_text] && @text_index[node_text][lang.lang_code] && @text_index[node_text][lang.lang_code].size > 0
14
- node.content = node.content.gsub(/^(\s*)[\S\s]*?(\s*)$/, '\1' + @text_index[node_text][lang.lang_code][0]['data'] + '\2')
14
+ node.content = replace_text(node.content, @text_index[node_text][lang.lang_code][0]['data'])
15
15
  end
16
16
  end
17
17
  end
data/lib/wovnrb/lang.rb CHANGED
@@ -4,6 +4,7 @@ module Wovnrb
4
4
  LANG = {
5
5
  #http://msdn.microsoft.com/en-us/library/hh456380.aspx
6
6
  'ar' => {name: 'العربية', code: 'ar', en: 'Arabic'},
7
+ 'bg' => {name: 'Български', code: 'bg', en: 'Bulgarian'},
7
8
  'zh-CHS' => {name: '简体中文', code: 'zh-CHS', en: 'Simp Chinese'},
8
9
  'zh-CHT' => {name: '繁體中文', code: 'zh-CHT', en: 'Trad Chinese'},
9
10
  'da' => {name: 'Dansk', code: 'da', en: 'Danish'},
@@ -1,3 +1,3 @@
1
1
  module Wovnrb
2
- VERSION = "0.2.02"
2
+ VERSION = "0.2.03"
3
3
  end
@@ -78,18 +78,6 @@ module Wovnrb
78
78
  assert_equal('さようなら', content2)
79
79
  end
80
80
 
81
- def test_replace_with_space
82
- replacer = MetaReplacer.new({
83
- 'Hello' => {'ja' => [{'data' => 'こんにちは'}]},
84
- })
85
-
86
- dom = Wovnrb.get_dom('<meta property="title" content=" Hello ">')
87
- replacer.replace(dom, Lang.new('ja'))
88
-
89
- content = dom.xpath('//meta')[0].get_attribute('content')
90
- assert_equal(' こんにちは ', content)
91
- end
92
-
93
81
  def test_replace_wovn_ignore
94
82
  replacer = MetaReplacer.new({
95
83
  'Hello' => {'ja' => [{'data' => 'こんにちは'}]},
@@ -26,6 +26,24 @@ module Wovnrb
26
26
 
27
27
  assert_equal(false, actual)
28
28
  end
29
+
30
+ def test_replace_text
31
+ replacer = ReplacerBase.new
32
+ actual = replacer.send(:replace_text, 'Hello', 'こんにちは')
33
+ assert_equal('こんにちは', actual)
34
+ end
35
+
36
+ def test_replace_text_with_space
37
+ replacer = ReplacerBase.new
38
+ actual = replacer.send(:replace_text, ' Hello ', 'こんにちは')
39
+ assert_equal(' こんにちは ', actual)
40
+ end
41
+
42
+ def test_replace_text_with_line_break
43
+ replacer = ReplacerBase.new
44
+ actual = replacer.send(:replace_text, " Hello \n Hello ", 'こんにちは')
45
+ assert_equal(' こんにちは ', actual)
46
+ end
29
47
  end
30
48
  end
31
49
 
@@ -75,7 +75,7 @@ module Wovnrb
75
75
  wovn_data = [
76
76
  ['src', '//j.wovn.io/1'],
77
77
  ['async', 'true'],
78
- ['data-wovnio', "key=#{user_token}&backend=true&currentLang=#{current_lang}&defaultLang=#{default_lang}&urlPattern=#{url_pattern}&version=0.2.01"]
78
+ ['data-wovnio', "key=#{user_token}&backend=true&currentLang=#{current_lang}&defaultLang=#{default_lang}&urlPattern=#{url_pattern}&version=#{Wovnrb::VERSION}"]
79
79
  ]
80
80
  wovn_data.each do |data|
81
81
  assert_equal(data[1], node.get_attribute(data[0]))
@@ -30,18 +30,6 @@ module Wovnrb
30
30
  assert_equal('さようなら', content2)
31
31
  end
32
32
 
33
- def test_replace_with_space
34
- replacer = TextReplacer.new({
35
- 'Hello' => {'ja' => [{'data' => 'こんにちは'}]}
36
- })
37
-
38
- dom = Wovnrb.get_dom(' Hello ')
39
- replacer.replace(dom, Lang.new('ja'))
40
-
41
- content = dom.xpath('//text()')[0].content
42
- assert_equal(' こんにちは ', content)
43
- end
44
-
45
33
  def test_replace_wovn_ignore
46
34
  replacer = TextReplacer.new({
47
35
  'Hello' => {'ja' => [{'data' => 'こんにちは'}]}
@@ -8,6 +8,10 @@ module Wovnrb
8
8
  refute_nil(Wovnrb::Lang::LANG)
9
9
  end
10
10
 
11
+ def test_langs_length
12
+ assert_equal(28, Wovnrb::Lang::LANG.length)
13
+ end
14
+
11
15
  def test_keys_exist
12
16
  Wovnrb::Lang::LANG.each do |k, l|
13
17
  assert(l.has_key?(:name))
data/wovnrb.gemspec CHANGED
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_development_dependency "bundler", "~> 1.7"
33
33
  spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "listen", "~> 3.0.6"
34
35
  ##spec.add_development_dependency "mocha"
35
36
  #spec.add_development_dependency "rspec"
36
37
  #spec.add_development_dependency "rspec-nc"
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.02
4
+ version: 0.2.03
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-21 00:00:00.000000000 Z
12
+ date: 2016-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogumbo
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '10.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: listen
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: 3.0.6
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: 3.0.6
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: test-unit
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -336,7 +350,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
350
  version: '0'
337
351
  requirements: []
338
352
  rubyforge_project:
339
- rubygems_version: 2.2.0
353
+ rubygems_version: 2.4.5.1
340
354
  signing_key:
341
355
  specification_version: 4
342
356
  summary: Gem for WOVN.io
@@ -360,4 +374,3 @@ test_files:
360
374
  - test/lib/wovnrb_test.rb
361
375
  - test/services/url_test.rb
362
376
  - test/test_helper.rb
363
- has_rdoc: