shorturl 0.8.3 → 0.8.4
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/ChangeLog +5 -15
- data/README +50 -35
- data/bin/CVS/Entries +2 -0
- data/bin/CVS/Repository +1 -0
- data/bin/CVS/Root +1 -0
- data/bin/shorturl +20 -36
- data/doc/classes/{WWW/InvalidService.html → InvalidService.html} +4 -4
- data/doc/classes/{WWW/Service.html → Service.html} +10 -50
- data/doc/classes/Service.src/M000003.html +28 -0
- data/doc/classes/Service.src/M000004.html +26 -0
- data/doc/classes/{WWW/ShortURL.html → ShortURL.html} +36 -46
- data/doc/classes/ShortURL.src/M000001.html +18 -0
- data/doc/classes/ShortURL.src/M000002.html +22 -0
- data/doc/created.rid +1 -1
- data/doc/files/ChangeLog.html +5 -26
- data/doc/files/MIT-LICENSE.html +2 -2
- data/doc/files/README.html +119 -45
- data/doc/files/TODO.html +1 -1
- data/doc/files/lib/shorturl_rb.html +1 -1
- data/doc/fr_class_index.html +3 -4
- data/doc/fr_method_index.html +4 -4
- data/examples/CVS/Entries +2 -0
- data/examples/CVS/Repository +1 -0
- data/examples/CVS/Root +1 -0
- data/lib/CVS/Entries +2 -0
- data/lib/CVS/Repository +1 -0
- data/lib/CVS/Root +1 -0
- data/lib/shorturl.rb +194 -152
- data/test/CVS/Entries +4 -0
- data/test/CVS/Repository +1 -0
- data/test/CVS/Root +1 -0
- data/test/tc_service.rb +1 -3
- data/test/tc_shorturl.rb +0 -1
- metadata +78 -50
- data/doc/classes/WWW.html +0 -113
data/ChangeLog
CHANGED
@@ -1,18 +1,8 @@
|
|
1
|
-
0.8.
|
2
|
-
- Fixed
|
3
|
-
-
|
4
|
-
|
5
|
-
|
6
|
-
- Added shurl.org
|
7
|
-
- Added "random" service to bin/shorturl to pick a random one
|
8
|
-
- Removed shorl.com and skinnylink.com because they no longer seem to
|
9
|
-
be up and running
|
10
|
-
0.8.1:
|
11
|
-
- Wrapped the library in a WWW namespace
|
12
|
-
|
13
|
-
0.8.0:
|
14
|
-
- Made some improvements to bin/shorturl
|
15
|
-
|
1
|
+
0.8.4:
|
2
|
+
- Fixed support for RubyURL.com
|
3
|
+
- Added support for urlTea.com
|
4
|
+
- Added support for moourl.com
|
5
|
+
|
16
6
|
0.7.0:
|
17
7
|
- Added shortify.com, 0rz.net
|
18
8
|
- Modified unit tests
|
data/README
CHANGED
@@ -1,63 +1,78 @@
|
|
1
|
-
= ShortURL 0.8.
|
1
|
+
= ShortURL 0.8.4
|
2
2
|
|
3
3
|
== Summary
|
4
4
|
ShortURL is a very simple library to use URL shortening services such as
|
5
|
-
|
5
|
+
RubyURL, urlTea, and TinyURL.
|
6
6
|
|
7
7
|
== Installation
|
8
8
|
ShortURL is available as a gem, installation is just like any other gem:
|
9
|
-
<tt>$ gem install
|
9
|
+
<tt>$ gem install shorturl</tt>
|
10
10
|
|
11
11
|
You can also download the tar.bz2 archive at
|
12
12
|
http://rubyforge.org/frs/?group_id=732 if you do not want to use the gem.
|
13
13
|
|
14
14
|
== Supported services
|
15
15
|
Here is the list of the services supported by ShortURL:
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
16
|
+
* http://rubyurl.com
|
17
|
+
* http://tinyurl.com
|
18
|
+
* http://shorl.com
|
19
|
+
* http://snipurl.com
|
20
|
+
* http://metamark.net
|
21
|
+
* http://makeashorterlink.com
|
22
|
+
* http://skinnylink.com
|
23
|
+
* http://linktrim.com
|
24
|
+
* http://shorterlink.com
|
25
|
+
* http://minilink.org
|
26
|
+
* http://ln-s.net
|
27
|
+
* http://fyad.org
|
28
|
+
* http://d62.net
|
29
|
+
* http://shiturl.com
|
30
|
+
* http://littlink.com
|
31
|
+
* http://clipurl.com
|
32
|
+
* http://shortify.com
|
33
|
+
* http://0rz.net
|
34
|
+
* http://moourl.com
|
35
|
+
* http://urltea.com
|
30
36
|
|
31
37
|
== Usage:
|
32
|
-
|
33
38
|
call-seq:
|
34
39
|
require "shorturl"
|
35
|
-
puts
|
36
|
-
puts
|
40
|
+
puts ShortURL.shorten("http://mypage.com")
|
41
|
+
puts ShortURL.shorten("http://mypage.com", :moourl)
|
42
|
+
|
43
|
+
The second parameter represents the service you want to use. These are:
|
44
|
+
* <tt>:rubyurl</tt>
|
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>:moourl</tt>
|
63
|
+
* <tt>:urltea</tt>
|
37
64
|
|
38
|
-
The second parameter represents the service you want to use. See the
|
39
|
-
documentation for WWW::ShortURL for a complete list
|
40
65
|
|
41
66
|
You can use <tt>ShortURL.valid_services</tt> to obtain a
|
42
67
|
list of the valid services (in case I forget to update the
|
43
68
|
documentation)
|
44
69
|
|
45
|
-
You can also use the small script in bin/ which can be used from the
|
46
|
-
command line:
|
47
|
-
call-seq:
|
48
|
-
$ shorturl www.google.com
|
49
|
-
http://rubyurl.com/fuuUw
|
50
|
-
$ shorturl -s tinyurl www.google.com
|
51
|
-
http://tinyurl.com/1c2
|
52
|
-
$ shorturl -s random www.google.com
|
53
|
-
http://linktrim.com/42k
|
54
|
-
|
55
|
-
|
56
70
|
== Thanks
|
57
71
|
- Marcel Molina Jr., Devin Mullins for some ideas
|
58
72
|
- imperator from #ruby-lang (I don't know your real name, sorry) for
|
59
73
|
helping me with creating and uploading a RubyGem
|
60
74
|
- Daniel Dipaolo for telling me about ln-s.net and fyad.org
|
61
75
|
|
62
|
-
==
|
63
|
-
Vincent Foley
|
76
|
+
== Authors
|
77
|
+
- Vincent Foley (original developer)
|
78
|
+
- Robby Russell <robbyrussell@gmail.com>
|
data/bin/CVS/Entries
ADDED
data/bin/CVS/Repository
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
support/bin
|
data/bin/CVS/Root
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
:pserver:anonymous@rubyforge.org:/var/cvs/shorturl
|
data/bin/shorturl
CHANGED
@@ -2,51 +2,35 @@
|
|
2
2
|
|
3
3
|
require "rubygems"
|
4
4
|
require "shorturl"
|
5
|
-
require "optparse"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def random_service
|
16
|
-
ShortURL.valid_services.pick
|
17
|
-
end
|
18
|
-
|
19
|
-
def service_list
|
20
|
-
ShortURL.valid_services.map { |s| s.to_s }.sort.join("\n\t")
|
6
|
+
def usage
|
7
|
+
puts "Usage: #$0 <url> [<service>]"
|
8
|
+
puts "Available services:"
|
9
|
+
ShortURL.valid_services.each { |s| puts "\t#{s}" }
|
10
|
+
exit(-1)
|
21
11
|
end
|
22
12
|
|
23
13
|
def main
|
24
|
-
|
25
|
-
|
26
|
-
opts.banner = "Usage: #{File.basename($0)} [<options>] <url>"
|
27
|
-
opts.on("-h", "--help", "Displays help") { puts opts; exit }
|
28
|
-
opts.on("-s", "--service <service>", String,
|
29
|
-
"Uses <service> instead of RubyURL
|
30
|
-
Available services:\n\t" + service_list) { |s| service = s.to_sym }
|
31
|
-
opts.parse!
|
14
|
+
if ARGV.size < 1
|
15
|
+
usage
|
32
16
|
end
|
33
17
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
url = ARGV.shift
|
40
|
-
shorturl = if service == :random
|
41
|
-
ShortURL.shorten(url, random_service)
|
42
|
-
elsif ShortURL.valid_services.include?(service)
|
43
|
-
ShortURL.shorten(url, service)
|
18
|
+
url = ARGV[0]
|
19
|
+
service = ARGV[1]
|
20
|
+
|
21
|
+
shorturl = if service.nil?
|
22
|
+
ShortURL.shorten(url)
|
44
23
|
else
|
45
|
-
|
46
|
-
|
24
|
+
if ShortURL.valid_services.include?(service.to_sym)
|
25
|
+
ShortURL.shorten(url, service.to_sym)
|
26
|
+
else
|
27
|
+
puts "Invalid service"
|
28
|
+
exit(-1)
|
29
|
+
end
|
47
30
|
end
|
48
31
|
|
49
|
-
puts shorturl
|
32
|
+
puts shorturl
|
33
|
+
|
50
34
|
end
|
51
35
|
|
52
36
|
main
|
@@ -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:
|
8
|
+
<title>Class: 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">
|
53
|
+
<td class="class-name-in-header">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:
|
8
|
+
<title>Class: 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">
|
53
|
+
<td class="class-name-in-header">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 />
|
@@ -151,7 +151,8 @@
|
|
151
151
|
<a name="M000003"></a>
|
152
152
|
|
153
153
|
<div class="method-heading">
|
154
|
-
<a href="
|
154
|
+
<a href="Service.src/M000003.html" target="Code" class="method-signature"
|
155
|
+
onclick="popupCode('Service.src/M000003.html');return false;">
|
155
156
|
<span class="method-name">new</span><span class="method-args">(hostname) {|service| ...}</span>
|
156
157
|
</a>
|
157
158
|
</div>
|
@@ -163,26 +164,6 @@ override the default values for the HTTP port, expected HTTP return code,
|
|
163
164
|
the form method to use, the form action, the form field which contains the
|
164
165
|
long URL, and the block of what to do with the HTML code you get.
|
165
166
|
</p>
|
166
|
-
<p><a class="source-toggle" href="#"
|
167
|
-
onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
|
168
|
-
<div class="method-source-code" id="M000003-source">
|
169
|
-
<pre>
|
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">:get</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
|
-
</pre>
|
185
|
-
</div>
|
186
167
|
</div>
|
187
168
|
</div>
|
188
169
|
|
@@ -192,38 +173,17 @@ long URL, and the block of what to do with the HTML code you get.
|
|
192
173
|
<a name="M000004"></a>
|
193
174
|
|
194
175
|
<div class="method-heading">
|
195
|
-
<a href="
|
176
|
+
<a href="Service.src/M000004.html" target="Code" class="method-signature"
|
177
|
+
onclick="popupCode('Service.src/M000004.html');return false;">
|
196
178
|
<span class="method-name">call</span><span class="method-args">(url)</span>
|
197
179
|
</a>
|
198
180
|
</div>
|
199
181
|
|
200
182
|
<div class="method-description">
|
201
183
|
<p>
|
202
|
-
Now that our service is set up, call it
|
203
|
-
(hopefully) return only the shortened URL.
|
184
|
+
Now that our service is set up, <a href="Service.html#M000004">call</a> it
|
185
|
+
with all the parameters to (hopefully) return only the shortened URL.
|
204
186
|
</p>
|
205
|
-
<p><a class="source-toggle" href="#"
|
206
|
-
onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
|
207
|
-
<div class="method-source-code" id="M000004-source">
|
208
|
-
<pre>
|
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
|
-
</pre>
|
226
|
-
</div>
|
227
187
|
</div>
|
228
188
|
</div>
|
229
189
|
|
@@ -0,0 +1,28 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>new (Service)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/shorturl.rb, line 21</span>
|
14
|
+
<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>
|
15
|
+
<span class="ruby-ivar">@hostname</span> = <span class="ruby-identifier">hostname</span>
|
16
|
+
<span class="ruby-ivar">@port</span> = <span class="ruby-value">80</span>
|
17
|
+
<span class="ruby-ivar">@code</span> = <span class="ruby-value">200</span>
|
18
|
+
<span class="ruby-ivar">@method</span> = <span class="ruby-identifier">:post</span>
|
19
|
+
<span class="ruby-ivar">@action</span> = <span class="ruby-value str">"/"</span>
|
20
|
+
<span class="ruby-ivar">@field</span> = <span class="ruby-value str">"url"</span>
|
21
|
+
<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> }
|
22
|
+
|
23
|
+
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
24
|
+
<span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span>
|
25
|
+
<span class="ruby-keyword kw">end</span>
|
26
|
+
<span class="ruby-keyword kw">end</span></pre>
|
27
|
+
</body>
|
28
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>call (Service)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/shorturl.rb, line 37</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">url</span>)
|
15
|
+
<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>
|
16
|
+
<span class="ruby-identifier">response</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@method</span>
|
17
|
+
<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>)
|
18
|
+
<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>)
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<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>
|
21
|
+
<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>)
|
22
|
+
<span class="ruby-keyword kw">end</span>
|
23
|
+
}
|
24
|
+
<span class="ruby-keyword kw">end</span></pre>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -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:
|
8
|
+
<title>Class: 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">
|
53
|
+
<td class="class-name-in-header">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 />
|
@@ -113,7 +113,8 @@
|
|
113
113
|
<a name="M000002"></a>
|
114
114
|
|
115
115
|
<div class="method-heading">
|
116
|
-
<a href="
|
116
|
+
<a href="ShortURL.src/M000002.html" target="Code" class="method-signature"
|
117
|
+
onclick="popupCode('ShortURL.src/M000002.html');return false;">
|
117
118
|
<span class="method-name">shorten</span><span class="method-args">(url, service = :rubyurl)</span>
|
118
119
|
</a>
|
119
120
|
</div>
|
@@ -121,54 +122,66 @@
|
|
121
122
|
<div class="method-description">
|
122
123
|
<p>
|
123
124
|
Main method of <a href="ShortURL.html">ShortURL</a>, its usage is quite
|
124
|
-
simple, just give an url to shorten and
|
125
|
-
is selected, RubyURL.com will be used.
|
126
|
-
an ArgumentError exception
|
125
|
+
simple, just give an url to <a href="ShortURL.html#M000002">shorten</a> and
|
126
|
+
an optional service. If no service is selected, RubyURL.com will be used.
|
127
|
+
An invalid service symbol will raise an ArgumentError exception
|
127
128
|
</p>
|
128
129
|
<p>
|
129
130
|
Valid <tt>service</tt> values:
|
130
131
|
</p>
|
131
132
|
<ul>
|
132
|
-
<li><tt>:
|
133
|
+
<li><tt>:rubyurl</tt>
|
133
134
|
|
134
135
|
</li>
|
135
|
-
<li><tt>:
|
136
|
+
<li><tt>:tinyurl</tt>
|
136
137
|
|
137
138
|
</li>
|
138
|
-
<li><tt>:
|
139
|
+
<li><tt>:shorl</tt>
|
139
140
|
|
140
141
|
</li>
|
141
|
-
<li><tt>:
|
142
|
+
<li><tt>:snipurl</tt>
|
142
143
|
|
143
144
|
</li>
|
144
|
-
<li><tt>:
|
145
|
+
<li><tt>:metamark</tt>
|
145
146
|
|
146
147
|
</li>
|
147
|
-
<li><tt>:
|
148
|
+
<li><tt>:makeashorterlink</tt>
|
148
149
|
|
149
150
|
</li>
|
150
|
-
<li><tt>:
|
151
|
+
<li><tt>:skinnylink</tt>
|
151
152
|
|
152
153
|
</li>
|
153
|
-
<li><tt>:
|
154
|
+
<li><tt>:linktrim</tt>
|
154
155
|
|
155
156
|
</li>
|
156
|
-
<li><tt>:
|
157
|
+
<li><tt>:shorterlink</tt>
|
158
|
+
|
159
|
+
</li>
|
160
|
+
<li><tt>:minlink</tt>
|
161
|
+
|
162
|
+
</li>
|
163
|
+
<li><tt>:lns</tt>
|
164
|
+
|
165
|
+
</li>
|
166
|
+
<li><tt>:fyad</tt>
|
167
|
+
|
168
|
+
</li>
|
169
|
+
<li><tt>:d62</tt>
|
157
170
|
|
158
171
|
</li>
|
159
172
|
<li><tt>:shiturl</tt>
|
160
173
|
|
161
174
|
</li>
|
162
|
-
<li><tt>:
|
175
|
+
<li><tt>:littlink</tt>
|
163
176
|
|
164
177
|
</li>
|
165
|
-
<li><tt>:
|
178
|
+
<li><tt>:clipurl</tt>
|
166
179
|
|
167
180
|
</li>
|
168
|
-
<li><tt>:
|
181
|
+
<li><tt>:shortify</tt>
|
169
182
|
|
170
183
|
</li>
|
171
|
-
<li><tt>:
|
184
|
+
<li><tt>:orz</tt>
|
172
185
|
|
173
186
|
</li>
|
174
187
|
</ul>
|
@@ -179,20 +192,6 @@ call-seq:
|
|
179
192
|
ShortURL.shorten("http://mypage.com") => Uses RubyURL
|
180
193
|
ShortURL.shorten("http://mypage.com", :tinyurl)
|
181
194
|
</pre>
|
182
|
-
<p><a class="source-toggle" href="#"
|
183
|
-
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
184
|
-
<div class="method-source-code" id="M000002-source">
|
185
|
-
<pre>
|
186
|
-
<span class="ruby-comment cmt"># File lib/shorturl.rb, line 166</span>
|
187
|
-
166: <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>)
|
188
|
-
167: <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>
|
189
|
-
168: <span class="ruby-ivar">@@services</span>[<span class="ruby-identifier">service</span>].<span class="ruby-identifier">call</span>(<span class="ruby-identifier">url</span>)
|
190
|
-
169: <span class="ruby-keyword kw">else</span>
|
191
|
-
170: <span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidService</span>
|
192
|
-
171: <span class="ruby-keyword kw">end</span>
|
193
|
-
172: <span class="ruby-keyword kw">end</span>
|
194
|
-
</pre>
|
195
|
-
</div>
|
196
195
|
</div>
|
197
196
|
</div>
|
198
197
|
|
@@ -200,7 +199,8 @@ call-seq:
|
|
200
199
|
<a name="M000001"></a>
|
201
200
|
|
202
201
|
<div class="method-heading">
|
203
|
-
<a href="
|
202
|
+
<a href="ShortURL.src/M000001.html" target="Code" class="method-signature"
|
203
|
+
onclick="popupCode('ShortURL.src/M000001.html');return false;">
|
204
204
|
<span class="method-name">valid_services</span><span class="method-args">()</span>
|
205
205
|
</a>
|
206
206
|
</div>
|
@@ -209,16 +209,6 @@ call-seq:
|
|
209
209
|
<p>
|
210
210
|
Returns @@<a href="ShortURL.html#M000001">valid_services</a>
|
211
211
|
</p>
|
212
|
-
<p><a class="source-toggle" href="#"
|
213
|
-
onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
|
214
|
-
<div class="method-source-code" id="M000001-source">
|
215
|
-
<pre>
|
216
|
-
<span class="ruby-comment cmt"># File lib/shorturl.rb, line 137</span>
|
217
|
-
137: <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">valid_services</span>
|
218
|
-
138: <span class="ruby-ivar">@@valid_services</span>
|
219
|
-
139: <span class="ruby-keyword kw">end</span>
|
220
|
-
</pre>
|
221
|
-
</div>
|
222
212
|
</div>
|
223
213
|
</div>
|
224
214
|
|
@@ -0,0 +1,18 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>valid_services (ShortURL)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/shorturl.rb, line 176</span>
|
14
|
+
<span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">valid_services</span>
|
15
|
+
<span class="ruby-ivar">@@valid_services</span>
|
16
|
+
<span class="ruby-keyword kw">end</span></pre>
|
17
|
+
</body>
|
18
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
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>
|
7
|
+
<head>
|
8
|
+
<title>shorten (ShortURL)</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
11
|
+
</head>
|
12
|
+
<body class="standalone-code">
|
13
|
+
<pre><span class="ruby-comment cmt"># File lib/shorturl.rb, line 209</span>
|
14
|
+
<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>)
|
15
|
+
<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>
|
16
|
+
<span class="ruby-ivar">@@services</span>[<span class="ruby-identifier">service</span>].<span class="ruby-identifier">call</span>(<span class="ruby-identifier">url</span>)
|
17
|
+
<span class="ruby-keyword kw">else</span>
|
18
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">InvalidService</span>
|
19
|
+
<span class="ruby-keyword kw">end</span>
|
20
|
+
<span class="ruby-keyword kw">end</span></pre>
|
21
|
+
</body>
|
22
|
+
</html>
|
data/doc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Sun, 06 Jan 2008 15:55:37 -0800
|