hugeurl 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/History.txt +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +47 -0
- data/Rakefile +5 -22
- data/bin/hugeurl +1 -1
- data/hugeurl.gemspec +24 -0
- data/lib/hugeurl.rb +7 -32
- data/lib/hugeurl/main.rb +26 -0
- data/lib/hugeurl/uri.rb +5 -0
- data/lib/hugeurl/version.rb +3 -0
- data/{examples/example.rb → samples/sample.rb} +0 -1
- data/test/test_helper.rb +5 -3
- data/test/test_hugeurl.rb +2 -2
- metadata +36 -43
- data/.gemtest +0 -0
- data/Manifest.txt +0 -12
- data/README.rdoc +0 -57
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b4ebb3a4ec6a291dda7afbcf1d79273451c01d32
|
4
|
+
data.tar.gz: 3ccc0181dde61a6769eecbc994e103372118c38d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7efc675812ded6b12745fcb046f9ff2728cd3f908dd63237f9b6fcfc199c9dca6ec32daeef93576c3d8d6c275b6ad91bae6690efa06b286496c24d1c4df0f31
|
7
|
+
data.tar.gz: 4e7939d1e3913d2d4008a7864a0139a655aead0aadeea04c651f224a0295bb861b5ec5844ed0a416cddf8118c0570a259368a2bc61163203337ec31783f7a7c7
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/History.txt
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2010-2013 Sho Hashimoto
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
hugeurl
|
2
|
+
=======
|
3
|
+
expand tinyurl, bit.ly, t.co and more.
|
4
|
+
|
5
|
+
* https://github.com/shokai/hugeurl
|
6
|
+
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
% gem install hugeurl
|
12
|
+
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'rubygems'
|
19
|
+
require 'hugeurl'
|
20
|
+
puts URI.parse("http://bit.ly/d4VYD2").to_huge # => get expanded URI instance
|
21
|
+
```
|
22
|
+
|
23
|
+
### hugeurl command
|
24
|
+
|
25
|
+
% hugeurl http://bit.ly/d4VYD2
|
26
|
+
|
27
|
+
or
|
28
|
+
|
29
|
+
% cat url_list.txt | hugeurl
|
30
|
+
|
31
|
+
|
32
|
+
Test
|
33
|
+
----
|
34
|
+
|
35
|
+
% gem install bundler
|
36
|
+
% bundle install
|
37
|
+
% rake test
|
38
|
+
|
39
|
+
|
40
|
+
Contributing
|
41
|
+
------------
|
42
|
+
|
43
|
+
1. Fork it
|
44
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
45
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
46
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
47
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
@@ -1,25 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'hoe'
|
4
|
-
require 'fileutils'
|
5
|
-
require './lib/hugeurl'
|
6
|
-
|
7
|
-
Hoe.plugin :newgem
|
8
|
-
# Hoe.plugin :website
|
9
|
-
# Hoe.plugin :cucumberfeatures
|
10
|
-
|
11
|
-
# Generate all the Rake tasks
|
12
|
-
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
-
$hoe = Hoe.spec 'hugeurl' do
|
14
|
-
self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
|
15
|
-
self.rubyforge_name = self.name # TODO this is default value
|
16
|
-
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
17
3
|
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.pattern = "test/test_*.rb"
|
18
6
|
end
|
19
7
|
|
20
|
-
|
21
|
-
Dir['tasks/**/*.rake'].each { |t| load t }
|
22
|
-
|
23
|
-
# TODO - want other tests/tasks run by default? Add them to the list
|
24
|
-
# remove_task :default
|
25
|
-
# task :default => [:spec, :features]
|
8
|
+
task :default => :test
|
data/bin/hugeurl
CHANGED
data/hugeurl.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hugeurl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hugeurl"
|
8
|
+
spec.version = Hugeurl::VERSION
|
9
|
+
spec.authors = ["Sho Hashimoto"]
|
10
|
+
spec.email = ["hashimoto@shokai.org"]
|
11
|
+
spec.description = %q{expand tinyurl, bit.ly, t.co and more.}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/shokai/hugeurl"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/).reject{|i| i == "Gemfile.lock" }
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "minitest"
|
24
|
+
end
|
data/lib/hugeurl.rb
CHANGED
@@ -1,35 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require 'net/https'
|
1
|
+
require "uri"
|
2
|
+
require "net/http"
|
3
|
+
require "net/https"
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
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)
|
19
|
-
if uri.class == URI::HTTPS
|
20
|
-
http = Net::HTTP.new(uri.host, 443)
|
21
|
-
http.use_ssl = true
|
22
|
-
else
|
23
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
24
|
-
end
|
25
|
-
res = http.request(Net::HTTP::Head.new uri.request_uri)
|
26
|
-
return uri unless res['location']
|
27
|
-
URI.parse res['location'] rescue return uri
|
28
|
-
end
|
29
|
-
end
|
5
|
+
require "hugeurl/version"
|
6
|
+
require "hugeurl/main"
|
7
|
+
require "hugeurl/uri"
|
30
8
|
|
31
|
-
|
32
|
-
def to_huge
|
33
|
-
Hugeurl.get(self)
|
34
|
-
end
|
9
|
+
module Hugeurl
|
35
10
|
end
|
data/lib/hugeurl/main.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Hugeurl
|
2
|
+
|
3
|
+
public
|
4
|
+
def self.get(uri)
|
5
|
+
uri = URI.parse uri unless uri.class.to_s =~ /^URI::/
|
6
|
+
loop do
|
7
|
+
res = self.get_redirect_to uri
|
8
|
+
return res if res.to_s == uri.to_s
|
9
|
+
uri = res
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def self.get_redirect_to(uri)
|
15
|
+
if uri.class == URI::HTTPS
|
16
|
+
http = Net::HTTP.new(uri.host, 443)
|
17
|
+
http.use_ssl = true
|
18
|
+
else
|
19
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
20
|
+
end
|
21
|
+
res = http.request(Net::HTTP::Head.new uri.request_uri)
|
22
|
+
return uri unless res['location']
|
23
|
+
URI.parse res['location'] rescue return uri
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/hugeurl/uri.rb
ADDED
data/test/test_helper.rb
CHANGED
data/test/test_hugeurl.rb
CHANGED
metadata
CHANGED
@@ -1,113 +1,106 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hugeurl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.8
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sho Hashimoto
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-04-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3
|
19
|
+
version: '1.3'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3
|
26
|
+
version: '1.3'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
28
|
+
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: minitest
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
54
|
+
version: '0'
|
62
55
|
description: expand tinyurl, bit.ly, t.co and more.
|
63
56
|
email:
|
64
57
|
- hashimoto@shokai.org
|
65
58
|
executables:
|
66
59
|
- hugeurl
|
67
60
|
extensions: []
|
68
|
-
extra_rdoc_files:
|
69
|
-
- History.txt
|
70
|
-
- Manifest.txt
|
71
|
-
- README.rdoc
|
61
|
+
extra_rdoc_files: []
|
72
62
|
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
73
65
|
- History.txt
|
74
|
-
-
|
75
|
-
- README.
|
66
|
+
- LICENSE.txt
|
67
|
+
- README.md
|
76
68
|
- Rakefile
|
69
|
+
- bin/hugeurl
|
70
|
+
- hugeurl.gemspec
|
77
71
|
- lib/hugeurl.rb
|
72
|
+
- lib/hugeurl/main.rb
|
73
|
+
- lib/hugeurl/uri.rb
|
74
|
+
- lib/hugeurl/version.rb
|
75
|
+
- samples/sample.rb
|
78
76
|
- script/console
|
79
77
|
- script/destroy
|
80
78
|
- script/generate
|
81
|
-
- examples/example.rb
|
82
79
|
- test/test_helper.rb
|
83
80
|
- test/test_hugeurl.rb
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
81
|
+
homepage: https://github.com/shokai/hugeurl
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
88
85
|
post_install_message:
|
89
|
-
rdoc_options:
|
90
|
-
- --main
|
91
|
-
- README.rdoc
|
86
|
+
rdoc_options: []
|
92
87
|
require_paths:
|
93
88
|
- lib
|
94
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
none: false
|
96
90
|
requirements:
|
97
|
-
- -
|
91
|
+
- - '>='
|
98
92
|
- !ruby/object:Gem::Version
|
99
93
|
version: '0'
|
100
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
-
none: false
|
102
95
|
requirements:
|
103
|
-
- -
|
96
|
+
- - '>='
|
104
97
|
- !ruby/object:Gem::Version
|
105
98
|
version: '0'
|
106
99
|
requirements: []
|
107
|
-
rubyforge_project:
|
108
|
-
rubygems_version:
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.0.3
|
109
102
|
signing_key:
|
110
|
-
specification_version:
|
103
|
+
specification_version: 4
|
111
104
|
summary: expand tinyurl, bit.ly, t.co and more.
|
112
105
|
test_files:
|
113
106
|
- test/test_helper.rb
|
data/.gemtest
DELETED
File without changes
|
data/Manifest.txt
DELETED
data/README.rdoc
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
= hugeurl
|
2
|
-
|
3
|
-
* http://github.com/shokai/hugeurl
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
expand tinyurl, bit.ly, t.co and more.
|
8
|
-
|
9
|
-
|
10
|
-
== SYNOPSIS:
|
11
|
-
|
12
|
-
require 'rubygems'
|
13
|
-
require 'hugeurl'
|
14
|
-
puts URI.parse("http://bit.ly/d4VYD2").to_huge # get expanded URI instance
|
15
|
-
|
16
|
-
|
17
|
-
== Hugeurl command
|
18
|
-
|
19
|
-
% hugeurl http://bit.ly/d4VYD2
|
20
|
-
|
21
|
-
or
|
22
|
-
|
23
|
-
% cat foo.txt | hugeurl
|
24
|
-
|
25
|
-
|
26
|
-
== REQUIREMENTS:
|
27
|
-
|
28
|
-
* Ruby 1.8+
|
29
|
-
|
30
|
-
== INSTALL:
|
31
|
-
|
32
|
-
* gem install hugeurl
|
33
|
-
|
34
|
-
== LICENSE:
|
35
|
-
|
36
|
-
(The MIT License)
|
37
|
-
|
38
|
-
Copyright (c) 2010 Sho Hashimoto
|
39
|
-
|
40
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
41
|
-
a copy of this software and associated documentation files (the
|
42
|
-
'Software'), to deal in the Software without restriction, including
|
43
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
44
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
45
|
-
permit persons to whom the Software is furnished to do so, subject to
|
46
|
-
the following conditions:
|
47
|
-
|
48
|
-
The above copyright notice and this permission notice shall be
|
49
|
-
included in all copies or substantial portions of the Software.
|
50
|
-
|
51
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
52
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
53
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
54
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
55
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
56
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
57
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|