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 +4 -4
- data/.gitignore +1 -0
- data/lib/wovnrb/html_replacers/image_replacer.rb +1 -1
- data/lib/wovnrb/html_replacers/meta_replacer.rb +1 -1
- data/lib/wovnrb/html_replacers/replacer_base.rb +4 -0
- data/lib/wovnrb/html_replacers/text_replacer.rb +1 -1
- data/lib/wovnrb/lang.rb +1 -0
- data/lib/wovnrb/version.rb +1 -1
- data/test/lib/html_replacers/meta_replacer_test.rb +0 -12
- data/test/lib/html_replacers/replacer_base_test.rb +18 -0
- data/test/lib/html_replacers/script_replacer_test.rb +1 -1
- data/test/lib/html_replacers/text_replacer_test.rb +0 -12
- data/test/lib/lang_test.rb +4 -0
- data/wovnrb.gemspec +1 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 331efba8ea791590ae759615aa853a4379a8633f
|
4
|
+
data.tar.gz: 95325d00b3d635fa06b2acd30ffde80a17d722ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aa88813f3efce6b9990c31f2e82d6ec80f0fe445cb15bee1814a5bd82eae9fa825275f236e4b747b03933e7f6e922ce14ec7d9499ac0dec5c0d0efc58f358ba
|
7
|
+
data.tar.gz: 9dfc5c07628474fc96203be53f18bdec97a98c198bf997c2a0bf448d02c6226c5222bda14fdc9974c9cee2cb08181afa93ac72dfe5427302818f227970556a3f
|
data/.gitignore
CHANGED
@@ -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
|
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')
|
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
|
@@ -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
|
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'},
|
data/lib/wovnrb/version.rb
CHANGED
@@ -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¤tLang=#{current_lang}&defaultLang=#{default_lang}&urlPattern=#{url_pattern}&version
|
78
|
+
['data-wovnio', "key=#{user_token}&backend=true¤tLang=#{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' => 'こんにちは'}]}
|
data/test/lib/lang_test.rb
CHANGED
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.
|
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-
|
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.
|
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:
|