link_url 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/link_url.rb +7 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 322ea29ada7ce42ae9ea7ea99c045f7c64cdb239
4
- data.tar.gz: 48e9e72fee7dd1a223084884809a2efa015e923f
3
+ metadata.gz: 466d88f3e52220341ebe06279e6e37a18b48c634
4
+ data.tar.gz: 336ba9b934657eb9b4fce2d568cf7e7690208fce
5
5
  SHA512:
6
- metadata.gz: 79022c954579c8ab97355e469126b20ea1ff7b212c34a877466b9f193f29131b213cb662a8271c0d00da0b9fa3c9fc7d396dcb5c8f6ff0701a33b635ee2c81b3
7
- data.tar.gz: 13e2a75a8cea30295b67762ab09415f5845e0b2d4ebc5537a89225ca6ede74da257ee19b190d565471f3f78e3888880b7e3b14faf84b3b887bc8b5abc07e0e77
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=~/http:\/\/|https:\/\/|ftp:\/\/|file:\/\/|www\./)!=0 && url[/(#{self.tlds.values.join('|\\')})$/]
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.6
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-13 00:00:00.000000000 Z
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").