hugeurl 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 0.0.7 2012-09-13
2
+
3
+ * expand nested short url
4
+
1
5
  === 0.0.6 2012-06-28
2
6
 
3
7
  * little fix
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
3
  require 'hugeurl'
4
- #require File.dirname(__FILE__)+'/../lib/hugeurl'
4
+ #require File.expand_path '../lib/hugeurl', File.dirname(__FILE__)
5
5
 
6
6
  unless ARGV.empty?
7
7
  puts URI.parse(ARGV.shift).to_huge
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- require File.dirname(__FILE__)+'/../lib/hugeurl'
2
+ $:.unshift File.expand_path '../lib', File.dirname(__FILE__)
3
+
4
+ require 'rubygems'
5
+ require 'hugeurl'
3
6
 
4
7
  puts tinyurl = "http://tinyurl.com/242tthb"
5
8
  puts " => " + Hugeurl.get(tinyurl).to_s
@@ -13,3 +16,6 @@ puts " => #{tco.to_huge}"
13
16
 
14
17
  puts gyamp = URI.parse("http://gyamp.com/shokai/shokai")
15
18
  puts " => #{gyamp.to_huge}"
19
+
20
+ puts bitly_tinyurl_nested = URI.parse("http://bit.ly/TSLl6M")
21
+ puts " => #{bitly_tinyurl_nested.to_huge}"
@@ -4,9 +4,18 @@ require 'net/http'
4
4
  require 'net/https'
5
5
 
6
6
  module Hugeurl
7
- VERSION = '0.0.6'
7
+ VERSION = '0.0.7'
8
8
  def self.get(uri)
9
9
  uri = URI.parse uri unless uri.class.to_s =~ /^URI::/
10
+ loop do
11
+ res = self.get_redirect_to uri
12
+ return res if res.to_s == uri.to_s
13
+ uri = res
14
+ end
15
+ end
16
+
17
+ private
18
+ def self.get_redirect_to(uri)
10
19
  if uri.class == URI::HTTPS
11
20
  http = Net::HTTP.new(uri.host, 443)
12
21
  http.use_ssl = true
@@ -1,3 +1,3 @@
1
1
  require 'stringio'
2
2
  require 'test/unit'
3
- require File.dirname(__FILE__) + '/../lib/hugeurl'
3
+ require File.expand_path '../lib/hugeurl', File.dirname(__FILE__)
@@ -6,6 +6,7 @@ class TestHugeurl < Test::Unit::TestCase
6
6
  @source = "http://shokai.org"
7
7
  @tinyurl = URI.parse("http://tinyurl.com/242tthb").to_huge
8
8
  @tco = URI.parse("http://t.co/sdMbEC7n").to_huge
9
+ @bitly_tinyurl_nested = URI.parse("http://bit.ly/TSLl6M").to_huge
9
10
  end
10
11
 
11
12
  def test_response
@@ -20,4 +21,7 @@ class TestHugeurl < Test::Unit::TestCase
20
21
  assert @tinyurl.to_s == @source
21
22
  end
22
23
 
24
+ def test_bitly_tinyurl_nested
25
+ assert @bitly_tinyurl_nested.to_s == @source
26
+ end
23
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hugeurl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-27 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdoc