hugeurl 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+
2
+ === 0.0.3 2012-04-10
3
+
4
+ * use HTTP-HEAD and check location param of HTTP Response.
5
+
1
6
  === 0.0.1 2010-09-17
2
7
 
3
8
  * start project
data/Manifest.txt CHANGED
@@ -6,9 +6,6 @@ lib/hugeurl.rb
6
6
  script/console
7
7
  script/destroy
8
8
  script/generate
9
- spec/hugeurl_spec.rb
10
- spec/uri_spec.rb
11
- spec/spec.opts
12
- spec/spec_helper.rb
13
- tasks/rspec.rake
14
9
  examples/example.rb
10
+ test/test_helper.rb
11
+ test/test_hugeurl.rb
data/README.rdoc CHANGED
@@ -15,7 +15,7 @@ expand tinyurl and bit.ly
15
15
 
16
16
  == REQUIREMENTS:
17
17
 
18
- * http://search.twitter.com/hugeurl?url=
18
+ * Ruby 1.8+
19
19
 
20
20
  == INSTALL:
21
21
 
data/examples/example.rb CHANGED
@@ -1,10 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.dirname(__FILE__)+'/../lib/hugeurl'
3
3
 
4
- tinyurl = URI.parse("http://tinyurl.com/242tthb")
5
- puts tinyurl
6
- puts " => " + tinyurl.to_huge.to_s
4
+ puts tinyurl = "http://tinyurl.com/242tthb"
5
+ puts " => " + Hugeurl.get(tinyurl).to_s
7
6
 
8
7
  bitly = URI.parse("http://bit.ly/d4VYD2")
9
8
  puts bitly
10
9
  puts " => " + bitly.to_huge.to_s
10
+
11
+ puts tco = URI.parse("http://t.co/sdMbEC7n")
12
+ puts " => #{tco.to_huge}"
13
+
14
+ puts gyamp = URI.parse("http://gyamp.com/shokai/shokai")
15
+ puts " => #{gyamp.to_huge}"
data/lib/hugeurl.rb CHANGED
@@ -3,13 +3,15 @@ $:.unshift(File.dirname(__FILE__)) unless
3
3
 
4
4
  require 'rubygems'
5
5
  require 'uri'
6
- require 'open-uri'
6
+ require 'net/http'
7
7
 
8
8
  module Hugeurl
9
- VERSION = '0.0.2'
10
- def Hugeurl.get(url)
11
- res = open("http://search.twitter.com/hugeurl?url=#{url.to_s}").read
12
- URI.parse(res)
9
+ VERSION = '0.0.3'
10
+ def self.get(url)
11
+ url = URI.parse url unless url.class.to_s =~ /^URI::/
12
+ res = Net::HTTP.start(url.host, url.port).
13
+ head(url.path.size < 1 ? '/' : url.path)
14
+ URI.parse res['location'] rescue return url
13
15
  end
14
16
  end
15
17
 
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/hugeurl'
@@ -0,0 +1,23 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestHugeurl < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @source = "http://shokai.org"
7
+ @tinyurl = URI.parse("http://tinyurl.com/242tthb").to_huge
8
+ @tco = URI.parse("http://t.co/sdMbEC7n").to_huge
9
+ end
10
+
11
+ def test_response
12
+ assert true if @tco.class == URI::HTTP
13
+ end
14
+
15
+ def test_tco
16
+ assert true if @tco.to_s == @source
17
+ end
18
+
19
+ def test_tinyurl
20
+ assert true if @tinyurl.to_s == @source
21
+ end
22
+
23
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hugeurl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 25
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sho Hashimoto
@@ -15,41 +15,54 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-18 00:00:00 +09:00
19
- default_executable:
18
+ date: 2012-04-10 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: rubyforge
21
+ name: rdoc
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
- - - ">="
26
+ - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 7
28
+ hash: 19
30
29
  segments:
31
- - 2
32
- - 0
33
- - 4
34
- version: 2.0.4
30
+ - 3
31
+ - 10
32
+ version: "3.10"
35
33
  type: :development
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
38
- name: hoe
36
+ name: newgem
39
37
  prerelease: false
40
38
  requirement: &id002 !ruby/object:Gem::Requirement
41
39
  none: false
42
40
  requirements:
43
41
  - - ">="
44
42
  - !ruby/object:Gem::Version
45
- hash: 21
43
+ hash: 5
46
44
  segments:
