zfben_extend 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zfben_extend/string.rb +7 -3
- data/test/string_test.rb +2 -0
- data/zfben_extend.gemspec +1 -1
- metadata +2 -2
data/lib/zfben_extend/string.rb
CHANGED
@@ -5,7 +5,7 @@ class ZfbenExtend::String < String
|
|
5
5
|
link: true,
|
6
6
|
link_regexp: /[a-zA-Z]{3,}:\/\/\S+/,
|
7
7
|
tag: true,
|
8
|
-
tag_regexp:
|
8
|
+
tag_regexp: /&?#[a-zA-Z0-9]+/,
|
9
9
|
tag_url: '/tags/',
|
10
10
|
mail: true,
|
11
11
|
mail_regexp: /[a-zA-Z0-9.-]+@[a-zA-Z0-9]+\.[a-zA-Z0-9.]+/,
|
@@ -27,8 +27,12 @@ class ZfbenExtend::String < String
|
|
27
27
|
if options[:tag]
|
28
28
|
data[:tag] = []
|
29
29
|
text = text.gsub(options[:tag_regexp]){ |tag|
|
30
|
-
|
31
|
-
|
30
|
+
if tag[0] != '&'
|
31
|
+
data[:tag].push('<a href="' + options[:tag_url] + tag.gsub('#', '') + '">' + tag + '</a>')
|
32
|
+
'ZFBENTAG' + (data[:tag].length - 1).to_s + 'ZFBENTAG'
|
33
|
+
else
|
34
|
+
tag
|
35
|
+
end
|
32
36
|
}
|
33
37
|
end
|
34
38
|
|
data/test/string_test.rb
CHANGED
@@ -28,10 +28,12 @@ class TestToHtml < Test::Unit::TestCase
|
|
28
28
|
assert_equal ZfbenExtend::String.to_html('#a', tag: false), '#a'
|
29
29
|
assert_equal ZfbenExtend::String.to_html('#a'), '<a href="/tags/a">#a</a>'
|
30
30
|
assert_equal ZfbenExtend::String.to_html('text #a #b'), 'text <a href="/tags/a">#a</a> <a href="/tags/b">#b</a>'
|
31
|
+
assert_equal ZfbenExtend::String.to_html(''s'), ''s'
|
31
32
|
|
32
33
|
assert_equal ZfbenExtend::String.new('#a').to_html(tag: false), '#a'
|
33
34
|
assert_equal ZfbenExtend::String.new('#a').to_html, '<a href="/tags/a">#a</a>'
|
34
35
|
assert_equal ZfbenExtend::String.new('text #a #b').to_html, 'text <a href="/tags/a">#a</a> <a href="/tags/b">#b</a>'
|
36
|
+
assert_equal ZfbenExtend::String.new(''s').to_html, ''s'
|
35
37
|
end
|
36
38
|
|
37
39
|
def test_mail
|
data/zfben_extend.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfben_extend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01
|
12
|
+
date: 2012-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ''
|
15
15
|
email:
|