shorturl 0.8.8 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +1 -0
  2. data/{ChangeLog → ChangeLog.txt} +0 -0
  3. data/{MIT-LICENSE → LICENSE.txt} +0 -0
  4. data/{README → README.rdoc} +28 -1
  5. data/Rakefile +42 -0
  6. data/{TODO → TODO.rdoc} +0 -0
  7. data/examples/shorten.rb +3 -3
  8. data/lib/shorturl.rb +35 -142
  9. data/lib/shorturl/exceptions.rb +7 -0
  10. data/lib/shorturl/service.rb +62 -0
  11. data/lib/shorturl/services.rb +12 -0
  12. data/lib/shorturl/services/bitly.rb +28 -0
  13. data/lib/shorturl/services/lns.rb +18 -0
  14. data/lib/shorturl/services/metamark.rb +20 -0
  15. data/lib/shorturl/services/minilink.rb +17 -0
  16. data/lib/shorturl/services/moourl.rb +22 -0
  17. data/lib/shorturl/services/shiturl.rb +20 -0
  18. data/lib/shorturl/services/shorl.rb +19 -0
  19. data/lib/shorturl/services/shortify.rb +20 -0
  20. data/lib/shorturl/services/snipurl.rb +22 -0
  21. data/lib/shorturl/services/tinyurl.rb +20 -0
  22. data/lib/shorturl/services/url.rb +21 -0
  23. data/lib/shorturl/services/vurl.rb +17 -0
  24. data/lib/shorturl/version.rb +3 -0
  25. data/shorturl.gemspec +27 -0
  26. data/test/helper.rb +11 -0
  27. data/test/tc_service.rb +6 -10
  28. data/test/tc_shorturl.rb +3 -12
  29. data/test/ts_all.rb +0 -5
  30. metadata +80 -63
  31. data/doc/classes/InvalidService.html +0 -111
  32. data/doc/classes/Service.html +0 -202
  33. data/doc/classes/Service.src/M000003.html +0 -28
  34. data/doc/classes/Service.src/M000004.html +0 -26
  35. data/doc/classes/ShortURL.html +0 -227
  36. data/doc/classes/ShortURL.src/M000001.html +0 -18
  37. data/doc/classes/ShortURL.src/M000002.html +0 -22
  38. data/doc/created.rid +0 -1
  39. data/doc/files/ChangeLog.html +0 -190
  40. data/doc/files/MIT-LICENSE.html +0 -129
  41. data/doc/files/README.html +0 -289
  42. data/doc/files/TODO.html +0 -113
  43. data/doc/files/lib/shorturl_rb.html +0 -119
  44. data/doc/fr_class_index.html +0 -29
  45. data/doc/fr_file_index.html +0 -31
  46. data/doc/fr_method_index.html +0 -30
  47. data/doc/index.html +0 -24
  48. data/doc/rdoc-style.css +0 -208
@@ -0,0 +1,18 @@
1
+ module ShortURL
2
+ module Services
3
+ class Lns < Service
4
+
5
+ def initialize
6
+ super("ln-s.net")
7
+
8
+ @method = :get
9
+ @action = "/home/api.jsp"
10
+ end
11
+
12
+ def on_body(body)
13
+ URI.extract(body)[0]
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -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,17 @@
1
+ module ShortURL
2
+ module Services
3
+ class Minilink < Service
4
+
5
+ def initialize
6
+ super("minilink.org")
7
+
8
+ @method = :get
9
+ end
10
+
11
+ def on_body(body)
12
+ URI.extract(body)[-1]
13
+ end
14
+
15
+ end
16
+ end
17
+ 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
@@ -0,0 +1,17 @@
1
+ require "shorturl/service"
2
+
3
+ module ShortURL
4
+ module Services
5
+ class Vurl < Service
6
+
7
+ def initialize
8
+ super("vurl.me")
9
+
10
+ @method = :get
11
+ @action = "/shorten"
12
+ @field = "url"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module ShortURL
2
+ VERSION = '1.0.0'
3
+ end
@@ -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
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'uri'
4
+
5
+ class Test::Unit::TestCase
6
+
7
+ def assert_url(url)
8
+ assert URI(url).scheme.downcase == "http"
9
+ end
10
+
11
+ end
@@ -2,20 +2,16 @@
2
2
  #
3
3
  # Created by Vincent Foley on 2005-06-01
4
4
 
5
- $test_lib_dir = File.join(File.dirname(__FILE__), "..", "lib")
6
- $:.unshift($test_lib_dir)
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("rubyurl.com")
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("rubyurl.com") { |s|
32
+ service = ShortURL::Service.new("tinyurl.com") { |s|
37
33
  s.port = 8080
38
34
  s.code = 302
39
35
  s.method = :get
@@ -2,18 +2,9 @@
2
2
  #
3
3
  # Created by Vincent Foley on 2005-06-01
4
4
 
5
- $test_lib_dir = File.join(File.dirname(__FILE__), "..", "lib")
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
- assert ShortURL.shorten(@url).url?
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
@@ -2,10 +2,5 @@
2
2
  #
3
3
  # Created by Vincent Foley on 2005-06-01
4
4
 
5
- $test_lib_dir = File.join(File.dirname(__FILE__))
6
- $:.unshift($test_lib_dir)
7
-
8
- require "test/unit"
9
-
10
5
  require "tc_shorturl"
11
6
  require "tc_service"
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.8.8
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: shorturl
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2010-03-08 00:00:00 -08:00
13
- default_executable: shorturl
14
- dependencies: []
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
- extra_rdoc_files:
23
- - README
24
- - TODO
25
- - MIT-LICENSE
26
- - ChangeLog
27
- files:
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
- - doc/classes/InvalidService.html
31
- - doc/classes/Service.html
32
- - doc/classes/Service.src/M000003.html
33
- - doc/classes/Service.src/M000004.html
34
- - doc/classes/ShortURL.html
35
- - doc/classes/ShortURL.src/M000001.html
36
- - doc/classes/ShortURL.src/M000002.html
37
- - doc/created.rid
38
- - doc/files/ChangeLog.html
39
- - doc/files/lib/shorturl_rb.html
40
- - doc/files/MIT-LICENSE.html
41
- - doc/files/README.html
42
- - doc/files/TODO.html
43
- - doc/fr_class_index.html
44
- - doc/fr_file_index.html
45
- - doc/fr_method_index.html
46
- - doc/index.html
47
- - doc/rdoc-style.css
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
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: "0"
76
- version:
77
- required_rubygems_version: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: "0"
82
- version:
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.3.5
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, and TinyURL
90
- test_files:
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