47
- - 2
48
- - 6
49
45
  - 1
50
- version: 2.6.1
46
+ - 5
47
+ - 3
48
+ version: 1.5.3
51
49
  type: :development
52
50
  version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: hoe
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 29
60
+ segments:
61
+ - 2
62
+ - 15
63
+ version: "2.15"
64
+ type: :development
65
+ version_requirements: *id003
53
66
  description: expand tinyurl and bit.ly
54
67
  email:
55
68
  - hashimoto@shokai.org
@@ -60,6 +73,7 @@ extensions: []
60
73
  extra_rdoc_files:
61
74
  - History.txt
62
75
  - Manifest.txt
76
+ - README.rdoc
63
77
  files:
64
78
  - History.txt
65
79
  - Manifest.txt
@@ -69,13 +83,10 @@ files:
69
83
  - script/console
70
84
  - script/destroy
71
85
  - script/generate
72
- - spec/hugeurl_spec.rb
73
- - spec/uri_spec.rb
74
- - spec/spec.opts
75
- - spec/spec_helper.rb
76
- - tasks/rspec.rake
77
86
  - examples/example.rb
78
- has_rdoc: true
87
+ - test/test_helper.rb
88
+ - test/test_hugeurl.rb
89
+ - .gemtest
79
90
  homepage: http://github.com/shokai/hugeurl
80
91
  licenses: []
81
92
 
@@ -106,9 +117,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
117
  requirements: []
107
118
 
108
119
  rubyforge_project: hugeurl
109
- rubygems_version: 1.3.7
120
+ rubygems_version: 1.8.17
110
121
  signing_key:
111
122
  specification_version: 3
112
123
  summary: expand tinyurl and bit.ly
113
- test_files: []
114
-
124
+ test_files:
125
+ - test/test_helper.rb
126
+ - test/test_hugeurl.rb
data/spec/hugeurl_spec.rb DELETED
@@ -1,31 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- require 'uri'
3
-
4
- describe Hugeurl, 'expand URL string "http://tinyurl.com/242tthb"' do
5
- before(:all) do
6
- @res = Hugeurl.get("http://tinyurl.com/242tthb")
7
- end
8
-
9
- it 'should return URI instance' do
10
- @res.class.should == URI::HTTP
11
- end
12
-
13
- it 'should return expanded URI' do
14
- @res.to_s.should == 'http://shokai.org'
15
- end
16
- end
17
-
18
- describe Hugeurl, 'expand URI instance "http://bit.ly/d4VYD2"' do
19
- before(:all) do
20
- @res = Hugeurl.get(URI.parse("http://bit.ly/d4VYD2"))
21
- end
22
-
23
- it 'should return URI instance' do
24
- @res.class.should == URI::HTTP
25
- end
26
-
27
- it 'should return expanded URI' do
28
- @res.to_s.should == 'http://shokai.org'
29
- end
30
- end
31
-
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --colour -fs
data/spec/spec_helper.rb DELETED
@@ -1,10 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- gem 'rspec'
6
- require 'spec'
7
- end
8
-
9
- $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'hugeurl'
data/spec/uri_spec.rb DELETED
@@ -1,17 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper.rb'
2
- require 'uri'
3
-
4
- describe URI, 'URI.to_huge' do
5
- before(:all) do
6
- @res = URI.parse("http://tinyurl.com/242tthb").to_huge
7
- end
8
-
9
- it 'should return URI instance' do
10
- @res.class.should == URI::HTTP
11
- end
12
-
13
- it 'should return expanded URI' do
14
- @res.to_s.should == 'http://shokai.org'
15
- end
16
- end
17
-
data/tasks/rspec.rake DELETED
@@ -1,21 +0,0 @@
1
- begin
2
- require 'spec'
3
- rescue LoadError
4
- require 'rubygems' unless ENV['NO_RUBYGEMS']
5
- require 'spec'
6
- end
7
- begin
8
- require 'spec/rake/spectask'
9
- rescue LoadError
10
- puts <<-EOS
11
- To use rspec for testing you must install rspec gem:
12
- gem install rspec
13
- EOS
14
- exit(0)
15
- end
16
-
17
- desc "Run the specs under spec/models"
18
- Spec::Rake::SpecTask.new do |t|
19
- t.spec_opts = ['--options', "spec/spec.opts"]
20
- t.spec_files = FileList['spec/**/*_spec.rb']
21
- end