rel_nofollow 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 601c19b25c543cd62133c0d56beca80899b868ae
4
- data.tar.gz: fcab4eb2ed5dcb95207bc81fc62a1d1381708fef
3
+ metadata.gz: b6bdae77508634155873cbb09dbb0c59d6ba2764
4
+ data.tar.gz: 9a35b96e86f0aa6d736f14bbd1d487ba0521c942
5
5
  SHA512:
6
- metadata.gz: 6a5c6c4073f5250a528b4a6a20329a837827f57ea8cbef0e417d5c99babfafe1203953e39313ae56fada3ea7b8ac10f639be270dc29768c413b6a0c299f15acc
7
- data.tar.gz: 3de2645c1f21cca38f9bfb18b8a23743040e55f4b6070323fe71a7291b1bbbc9da6af1718cb538eb463797422a4edc08591954f871708db694ebab16fddb70f7
6
+ metadata.gz: e5dc1a99f1030031ac22bd28be5264b8c2e33193aeac47064ff8a7cb688222c4470a7d1b342c4fb12f7399c5c855f0d8d70d56e9a176fee589b907ec4d253555
7
+ data.tar.gz: a7cf5421fa6305ac12e54486d47b8963401bc914f6856cb3bd1ddf084f5d11da93828fddd7add4b0c9d077021a3370f6dc3ccf4941504837abb8feea24ae3c09
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # RelNofollow
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rel_nofollow`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Add rel="nofollow" to all link in a string
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
@@ -22,17 +21,14 @@ Or install it yourself as:
22
21
 
23
22
  ## Usage
24
23
 
25
- TODO: Write usage instructions here
24
+ simply call
26
25
 
27
- ## Development
26
+ string.add_nofollow
28
27
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
28
 
33
29
  ## Contributing
34
30
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rel_nofollow. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/lmajowka/rel_nofollow. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
32
 
37
33
 
38
34
  ## License
@@ -1,8 +1,10 @@
1
1
  class String
2
2
  def add_nofollow
3
- self.scan(/(\<a href=["'].*?["']\>.*?\<\/a\>)/).flatten.each do |link|
4
- link.match(/(\<a href=["'](.*?)["']\>(.*?)\<\/a\>)/)
5
- self.gsub!(link, "<a href='#{$2}' rel='nofollow'>#{$3}</a>" )
3
+ self.gsub(/<a [^>]+>/) do |link|
4
+ unless aref.include?('rel="nofollow"')
5
+ link = link[0..-2] + ' rel="nofollow">'
6
+ end
7
+ link
6
8
  end
7
9
  end
8
10
  end
@@ -1,3 +1,3 @@
1
1
  module RelNofollow
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rel_nofollow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo