shorturl 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +6 -0
- data/README +7 -25
- data/bin/shorturl +13 -1
- data/doc/classes/{InvalidService.html → WWW/InvalidService.html} +4 -4
- data/doc/classes/{Service.html → WWW/Service.html} +34 -34
- data/doc/classes/{ShortURL.html → WWW/ShortURL.html} +16 -16
- data/doc/classes/WWW.html +113 -0
- data/doc/created.rid +1 -1
- data/doc/files/ChangeLog.html +7 -1
- data/doc/files/README.html +17 -14
- data/doc/files/lib/shorturl_rb.html +1 -1
- data/doc/fr_class_index.html +4 -3
- data/doc/fr_method_index.html +4 -4
- data/lib/shorturl.rb +5 -11
- data/test/tc_service.rb +3 -1
- data/test/tc_shorturl.rb +3 -1
- metadata +7 -5
data/ChangeLog
CHANGED
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
= ShortURL 0.8.
|
1
|
+
= ShortURL 0.8.2
|
2
2
|
|
3
3
|
== Summary
|
4
4
|
ShortURL is a very simple library to use URL shortening services such as
|
@@ -15,11 +15,9 @@ http://rubyforge.org/frs/?group_id=732 if you do not want to use the gem.
|
|
15
15
|
Here is the list of the services supported by ShortURL:
|
16
16
|
* http://rubyurl.com
|
17
17
|
* http://tinyurl.com
|
18
|
-
* http://shorl.com
|
19
18
|
* http://snipurl.com
|
20
19
|
* http://metamark.net
|
21
20
|
* http://makeashorterlink.com
|
22
|
-
* http://skinnylink.com
|
23
21
|
* http://linktrim.com
|
24
22
|
* http://shorterlink.com
|
25
23
|
* http://minilink.org
|
@@ -32,6 +30,7 @@ Here is the list of the services supported by ShortURL:
|
|
32
30
|
* http://shortify.com
|
33
31
|
* http://0rz.net
|
34
32
|
* http://skinnylink.com
|
33
|
+
* http://shurl.org
|
35
34
|
|
36
35
|
== Usage:
|
37
36
|
|
@@ -40,27 +39,8 @@ call-seq:
|
|
40
39
|
puts WWW::ShortURL.shorten("http://mypage.com")
|
41
40
|
puts WWW::ShortURL.shorten("http://mypage.com", :tinyurl)
|
42
41
|
|
43
|
-
The second parameter represents the service you want to use.
|
44
|
-
|
45
|
-
* <tt>:tinyurl</tt>
|
46
|
-
* <tt>:shorl</tt>
|
47
|
-
* <tt>:snipurl</tt>
|
48
|
-
* <tt>:metamark</tt>
|
49
|
-
* <tt>:makeashorterlink</tt>
|
50
|
-
* <tt>:skinnylink</tt>
|
51
|
-
* <tt>:linktrim</tt>
|
52
|
-
* <tt>:shorterlink</tt>
|
53
|
-
* <tt>:minlink</tt>
|
54
|
-
* <tt>:lns</tt>
|
55
|
-
* <tt>:fyad</tt>
|
56
|
-
* <tt>:d62</tt>
|
57
|
-
* <tt>:shiturl</tt>
|
58
|
-
* <tt>:littlink</tt>
|
59
|
-
* <tt>:clipurl</tt>
|
60
|
-
* <tt>:shortify</tt>
|
61
|
-
* <tt>:orz</tt>
|
62
|
-
* <tt>:skinnylink</tt>
|
63
|
-
|
42
|
+
The second parameter represents the service you want to use. See the
|
43
|
+
documentation for WWW::ShortURL for a complete list
|
64
44
|
|
65
45
|
You can use <tt>ShortURL.valid_services</tt> to obtain a
|
66
46
|
list of the valid services (in case I forget to update the
|
@@ -73,7 +53,9 @@ call-seq:
|
|
73
53
|
http://rubyurl.com/fuuUw
|
74
54
|
$ shorturl -s tinyurl www.google.com
|
75
55
|
http://tinyurl.com/1c2
|
76
|
-
$
|
56
|
+
$ shorturl -s random www.google.com
|
57
|
+
http://linktrim.com/42k
|
58
|
+
|
77
59
|
|
78
60
|
== Thanks
|
79
61
|
- Marcel Molina Jr., Devin Mullins for some ideas
|
data/bin/shorturl
CHANGED
@@ -6,6 +6,16 @@ require "optparse"
|
|
6
6
|
|
7
7
|
include WWW
|
8
8
|
|
9
|
+
class Array
|
10
|
+
def pick
|
11
|
+
self[rand(size)]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def random_service
|
16
|
+
ShortURL.valid_services.pick
|
17
|
+
end
|
18
|
+
|
9
19
|
def service_list
|
10
20
|
ShortURL.valid_services.map { |s| s.to_s }.sort.join("\n\t")
|
11
21
|
end
|
@@ -27,7 +37,9 @@ Available services:\n\t" + service_list) { |s| service = s.to_sym }
|
|
27
37
|
end
|
28
38
|
|
29
39
|
url = ARGV.shift
|
30
|
-
shorturl = if
|
40
|
+
shorturl = if service == :random
|
41
|
+
ShortURL.shorten(url, random_service)
|
42
|
+
elsif ShortURL.valid_services.include?(service)
|
31
43
|
ShortURL.shorten(url, service)
|
32
44
|
else
|
33
45
|
puts "Invalid service"
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>Class: InvalidService</title>
|
8
|
+
<title>Class: WWW::InvalidService</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
12
|
<script type="text/javascript">
|
13
13
|
// <![CDATA[
|
14
14
|
|
@@ -50,12 +50,12 @@
|
|
50
50
|
<table class="header-table">
|
51
51
|
<tr class="top-aligned-row">
|
52
52
|
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">InvalidService</td>
|
53
|
+
<td class="class-name-in-header">WWW::InvalidService</td>
|
54
54
|
</tr>
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
57
57
|
<td>
|
58
|
-
<a href="
|
58
|
+
<a href="../../files/lib/shorturl_rb.html">
|
59
59
|
lib/shorturl.rb
|
60
60
|
</a>
|
61
61
|
<br />
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>Class: Service</title>
|
8
|
+
<title>Class: WWW::Service</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
12
|
<script type="text/javascript">
|
13
13
|
// <![CDATA[
|
14
14
|
|
@@ -50,12 +50,12 @@
|
|
50
50
|
<table class="header-table">
|
51
51
|
<tr class="top-aligned-row">
|
52
52
|
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Service</td>
|
53
|
+
<td class="class-name-in-header">WWW::Service</td>
|
54
54
|
</tr>
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
57
57
|
<td>
|
58
|
-
<a href="
|
58
|
+
<a href="../../files/lib/shorturl_rb.html">
|
59
59
|
lib/shorturl.rb
|
60
60
|
</a>
|
61
61
|
<br />
|
@@ -167,20 +167,20 @@ long URL, and the block of what to do with the HTML code you get.
|
|
167
167
|
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
168
168
|
<div class="method-source-code" id="M000003-source">
|
169
169
|
<pre>
|
170
|
-
<span class="ruby-comment cmt"># File lib/shorturl.rb, line
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
170
|
+
<span class="ruby-comment cmt"># File lib/shorturl.rb, line 22</span>
|
171
|
+
22: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">hostname</span>) <span class="ruby-comment cmt"># :yield: service</span>
|
172
|
+
23: <span class="ruby-ivar">@hostname</span> = <span class="ruby-identifier">hostname</span>
|
173
|
+
24: <span class="ruby-ivar">@port</span> = <span class="ruby-value">80</span>
|
174
|
+
25: <span class="ruby-ivar">@code</span> = <span class="ruby-value">200</span>
|
175
|
+
26: <span class="ruby-ivar">@method</span> = <span class="ruby-identifier">:post</span>
|
176
|
+
27: <span class="ruby-ivar">@action</span> = <span class="ruby-value str">"/"</span>
|
177
|
+
28: <span class="ruby-ivar">@field</span> = <span class="ruby-value str">"url"</span>
|
178
|
+
29: <span class="ruby-ivar">@block</span> = <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">body</span><span class="ruby-operator">|</span> }
|
179
|
+
30:
|
180
|
+
31: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
181
|
+
32: <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
|
182
|
+
33: <span class="ruby-keyword kw">end</span>
|
183
|
+
34: <span class="ruby-keyword kw">end</span>
|
184
184
|
</pre>
|
185
185
|
</div>
|
186
186
|
</div>
|
@@ -206,22 +206,22 @@ Now that our service is set up, call it with all the parameters to
|
|
206
206
|
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
207
207
|
<div class="method-source-code" id="M000004-source">
|
208
208
|
<pre>
|
209
|
-
<span class="ruby-comment cmt"># File lib/shorturl.rb, line
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
209
|
+
<span class="ruby-comment cmt"># File lib/shorturl.rb, line 38</span>
|
210
|
+
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">url</span>)
|
211
|
+
39: <span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTP</span>.<span class="ruby-identifier">start</span>(<span class="ruby-ivar">@hostname</span>, <span class="ruby-ivar">@port</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">http</span><span class="ruby-operator">|</span>
|
212
|
+
40: <span class="ruby-identifier">response</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@method</span>
|
213
|
+
41: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:post</span><span class="ruby-operator">:</span> <span class="ruby-identifier">http</span>.<span class="ruby-identifier">post</span>(<span class="ruby-ivar">@action</span>, <span class="ruby-node">"#{@field}=#{url}"</span>)
|
214
|
+
42: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:get</span><span class="ruby-operator">:</span> <span class="ruby-identifier">http</span>.<span class="ruby-identifier">get</span>(<span class="ruby-node">"#{@action}?#{@field}=#{CGI.escape(url)}"</span>)
|
215
|
+
43: <span class="ruby-keyword kw">end</span>
|
216
|
+
44: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">response</span>.<span class="ruby-identifier">code</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@code</span>.<span class="ruby-identifier">to_s</span>
|
217
|
+
45: <span class="ruby-keyword kw">begin</span>
|
218
|
+
46: <span class="ruby-ivar">@block</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">response</span>.<span class="ruby-identifier">read_body</span>)
|
219
|
+
47: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NoMethodError</span>
|
220
|
+
48: <span class="ruby-keyword kw">nil</span>
|
221
|
+
49: <span class="ruby-keyword kw">end</span>
|
222
|
+
50: <span class="ruby-keyword kw">end</span>
|
223
|
+
51: }
|
224
|
+
52: <span class="ruby-keyword kw">end</span>
|
225
225
|
</pre>
|
226
226
|
</div>
|
227
227
|
</div>
|
@@ -5,10 +5,10 @@
|
|
5
5
|
|
6
6
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
7
|
<head>
|
8
|
-
<title>Class: ShortURL</title>
|
8
|
+
<title>Class: WWW::ShortURL</title>
|
9
9
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
10
|
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="
|
11
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
12
|
<script type="text/javascript">
|
13
13
|
// <![CDATA[
|
14
14
|
|
@@ -50,12 +50,12 @@
|
|
50
50
|
<table class="header-table">
|
51
51
|
<tr class="top-aligned-row">
|
52
52
|
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">ShortURL</td>
|
53
|
+
<td class="class-name-in-header">WWW::ShortURL</td>
|
54
54
|
</tr>
|
55
55
|
<tr class="top-aligned-row">
|
56
56
|
<td><strong>In:</strong></td>
|
57
57
|
<td>
|
58
|
-
<a href="
|
58
|
+
<a href="../../files/lib/shorturl_rb.html">
|
59
59
|
lib/shorturl.rb
|
60
60
|
</a>
|
61
61
|
<br />
|
@@ -195,14 +195,14 @@ call-seq:
|
|
195
195
|
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
196
196
|
<div class="method-source-code" id="M000002-source">
|
197
197
|
<pre>
|
198
|
-
<span class="ruby-comment cmt"># File lib/shorturl.rb, line
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
198
|
+
<span class="ruby-comment cmt"># File lib/shorturl.rb, line 202</span>
|
199
|
+
202: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">shorten</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">service</span> = <span class="ruby-identifier">:rubyurl</span>)
|
200
|
+
203: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">valid_services</span>.<span class="ruby-identifier">include?</span> <span class="ruby-identifier">service</span>
|
201
|
+
204: <span class="ruby-ivar">@@services</span>[<span class="ruby-identifier">service</span>].<span class="ruby-identifier">call</span>(<span class="ruby-identifier">url</span>)
|
202
|
+
205: <span class="ruby-keyword kw">else</span>
|
203
|
+
206: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidService</span>
|
204
|
+
207: <span class="ruby-keyword kw">end</span>
|
205
|
+
208: <span class="ruby-keyword kw">end</span>
|
206
206
|
</pre>
|
207
207
|
</div>
|
208
208
|
</div>
|
@@ -225,10 +225,10 @@ Returns @@<a href="ShortURL.html#M000001">valid_services</a>
|
|
225
225
|
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
226
226
|
<div class="method-source-code" id="M000001-source">
|
227
227
|
<pre>
|
228
|
-
<span class="ruby-comment cmt"># File lib/shorturl.rb, line
|
229
|
-
|
230
|
-
|
231
|
-
|
228
|
+
<span class="ruby-comment cmt"># File lib/shorturl.rb, line 169</span>
|
229
|
+
169: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">valid_services</span>
|
230
|
+
170: <span class="ruby-ivar">@@valid_services</span>
|
231
|
+
171: <span class="ruby-keyword kw">end</span>
|
232
232
|
</pre>
|
233
233
|
</div>
|
234
234
|
</div>
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>Module: WWW</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="classHeader">
|
50
|
+
<table class="header-table">
|
51
|
+
<tr class="top-aligned-row">
|
52
|
+
<td><strong>Module</strong></td>
|
53
|
+
<td class="class-name-in-header">WWW</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../files/lib/shorturl_rb.html">
|
59
|
+
lib/shorturl.rb
|
60
|
+
</a>
|
61
|
+
<br />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
|
65
|
+
</table>
|
66
|
+
</div>
|
67
|
+
<!-- banner header -->
|
68
|
+
|
69
|
+
<div id="bodyContent">
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
<div id="contextContent">
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
</div>
|
78
|
+
|
79
|
+
|
80
|
+
</div>
|
81
|
+
|
82
|
+
|
83
|
+
<!-- if includes -->
|
84
|
+
|
85
|
+
<div id="section">
|
86
|
+
|
87
|
+
<div id="class-list">
|
88
|
+
<h3 class="section-bar">Classes and Modules</h3>
|
89
|
+
|
90
|
+
Class <a href="WWW/InvalidService.html" class="link">WWW::InvalidService</a><br />
|
91
|
+
Class <a href="WWW/Service.html" class="link">WWW::Service</a><br />
|
92
|
+
Class <a href="WWW/ShortURL.html" class="link">WWW::ShortURL</a><br />
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
<!-- if method_list -->
|
103
|
+
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
|
108
|
+
<div id="validator-badges">
|
109
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
</body>
|
113
|
+
</html>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Sun Oct 02
|
1
|
+
Sun Oct 02 18:54:32 EDT 2005
|
data/doc/files/ChangeLog.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Sun Oct 02
|
59
|
+
<td>Sun Oct 02 18:42:01 EDT 2005</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -70,6 +70,12 @@
|
|
70
70
|
|
71
71
|
<div id="description">
|
72
72
|
<p>
|
73
|
+
0.8.1:
|
74
|
+
</p>
|
75
|
+
<pre>
|
76
|
+
- Wrapped the library in a WWW namespace
|
77
|
+
</pre>
|
78
|
+
<p>
|
73
79
|
0.8.0:
|
74
80
|
</p>
|
75
81
|
<pre>
|
data/doc/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Sun Oct 02
|
59
|
+
<td>Sun Oct 02 18:45:01 EDT 2005</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -69,16 +69,16 @@
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
71
|
<div id="description">
|
72
|
-
<h1
|
72
|
+
<h1>ShortURL 0.8.1</h1>
|
73
73
|
<h2>Summary</h2>
|
74
74
|
<p>
|
75
|
-
|
76
|
-
|
75
|
+
ShortURL is a very simple library to use URL shortening services such as
|
76
|
+
TinyURL or RubyURL.
|
77
77
|
</p>
|
78
78
|
<h2>Installation</h2>
|
79
79
|
<p>
|
80
|
-
|
81
|
-
|
80
|
+
ShortURL is available as a gem, installation is just like any other gem:
|
81
|
+
<tt>$ gem install -r shorturl</tt>
|
82
82
|
</p>
|
83
83
|
<p>
|
84
84
|
You can also download the tar.bz2 archive at <a
|
@@ -87,8 +87,7 @@ if you do not want to use the gem.
|
|
87
87
|
</p>
|
88
88
|
<h2>Supported services</h2>
|
89
89
|
<p>
|
90
|
-
Here is the list of the services supported by
|
91
|
-
href="../classes/ShortURL.html">ShortURL</a>:
|
90
|
+
Here is the list of the services supported by ShortURL:
|
92
91
|
</p>
|
93
92
|
<ul>
|
94
93
|
<li><a href="http://rubyurl.com">rubyurl.com</a>
|
@@ -144,6 +143,9 @@ href="../classes/ShortURL.html">ShortURL</a>:
|
|
144
143
|
</li>
|
145
144
|
<li><a href="http://0rz.net">0rz.net</a>
|
146
145
|
|
146
|
+
</li>
|
147
|
+
<li><a href="http://skinnylink.com">skinnylink.com</a>
|
148
|
+
|
147
149
|
</li>
|
148
150
|
</ul>
|
149
151
|
<h2>Usage:</h2>
|
@@ -152,8 +154,8 @@ call-seq:
|
|
152
154
|
</p>
|
153
155
|
<pre>
|
154
156
|
require "shorturl"
|
155
|
-
puts ShortURL.shorten("http://mypage.com")
|
156
|
-
puts ShortURL.shorten("http://mypage.com", :tinyurl)
|
157
|
+
puts WWW::ShortURL.shorten("http://mypage.com")
|
158
|
+
puts WWW::ShortURL.shorten("http://mypage.com", :tinyurl)
|
157
159
|
</pre>
|
158
160
|
<p>
|
159
161
|
The second parameter represents the service you want to use. These are:
|
@@ -212,13 +214,14 @@ The second parameter represents the service you want to use. These are:
|
|
212
214
|
</li>
|
213
215
|
<li><tt>:orz</tt>
|
214
216
|
|
217
|
+
</li>
|
218
|
+
<li><tt>:skinnylink</tt>
|
219
|
+
|
215
220
|
</li>
|
216
221
|
</ul>
|
217
222
|
<p>
|
218
|
-
You can use <tt
|
219
|
-
|
220
|
-
obtain a list of the valid services (in case I forget to update the
|
221
|
-
documentation)
|
223
|
+
You can use <tt>ShortURL.valid_services</tt> to obtain a list of the valid
|
224
|
+
services (in case I forget to update the documentation)
|
222
225
|
</p>
|
223
226
|
<p>
|
224
227
|
You can also use the small script in bin/ which can be used from the
|
data/doc/fr_class_index.html
CHANGED
@@ -20,9 +20,10 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Classes</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/
|
24
|
-
<a href="classes/
|
25
|
-
<a href="classes/
|
23
|
+
<a href="classes/WWW.html">WWW</a><br />
|
24
|
+
<a href="classes/WWW/InvalidService.html">WWW::InvalidService</a><br />
|
25
|
+
<a href="classes/WWW/Service.html">WWW::Service</a><br />
|
26
|
+
<a href="classes/WWW/ShortURL.html">WWW::ShortURL</a><br />
|
26
27
|
</div>
|
27
28
|
</div>
|
28
29
|
</body>
|
data/doc/fr_method_index.html
CHANGED
@@ -20,10 +20,10 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Service.html#M000004">call (Service)</a><br />
|
24
|
-
<a href="classes/Service.html#M000003">new (Service)</a><br />
|
25
|
-
<a href="classes/ShortURL.html#M000002">shorten (ShortURL)</a><br />
|
26
|
-
<a href="classes/ShortURL.html#M000001">valid_services (ShortURL)</a><br />
|
23
|
+
<a href="classes/WWW/Service.html#M000004">call (WWW::Service)</a><br />
|
24
|
+
<a href="classes/WWW/Service.html#M000003">new (WWW::Service)</a><br />
|
25
|
+
<a href="classes/WWW/ShortURL.html#M000002">shorten (WWW::ShortURL)</a><br />
|
26
|
+
<a href="classes/WWW/ShortURL.html#M000001">valid_services (WWW::ShortURL)</a><br />
|
27
27
|
</div>
|
28
28
|
</div>
|
29
29
|
</body>
|
data/lib/shorturl.rb
CHANGED
@@ -72,11 +72,6 @@ module WWW
|
|
72
72
|
s.block = lambda { |body| URI.extract(body).grep(/tinyurl/)[-1] }
|
73
73
|
},
|
74
74
|
|
75
|
-
:shorl => Service.new("shorl.com") { |s|
|
76
|
-
s.action = "/create.php"
|
77
|
-
s.block = lambda { |body| URI.extract(body)[2] }
|
78
|
-
},
|
79
|
-
|
80
75
|
:snipurl => Service.new("snipurl.com") { |s|
|
81
76
|
s.action = "/index.php"
|
82
77
|
s.field = "link"
|
@@ -97,10 +92,6 @@ module WWW
|
|
97
92
|
s.block = lambda { |body| URI.extract(body).grep(/makeashorterlink/)[0] }
|
98
93
|
},
|
99
94
|
|
100
|
-
:skinnylink => Service.new("skinnylink.com") { |s|
|
101
|
-
s.block = lambda { |body| URI.extract(body).grep(/skinnylink/)[0] }
|
102
|
-
},
|
103
|
-
|
104
95
|
:linktrim => Service.new("linktrim.com") { |s|
|
105
96
|
s.method = :get
|
106
97
|
s.action = "/lt/generate"
|
@@ -158,6 +149,10 @@ module WWW
|
|
158
149
|
:orz => Service.new("0rz.net") { |s|
|
159
150
|
s.action = "/create.php"
|
160
151
|
s.block = lambda { |body| URI.extract(body).grep(/0rz/)[0] }
|
152
|
+
},
|
153
|
+
|
154
|
+
:shurl => Service.new("shurl.org") { |s|
|
155
|
+
s.block = lambda { |body| URI.extract(body).grep(/shurl/)[0] }
|
161
156
|
}
|
162
157
|
}
|
163
158
|
|
@@ -179,11 +174,9 @@ module WWW
|
|
179
174
|
#
|
180
175
|
# * <tt>:rubyurl</tt>
|
181
176
|
# * <tt>:tinyurl</tt>
|
182
|
-
# * <tt>:shorl</tt>
|
183
177
|
# * <tt>:snipurl</tt>
|
184
178
|
# * <tt>:metamark</tt>
|
185
179
|
# * <tt>:makeashorterlink</tt>
|
186
|
-
# * <tt>:skinnylink</tt>
|
187
180
|
# * <tt>:linktrim</tt>
|
188
181
|
# * <tt>:shorterlink</tt>
|
189
182
|
# * <tt>:minlink</tt>
|
@@ -195,6 +188,7 @@ module WWW
|
|
195
188
|
# * <tt>:clipurl</tt>
|
196
189
|
# * <tt>:shortify</tt>
|
197
190
|
# * <tt>:orz</tt>
|
191
|
+
# * <tt>:shurl</tt>
|
198
192
|
#
|
199
193
|
# call-seq:
|
200
194
|
# ShortURL.shorten("http://mypage.com") => Uses RubyURL
|
data/test/tc_service.rb
CHANGED
data/test/tc_shorturl.rb
CHANGED
@@ -14,7 +14,8 @@ class String
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
class
|
17
|
+
class TestShortURL < Test::Unit::TestCase
|
18
|
+
include WWW
|
18
19
|
def setup
|
19
20
|
@url = "http://groups.google.com/group/comp.lang.ruby/"
|
20
21
|
end
|
@@ -26,6 +27,7 @@ class WWW::TestShortURL < Test::Unit::TestCase
|
|
26
27
|
# All the services (I can't test exact URLs since they seem to
|
27
28
|
# change semi regularly)
|
28
29
|
ShortURL.valid_services.each do |service|
|
30
|
+
puts "Testing #{service}"
|
29
31
|
assert ShortURL.shorten(@url, service).url?
|
30
32
|
end
|
31
33
|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: shorturl
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.8.2
|
7
|
+
date: 2005-12-17 00:00:00 -05:00
|
8
8
|
summary: Shortens URLs using services such as TinyURL and RubyURL
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -39,9 +39,11 @@ files:
|
|
39
39
|
- doc/fr_method_index.html
|
40
40
|
- doc/index.html
|
41
41
|
- doc/rdoc-style.css
|
42
|
-
- doc/classes/
|
43
|
-
- doc/classes/
|
44
|
-
- doc/classes/
|
42
|
+
- doc/classes/WWW
|
43
|
+
- doc/classes/WWW.html
|
44
|
+
- doc/classes/WWW/InvalidService.html
|
45
|
+
- doc/classes/WWW/Service.html
|
46
|
+
- doc/classes/WWW/ShortURL.html
|
45
47
|
- doc/files/ChangeLog.html
|
46
48
|
- doc/files/lib
|
47
49
|
- doc/files/MIT-LICENSE.html
|