follow_redirect 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/follow_redirect.gemspec +24 -0
- data/lib/follow_redirect.rb +23 -0
- data/lib/follow_redirect/version.rb +3 -0
- metadata +54 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@follow_redirect
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "follow_redirect/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "follow_redirect"
|
7
|
+
s.version = FollowRedirect::VERSION
|
8
|
+
s.authors = ["Stewart McKee"]
|
9
|
+
s.email = ["stewart@theizone.co.uk"]
|
10
|
+
s.homepage = "http://github.com/stewartmckee/follow_redirect"
|
11
|
+
s.summary = %q{This gem allows you to find a url's evenutal target. Its intended use is to remove shortened urls in social media}
|
12
|
+
s.description = %q{This gem allows you to find a url's evenutal target. Its intended use is to remove shortened urls in social media}
|
13
|
+
|
14
|
+
s.rubyforge_project = "follow_redirect"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "follow_redirect/version"
|
2
|
+
require 'uri'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module FollowRedirect
|
6
|
+
|
7
|
+
class Url
|
8
|
+
def self.resolve(url)
|
9
|
+
redirect_limit = 10
|
10
|
+
(0..9).each do
|
11
|
+
uri = URI.parse(url)
|
12
|
+
response = nil
|
13
|
+
Net::HTTP.start(uri.host, uri.port) {|http|
|
14
|
+
response = http.head(uri.request_uri)
|
15
|
+
}
|
16
|
+
break unless response.key?("Location")
|
17
|
+
url = response['Location']
|
18
|
+
end
|
19
|
+
url
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: follow_redirect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stewart McKee
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: This gem allows you to find a url's evenutal target. Its intended use
|
15
|
+
is to remove shortened urls in social media
|
16
|
+
email:
|
17
|
+
- stewart@theizone.co.uk
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- .rvmrc
|
24
|
+
- Gemfile
|
25
|
+
- Rakefile
|
26
|
+
- follow_redirect.gemspec
|
27
|
+
- lib/follow_redirect.rb
|
28
|
+
- lib/follow_redirect/version.rb
|
29
|
+
homepage: http://github.com/stewartmckee/follow_redirect
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: follow_redirect
|
49
|
+
rubygems_version: 1.8.10
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: This gem allows you to find a url's evenutal target. Its intended use is
|
53
|
+
to remove shortened urls in social media
|
54
|
+
test_files: []
|