long_url 0.0.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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/lib/long_url.rb +15 -0
- data/lib/long_url/version.rb +3 -0
- data/long_url.gemspec +19 -0
- data/spec/long_url_spec.rb +11 -0
- data/spec/spec_helper.rb +7 -0
- metadata +66 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/lib/long_url.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "net/http"
|
|
2
|
+
|
|
3
|
+
require "long_url/version"
|
|
4
|
+
|
|
5
|
+
module LongURL
|
|
6
|
+
def self.find(url)
|
|
7
|
+
response = Net::HTTP.get_response(URI.parse(url))
|
|
8
|
+
case response
|
|
9
|
+
when Net::HTTPRedirection
|
|
10
|
+
find(response['location'])
|
|
11
|
+
else
|
|
12
|
+
url
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/long_url.gemspec
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/long_url/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Utkarsh Kukreti"]
|
|
6
|
+
gem.email = ["utkarshkukreti@gmail.com"]
|
|
7
|
+
gem.description = %q{Longens urls like bit.ly, t.co, etc.}
|
|
8
|
+
gem.summary = %q{Longens urls like bit.ly, t.co, etc.}
|
|
9
|
+
gem.homepage = ""
|
|
10
|
+
|
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
14
|
+
gem.name = "long_url"
|
|
15
|
+
gem.require_paths = ["lib"]
|
|
16
|
+
gem.version = LongURL::VERSION
|
|
17
|
+
|
|
18
|
+
gem.add_development_dependency 'rspec'
|
|
19
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe LongURL do
|
|
4
|
+
it "should have a version" do
|
|
5
|
+
LongURL::VERSION.should be_a(String)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should work" do
|
|
9
|
+
LongURL.find("http://t.co/ttI9YPQ").should eq("http://twitter.com/fxn/status/112541008784408576/photo/1")
|
|
10
|
+
end
|
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: long_url
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Utkarsh Kukreti
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2011-09-26 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rspec
|
|
16
|
+
requirement: &70341582426940 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70341582426940
|
|
25
|
+
description: Longens urls like bit.ly, t.co, etc.
|
|
26
|
+
email:
|
|
27
|
+
- utkarshkukreti@gmail.com
|
|
28
|
+
executables: []
|
|
29
|
+
extensions: []
|
|
30
|
+
extra_rdoc_files: []
|
|
31
|
+
files:
|
|
32
|
+
- .gitignore
|
|
33
|
+
- Gemfile
|
|
34
|
+
- Rakefile
|
|
35
|
+
- lib/long_url.rb
|
|
36
|
+
- lib/long_url/version.rb
|
|
37
|
+
- long_url.gemspec
|
|
38
|
+
- spec/long_url_spec.rb
|
|
39
|
+
- spec/spec_helper.rb
|
|
40
|
+
homepage: ''
|
|
41
|
+
licenses: []
|
|
42
|
+
post_install_message:
|
|
43
|
+
rdoc_options: []
|
|
44
|
+
require_paths:
|
|
45
|
+
- lib
|
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
47
|
+
none: false
|
|
48
|
+
requirements:
|
|
49
|
+
- - ! '>='
|
|
50
|
+
- !ruby/object:Gem::Version
|
|
51
|
+
version: '0'
|
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
|
+
none: false
|
|
54
|
+
requirements:
|
|
55
|
+
- - ! '>='
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: '0'
|
|
58
|
+
requirements: []
|
|
59
|
+
rubyforge_project:
|
|
60
|
+
rubygems_version: 1.8.10
|
|
61
|
+
signing_key:
|
|
62
|
+
specification_version: 3
|
|
63
|
+
summary: Longens urls like bit.ly, t.co, etc.
|
|
64
|
+
test_files:
|
|
65
|
+
- spec/long_url_spec.rb
|
|
66
|
+
- spec/spec_helper.rb
|