shorturl 0.8.8 → 1.0.0
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 +1 -0
- data/{ChangeLog → ChangeLog.txt} +0 -0
- data/{MIT-LICENSE → LICENSE.txt} +0 -0
- data/{README → README.rdoc} +28 -1
- data/Rakefile +42 -0
- data/{TODO → TODO.rdoc} +0 -0
- data/examples/shorten.rb +3 -3
- data/lib/shorturl.rb +35 -142
- data/lib/shorturl/exceptions.rb +7 -0
- data/lib/shorturl/service.rb +62 -0
- data/lib/shorturl/services.rb +12 -0
- data/lib/shorturl/services/bitly.rb +28 -0
- data/lib/shorturl/services/lns.rb +18 -0
- data/lib/shorturl/services/metamark.rb +20 -0
- data/lib/shorturl/services/minilink.rb +17 -0
- data/lib/shorturl/services/moourl.rb +22 -0
- data/lib/shorturl/services/shiturl.rb +20 -0
- data/lib/shorturl/services/shorl.rb +19 -0
- data/lib/shorturl/services/shortify.rb +20 -0
- data/lib/shorturl/services/snipurl.rb +22 -0
- data/lib/shorturl/services/tinyurl.rb +20 -0
- data/lib/shorturl/services/url.rb +21 -0
- data/lib/shorturl/services/vurl.rb +17 -0
- data/lib/shorturl/version.rb +3 -0
- data/shorturl.gemspec +27 -0
- data/test/helper.rb +11 -0
- data/test/tc_service.rb +6 -10
- data/test/tc_shorturl.rb +3 -12
- data/test/ts_all.rb +0 -5
- metadata +80 -63
- data/doc/classes/InvalidService.html +0 -111
- data/doc/classes/Service.html +0 -202
- data/doc/classes/Service.src/M000003.html +0 -28
- data/doc/classes/Service.src/M000004.html +0 -26
- data/doc/classes/ShortURL.html +0 -227
- data/doc/classes/ShortURL.src/M000001.html +0 -18
- data/doc/classes/ShortURL.src/M000002.html +0 -22
- data/doc/created.rid +0 -1
- data/doc/files/ChangeLog.html +0 -190
- data/doc/files/MIT-LICENSE.html +0 -129
- data/doc/files/README.html +0 -289
- data/doc/files/TODO.html +0 -113
- data/doc/files/lib/shorturl_rb.html +0 -119
- data/doc/fr_class_index.html +0 -29
- data/doc/fr_file_index.html +0 -31
- data/doc/fr_method_index.html +0 -30
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
@@ -0,0 +1,20 @@
|
|
1
|
+
require "shorturl/services/metamark"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class Metamark < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super("metamark.net")
|
9
|
+
|
10
|
+
@action = "/add"
|
11
|
+
@field = "long_url"
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_body(body)
|
15
|
+
URI.extract(body).grep(/xrl.us/)[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "shorturl/service"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class MooURL < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super("moourl.com")
|
9
|
+
|
10
|
+
@code = 302
|
11
|
+
@method = :get
|
12
|
+
@action = "/create/"
|
13
|
+
@field = "source"
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_response(response)
|
17
|
+
"http://moourl.com/" + res["location"].match(/\?moo=/).post_match
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "shorturl/service"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class ShitURL < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super("shiturl.com")
|
9
|
+
|
10
|
+
@method = :get
|
11
|
+
@action = "/make.php"
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_body(body)
|
15
|
+
URI.extract(body).grep(/shiturl/)[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "shorturl/service"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class Shorl < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super("shorl.com")
|
9
|
+
|
10
|
+
@action = "/create.php"
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_body(body)
|
14
|
+
URI.extract(body)[2]
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "shorturl/service"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class Shortify < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super("shortify.wikinote.com")
|
9
|
+
|
10
|
+
@method = :get
|
11
|
+
@action = "/shorten.php"
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_body(body)
|
15
|
+
URI.extract(body).grep(/shortify/)[-1]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "shorturl/service"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
# SnipURL offers a restful HTTP API but it cannot be used without
|
6
|
+
# registration.
|
7
|
+
class SnipURL < Service
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
super("snipurl.com")
|
11
|
+
|
12
|
+
@action = "/site/index"
|
13
|
+
@field = "url"
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_body(body)
|
17
|
+
URI.extract(body).grep(/http:\/\/snipurl.com/)[0]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'shorturl/service'
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class TinyURL < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super('tinyurl.com')
|
9
|
+
|
10
|
+
@action = "/api-create.php"
|
11
|
+
@method = :get
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_body(body)
|
15
|
+
URI.extract(body).grep(/tinyurl/)[0]
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "shorturl/service"
|
2
|
+
|
3
|
+
module ShortURL
|
4
|
+
module Services
|
5
|
+
class Url < Service
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super("url.ca")
|
9
|
+
|
10
|
+
@method = :post
|
11
|
+
@action = "/"
|
12
|
+
@field = "longurl"
|
13
|
+
end
|
14
|
+
|
15
|
+
def on_body(body)
|
16
|
+
URI.extract(body).grep(/ur1/)[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/shorturl.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
require File.expand_path('../lib/shorturl/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "shorturl"
|
7
|
+
gem.version = ShortURL::VERSION
|
8
|
+
gem.summary = %q{Shortens URLs using services such as RubyURL, urlTea, bit.ly, moourl.com, and TinyURL}
|
9
|
+
gem.license = "MIT"
|
10
|
+
gem.authors = ["Robby Russell"]
|
11
|
+
gem.email = "robby@planetargon.com"
|
12
|
+
gem.homepage = "http://github.com/robbyrussell/shorturl/"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ['lib']
|
18
|
+
|
19
|
+
gem.extra_rdoc_files = %w[README.rdoc TODO.rdoc LICENSE.txt ChangeLog.txt]
|
20
|
+
gem.rdoc_options = %w[
|
21
|
+
--title ShortURL\ Documentation
|
22
|
+
--main README.rdoc
|
23
|
+
-S -N --all
|
24
|
+
]
|
25
|
+
|
26
|
+
gem.add_development_dependency 'rdoc', '~> 3.0'
|
27
|
+
end
|
data/test/helper.rb
ADDED
data/test/tc_service.rb
CHANGED
@@ -2,20 +2,16 @@
|
|
2
2
|
#
|
3
3
|
# Created by Vincent Foley on 2005-06-01
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
require "test/unit"
|
9
|
-
require "shorturl"
|
10
|
-
|
5
|
+
require "helper"
|
6
|
+
require "shorturl/service"
|
11
7
|
|
12
8
|
class TestService < Test::Unit::TestCase
|
13
9
|
|
14
10
|
def test_call
|
15
|
-
service = Service.new("oasdasobf")
|
11
|
+
service = ShortURL::Service.new("oasdasobf")
|
16
12
|
assert_raise(SocketError) { service.call(nil) }
|
17
13
|
|
18
|
-
service = Service.new("tinyurl.com") { |s|
|
14
|
+
service = ShortURL::Service.new("tinyurl.com") { |s|
|
19
15
|
s.code = 404
|
20
16
|
s.action = "/create.php"
|
21
17
|
s.block = lambda { |body|
|
@@ -26,14 +22,14 @@ class TestService < Test::Unit::TestCase
|
|
26
22
|
end
|
27
23
|
|
28
24
|
def test_initialize
|
29
|
-
service = Service.new("
|
25
|
+
service = ShortURL::Service.new("tinyurl.com")
|
30
26
|
assert_equal(service.port, 80)
|
31
27
|
assert_equal(service.code, 200)
|
32
28
|
assert_equal(service.method, :post)
|
33
29
|
assert_equal(service.action, "/")
|
34
30
|
assert_equal(service.field, "url")
|
35
31
|
|
36
|
-
service = Service.new("
|
32
|
+
service = ShortURL::Service.new("tinyurl.com") { |s|
|
37
33
|
s.port = 8080
|
38
34
|
s.code = 302
|
39
35
|
s.method = :get
|
data/test/tc_shorturl.rb
CHANGED
@@ -2,18 +2,9 @@
|
|
2
2
|
#
|
3
3
|
# Created by Vincent Foley on 2005-06-01
|
4
4
|
|
5
|
-
|
6
|
-
$:.unshift($test_lib_dir)
|
7
|
-
|
8
|
-
require "test/unit"
|
5
|
+
require "helper"
|
9
6
|
require "shorturl"
|
10
7
|
|
11
|
-
class String
|
12
|
-
def url?
|
13
|
-
self[0..6].downcase == "http://"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
8
|
class TestShortURL < Test::Unit::TestCase
|
18
9
|
def setup
|
19
10
|
@url = "http://groups.google.com/group/comp.lang.ruby/"
|
@@ -21,7 +12,7 @@ class TestShortURL < Test::Unit::TestCase
|
|
21
12
|
|
22
13
|
def test_shorten
|
23
14
|
# Default service (RubyURL)
|
24
|
-
|
15
|
+
assert_url ShortURL.shorten(@url)
|
25
16
|
|
26
17
|
# All the services (I can't test exact URLs since they seem to
|
27
18
|
# # change semi regularly)
|
@@ -30,6 +21,6 @@ class TestShortURL < Test::Unit::TestCase
|
|
30
21
|
# end
|
31
22
|
|
32
23
|
# An invalid service
|
33
|
-
assert_raise(InvalidService) { ShortURL.shorten(@url, :foobar) }
|
24
|
+
assert_raise(ShortURL::InvalidService) { ShortURL.shorten(@url, :foobar) }
|
34
25
|
end
|
35
26
|
end
|
data/test/ts_all.rb
CHANGED
metadata
CHANGED
@@ -1,91 +1,108 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: shorturl
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Robby Russell
|
8
|
-
autorequire:
|
9
|
+
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rdoc
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.0'
|
16
30
|
description:
|
17
31
|
email: robby@planetargon.com
|
18
|
-
executables:
|
32
|
+
executables:
|
19
33
|
- shorturl
|
20
34
|
extensions: []
|
21
|
-
|
22
|
-
|
23
|
-
-
|
24
|
-
-
|
25
|
-
-
|
26
|
-
|
27
|
-
|
35
|
+
extra_rdoc_files:
|
36
|
+
- README.rdoc
|
37
|
+
- TODO.rdoc
|
38
|
+
- LICENSE.txt
|
39
|
+
- ChangeLog.txt
|
40
|
+
files:
|
41
|
+
- .gitignore
|
42
|
+
- ChangeLog.txt
|
43
|
+
- LICENSE.txt
|
44
|
+
- README.rdoc
|
45
|
+
- Rakefile
|
46
|
+
- TODO.rdoc
|
28
47
|
- bin/shorturl
|
48
|
+
- examples/shorten.rb
|
29
49
|
- lib/shorturl.rb
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
45
|
-
-
|
46
|
-
-
|
47
|
-
-
|
50
|
+
- lib/shorturl/exceptions.rb
|
51
|
+
- lib/shorturl/service.rb
|
52
|
+
- lib/shorturl/services.rb
|
53
|
+
- lib/shorturl/services/bitly.rb
|
54
|
+
- lib/shorturl/services/lns.rb
|
55
|
+
- lib/shorturl/services/metamark.rb
|
56
|
+
- lib/shorturl/services/minilink.rb
|
57
|
+
- lib/shorturl/services/moourl.rb
|
58
|
+
- lib/shorturl/services/shiturl.rb
|
59
|
+
- lib/shorturl/services/shorl.rb
|
60
|
+
- lib/shorturl/services/shortify.rb
|
61
|
+
- lib/shorturl/services/snipurl.rb
|
62
|
+
- lib/shorturl/services/tinyurl.rb
|
63
|
+
- lib/shorturl/services/url.rb
|
64
|
+
- lib/shorturl/services/vurl.rb
|
65
|
+
- lib/shorturl/version.rb
|
66
|
+
- shorturl.gemspec
|
67
|
+
- test/helper.rb
|
48
68
|
- test/tc_service.rb
|
49
69
|
- test/tc_shorturl.rb
|
50
70
|
- test/ts_all.rb
|
51
|
-
- examples/shorten.rb
|
52
|
-
- README
|
53
|
-
- TODO
|
54
|
-
- MIT-LICENSE
|
55
|
-
- ChangeLog
|
56
|
-
has_rdoc: true
|
57
71
|
homepage: http://github.com/robbyrussell/shorturl/
|
58
|
-
licenses:
|
59
|
-
|
72
|
+
licenses:
|
73
|
+
- MIT
|
60
74
|
post_install_message:
|
61
|
-
rdoc_options:
|
75
|
+
rdoc_options:
|
62
76
|
- --title
|
63
77
|
- ShortURL Documentation
|
64
78
|
- --main
|
65
|
-
- README
|
79
|
+
- README.rdoc
|
66
80
|
- -S
|
67
81
|
- -N
|
68
82
|
- --all
|
69
|
-
require_paths:
|
83
|
+
require_paths:
|
70
84
|
- lib
|
71
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
requirements: []
|
84
|
-
|
85
98
|
rubyforge_project:
|
86
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.8.23
|
87
100
|
signing_key:
|
88
101
|
specification_version: 3
|
89
|
-
summary: Shortens URLs using services such as RubyURL, urlTea, bit.ly, moourl.com,
|
90
|
-
|
102
|
+
summary: Shortens URLs using services such as RubyURL, urlTea, bit.ly, moourl.com,
|
103
|
+
and TinyURL
|
104
|
+
test_files:
|
105
|
+
- test/helper.rb
|
106
|
+
- test/tc_service.rb
|
107
|
+
- test/tc_shorturl.rb
|
91
108
|
- test/ts_all.rb
|