url_link 0.0.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/url_link.rb +26 -6
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77b5f6ffbf1ad8d71fed3ce6a923442fdf6d6b81
|
4
|
+
data.tar.gz: 12577c7b67d7eb22b346fcd3a52a072c3a41ef0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9b9f016e7b369007fbbd0b0ae608e565ffb346022eff2371de0a57410ee198af5532fbe12c89713e853015556e1e891d03ba2ccf6f9b428104fecd41c74bfad
|
7
|
+
data.tar.gz: f7ac31203fd7b96daab843dfa47946bd4f14c4ea5ac870ca3841076906903c84a81d9cf1d0c3af066708b9031db18f6a1a7b51fb406fcd714f5659487695dcf3
|
data/lib/url_link.rb
CHANGED
@@ -3,9 +3,14 @@ module UrlLink
|
|
3
3
|
module Helpers # :nodoc:
|
4
4
|
module TextHelper
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def proper_url_link(url_link)
|
7
|
+
unless url_link.blank?
|
8
|
+
|
9
|
+
url_link.gsub( /\s*([^\s]+@[^\s]+\.[^\s]+)\s*/ ) do |email_to|
|
10
|
+
"<a href='mailto:#{email_to}'>#{email_to}</a>"
|
11
|
+
end
|
12
|
+
|
13
|
+
url_link.gsub( %r{(http|https)://[^\s<]+} ) do |url|
|
9
14
|
if url[/(?:png|jpe?g|gif|svg)$/]
|
10
15
|
"<img src='#{url}' />"
|
11
16
|
else
|
@@ -15,14 +20,29 @@ module UrlLink
|
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
|
-
def url_link
|
23
|
+
def proper_email(url_link)
|
24
|
+
unless url_link.blank?
|
25
|
+
url_link.gsub( /\s*([^\s]+@[^\s]+\.[^\s]+)\s*/ ) do |email_to|
|
26
|
+
"<a href='mailto:#{email_to}'>#{email_to}</a>"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def proper_html(html_format)
|
19
32
|
unless html_format.blank?
|
20
33
|
html_format.html_safe
|
21
34
|
end
|
22
35
|
end
|
23
36
|
|
24
|
-
|
25
|
-
|
37
|
+
def url_link(url_link_format)
|
38
|
+
unless url_link_format.blank?
|
39
|
+
proper_html(proper_email(proper_url_link(url_link_format)))
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
26
46
|
end
|
27
47
|
|
28
48
|
end
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_link
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Austria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Convert all the urls from text or string to Url
|
14
|
-
<a target="_blank" https://www.facebook.com/marcelo.austria.1">https://www.facebook.com/marcelo.austria.1</a>,
|
15
|
-
http://blogspot.com/images/screenshot.png <img src="http://blogspot.com/images/screenshot.png"/>"
|
13
|
+
description: Convert all the urls, img url and email from text or string to Url Link
|
14
|
+
(https://www.facebook.com/marcelo.austria.1 to => <a target="_blank" https://www.facebook.com/marcelo.austria.1">https://www.facebook.com/marcelo.austria.1</a>,
|
15
|
+
http://blogspot.com/images/screenshot.png to => <img src="http://blogspot.com/images/screenshot.png"/>",
|
16
|
+
marceloaustria@yahoo.com to => <a href="mailto:marceloaustria@yahoo.com">marceloaustria@yahoo.com</a>)
|
16
17
|
email: marceloaustria@yahoo.com
|
17
18
|
executables: []
|
18
19
|
extensions: []
|