redirect_follower 0.1.0 → 0.1.1
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.
- data/README.rdoc +10 -1
- data/VERSION +1 -1
- data/lib/redirect_follower.rb +2 -2
- data/redirect_follower.gemspec +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ out their destination url as well as the body.
|
|
5
5
|
|
6
6
|
The code is mostly ripped from John Nunemaker's blog post "Following Redirects with Net/HTTP"
|
7
7
|
(http://railstips.org/blog/archives/2009/03/04/following-redirects-with-nethttp/), but wrapped
|
8
|
-
into a Rubygem
|
8
|
+
into a Rubygem and with automatic resolving
|
9
9
|
|
10
10
|
Install with:
|
11
11
|
|
@@ -28,6 +28,15 @@ Then, either shorthand for the destination url only or for the full response:
|
|
28
28
|
> redirect.response
|
29
29
|
=> # Full response object from Net::HTTP
|
30
30
|
|
31
|
+
Limiting the amount of redirects can be achieved by giving a second parameter to either
|
32
|
+
methods:
|
33
|
+
|
34
|
+
<code>RedirectFollower('http://is.gd/bNZYZ', 2)</code> will only follow two redirects before
|
35
|
+
raising <code>RedirectFollower::TooManyRedirects</code>. Same thing for
|
36
|
+
<code>RedirectFollower.new('http://is.gd/bNZYZ', 2)</code>. The default amount of redirects
|
37
|
+
is 5.
|
38
|
+
|
39
|
+
You can also check out my introductory blog post at http://colszowka.heroku.com/2010/04/30/redirectfollower-rubygem
|
31
40
|
|
32
41
|
== Note on Patches/Pull Requests
|
33
42
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/redirect_follower.rb
CHANGED
@@ -4,8 +4,8 @@ require 'net/http'
|
|
4
4
|
# Shorthand for RedirectFollower.new(url).resolve.url - just get the
|
5
5
|
# destination url for given url
|
6
6
|
#
|
7
|
-
def RedirectFollower(url)
|
8
|
-
RedirectFollower.new(url).url
|
7
|
+
def RedirectFollower(url, limit=5)
|
8
|
+
RedirectFollower.new(url, limit).url
|
9
9
|
end
|
10
10
|
|
11
11
|
#
|
data/redirect_follower.gemspec
CHANGED