link_url 0.0.6 → 0.0.7
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/link_url.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 466d88f3e52220341ebe06279e6e37a18b48c634
|
4
|
+
data.tar.gz: 336ba9b934657eb9b4fce2d568cf7e7690208fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 224f94d4f54352334605d1f5dffb1f1c112cd98d22c2ff0f20e52e47258ca933dea047cda0789e896dd0dd09843d1c5d65fbcc3bc3993d6eed9196a2ecdb6667
|
7
|
+
data.tar.gz: 3492717f05fbf0986dbd9e69034650f2078bdaca5dfb67ba23b5a373e4fde5d3bc3f86af76e7ed1d8ed0a1e3c11dd97933e2139c03552034ffc5448712c68727
|
data/lib/link_url.rb
CHANGED
@@ -11,6 +11,8 @@ class LinkUrl
|
|
11
11
|
# => Hi I have updated the code. my website is www.ashishprajapati.com you can see my pic using <img src='www.ashishprajapati.com/ashish.png' />
|
12
12
|
# >> LinkUrl.convert_all("Hi I have updated the code. my website is www.ashishprajapati.com you can see my pic using www.ashishprajapati.com/ashish.png")
|
13
13
|
# => Hi I have updated the code. my website is <a href='www.ashishprajapati.com'>www.ashishprajapati.com</a> you can see my pic using <img src='www.ashishprajapati.com/ashish.png' />
|
14
|
+
# >> LinkUrl.convert_all("Hello my email is mail@ashishprajapati.com . You can visit my blog at clecotech.in")
|
15
|
+
# => Hello my email is <a href='mailto:mail@ashishprajapati.com'>mail@ashishprajapati.com</a> . You can visit my blog at <a href='http://clecotech.in'>clecotech.in</a>
|
14
16
|
# Arguments:
|
15
17
|
# content: (String)
|
16
18
|
# Convert all url into links.
|
@@ -18,7 +20,9 @@ class LinkUrl
|
|
18
20
|
if(content)
|
19
21
|
exp =/\b(((?:mailto:\S+|(?:https?|ftp|file):\/\/|www.)[^\s<]+)|[^\s<]+(#{self.tlds.values.join('|\\')}))\b/
|
20
22
|
content = content.gsub(exp) do |url|
|
21
|
-
if (url
|
23
|
+
if (url=~/@+[^\s<]+(#{self.tlds.values.join('|\\')})/)!=nil
|
24
|
+
"<a href='mailto:#{url}'>#{url}</a>"
|
25
|
+
elsif (url=~/http:\/\/|https:\/\/|ftp:\/\/|file:\/\/|www\./)!=0 && url[/(#{self.tlds.values.join('|\\')})$/]
|
22
26
|
"<a href='http://#{url}'>#{url}</a>"
|
23
27
|
else
|
24
28
|
"<a href='#{url}'>#{url}</a>".gsub("<a href='www.","<a href='http://www.");
|
@@ -47,6 +51,8 @@ class LinkUrl
|
|
47
51
|
content = content.gsub(exp) do |url|
|
48
52
|
if url[/(?:png|jpe?g|gif|svg|bmp)$/]
|
49
53
|
"<img src='#{url}' />"
|
54
|
+
elsif (url=~/@+[^\s<]+(#{self.tlds.values.join('|\\')})/)!=nil
|
55
|
+
"<a href='mailto:#{url}'>#{url}</a>"
|
50
56
|
elsif (url=~/http:\/\/|https:\/\/|ftp:\/\/|file:\/\/|www\./)!=0 && url[/(#{self.tlds.values.join('|\\')})$/]
|
51
57
|
"<a href='http://#{url}'>#{url}</a>"
|
52
58
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ashish Prajapati
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Convert any image url into the image tag sepratedly and remain other
|
14
14
|
url normal by using LinkUrl.convert_image("www.clecotech.in http://www.ashishprajapati.com/new.png").
|