caleb-shorturl 0.8.7 → 0.8.9
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/Rakefile +61 -0
- data/VERSION.yml +4 -0
- data/doc/classes/InvalidService.html +111 -0
- data/doc/classes/Service.html +202 -0
- data/doc/classes/Service.src/M000003.html +28 -0
- data/doc/classes/Service.src/M000004.html +26 -0
- data/doc/classes/ShortURL.html +227 -0
- data/doc/classes/ShortURL.src/M000001.html +18 -0
- data/doc/classes/ShortURL.src/M000002.html +22 -0
- data/doc/created.rid +1 -0
- data/doc/files/ChangeLog.html +190 -0
- data/doc/files/MIT-LICENSE.html +129 -0
- data/doc/files/README.html +289 -0
- data/doc/files/TODO.html +113 -0
- data/doc/files/lib/shorturl_rb.html +119 -0
- data/doc/fr_class_index.html +29 -0
- data/doc/fr_file_index.html +31 -0
- data/doc/fr_method_index.html +30 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/examples/shorten.rb +27 -0
- data/lib/shorturl.rb +217 -0
- data/shorturl.gemspec +75 -0
- data/test/tc_service.rb +50 -0
- data/test/tc_shorturl.rb +35 -0
- metadata +42 -11
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/rdoctask"
|
3
|
+
require "rake/testtask"
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gemspec|
|
8
|
+
gemspec.name = "shorturl"
|
9
|
+
gemspec.summary = "Shortens URLs using services such as RubyURL, urlTea, and TinyURL"
|
10
|
+
gemspec.description = "Shortens URLs using services such as RubyURL, urlTea, and TinyURL"
|
11
|
+
gemspec.email = "robby@planetargon.com"
|
12
|
+
gemspec.homepage = "http://github.com/robbyrussell/shorturl"
|
13
|
+
gemspec.authors = ["Robby Russell"]
|
14
|
+
gemspec.rdoc_options = [
|
15
|
+
"--title", "ShortURL Documentation",
|
16
|
+
"--main", "README",
|
17
|
+
"-S",
|
18
|
+
"-N",
|
19
|
+
"--all"]
|
20
|
+
end
|
21
|
+
rescue LoadError
|
22
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
23
|
+
end
|
24
|
+
|
25
|
+
task :default => [ :test, :doc ]
|
26
|
+
|
27
|
+
desc "Run the tests"
|
28
|
+
Rake::TestTask.new("test") { |t|
|
29
|
+
t.pattern = "test/**/ts_*.rb"
|
30
|
+
t.verbose = true
|
31
|
+
}
|
32
|
+
|
33
|
+
desc "Write the documentation"
|
34
|
+
Rake::RDocTask.new("doc") { |rdoc|
|
35
|
+
rdoc.rdoc_dir = "doc"
|
36
|
+
rdoc.title = "ShortURL Documentation"
|
37
|
+
# rdoc.options << "--line-numbers --inline-source"
|
38
|
+
rdoc.rdoc_files.include("README")
|
39
|
+
rdoc.rdoc_files.include("TODO")
|
40
|
+
rdoc.rdoc_files.include("MIT-LICENSE")
|
41
|
+
rdoc.rdoc_files.include("ChangeLog")
|
42
|
+
rdoc.rdoc_files.include("lib/*.rb")
|
43
|
+
rdoc.rdoc_files.exclude("test/*")
|
44
|
+
}
|
45
|
+
|
46
|
+
desc "Upload documentation to RubyForge"
|
47
|
+
task :upload_doc do
|
48
|
+
sh "scp -r doc/* robbyrussell@rubyforge.org:/var/www/gforge-projects/shorturl"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
desc "Statistics for the code"
|
53
|
+
task :stats do
|
54
|
+
begin
|
55
|
+
require "code_statistics"
|
56
|
+
CodeStatistics.new(["Code", "lib"],
|
57
|
+
["Units", "test"]).to_s
|
58
|
+
rescue LoadError
|
59
|
+
puts "Couldn't load code_statistics (install rails)"
|
60
|
+
end
|
61
|
+
end
|
data/VERSION.yml
ADDED
@@ -0,0 +1,111 @@
|
|
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>Class: InvalidService</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>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">InvalidService</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
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Exception
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
|
89
|
+
<!-- if includes -->
|
90
|
+
|
91
|
+
<div id="section">
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<!-- if method_list -->
|
101
|
+
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
|
106
|
+
<div id="validator-badges">
|
107
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
108
|
+
</div>
|
109
|
+
|
110
|
+
</body>
|
111
|
+
</html>
|
@@ -0,0 +1,202 @@
|
|
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>Class: Service</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>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">Service</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
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000004">call</a>
|
90
|
+
<a href="#M000003">new</a>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<div id="attribute-list">
|
106
|
+
<h3 class="section-bar">Attributes</h3>
|
107
|
+
|
108
|
+
<div class="name-list">
|
109
|
+
<table>
|
110
|
+
<tr class="top-aligned-row context-row">
|
111
|
+
<td class="context-item-name">action</td>
|
112
|
+
<td class="context-item-value"> [RW] </td>
|
113
|
+
<td class="context-item-desc"></td>
|
114
|
+
</tr>
|
115
|
+
<tr class="top-aligned-row context-row">
|
116
|
+
<td class="context-item-name">block</td>
|
117
|
+
<td class="context-item-value"> [RW] </td>
|
118
|
+
<td class="context-item-desc"></td>
|
119
|
+
</tr>
|
120
|
+
<tr class="top-aligned-row context-row">
|
121
|
+
<td class="context-item-name">code</td>
|
122
|
+
<td class="context-item-value"> [RW] </td>
|
123
|
+
<td class="context-item-desc"></td>
|
124
|
+
</tr>
|
125
|
+
<tr class="top-aligned-row context-row">
|
126
|
+
<td class="context-item-name">field</td>
|
127
|
+
<td class="context-item-value"> [RW] </td>
|
128
|
+
<td class="context-item-desc"></td>
|
129
|
+
</tr>
|
130
|
+
<tr class="top-aligned-row context-row">
|
131
|
+
<td class="context-item-name">method</td>
|
132
|
+
<td class="context-item-value"> [RW] </td>
|
133
|
+
<td class="context-item-desc"></td>
|
134
|
+
</tr>
|
135
|
+
<tr class="top-aligned-row context-row">
|
136
|
+
<td class="context-item-name">port</td>
|
137
|
+
<td class="context-item-value"> [RW] </td>
|
138
|
+
<td class="context-item-desc"></td>
|
139
|
+
</tr>
|
140
|
+
</table>
|
141
|
+
</div>
|
142
|
+
</div>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
<!-- if method_list -->
|
147
|
+
<div id="methods">
|
148
|
+
<h3 class="section-bar">Public Class methods</h3>
|
149
|
+
|
150
|
+
<div id="method-M000003" class="method-detail">
|
151
|
+
<a name="M000003"></a>
|
152
|
+
|
153
|
+
<div class="method-heading">
|
154
|
+
<a href="Service.src/M000003.html" target="Code" class="method-signature"
|
155
|
+
onclick="popupCode('Service.src/M000003.html');return false;">
|
156
|
+
<span class="method-name">new</span><span class="method-args">(hostname) {|service| ...}</span>
|
157
|
+
</a>
|
158
|
+
</div>
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
<p>
|
162
|
+
Intialize the service with a hostname (required parameter) and you can
|
163
|
+
override the default values for the HTTP port, expected HTTP return code,
|
164
|
+
the form method to use, the form action, the form field which contains the
|
165
|
+
long URL, and the block of what to do with the HTML code you get.
|
166
|
+
</p>
|
167
|
+
</div>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
171
|
+
|
172
|
+
<div id="method-M000004" class="method-detail">
|
173
|
+
<a name="M000004"></a>
|
174
|
+
|
175
|
+
<div class="method-heading">
|
176
|
+
<a href="Service.src/M000004.html" target="Code" class="method-signature"
|
177
|
+
onclick="popupCode('Service.src/M000004.html');return false;">
|
178
|
+
<span class="method-name">call</span><span class="method-args">(url)</span>
|
179
|
+
</a>
|
180
|
+
</div>
|
181
|
+
|
182
|
+
<div class="method-description">
|
183
|
+
<p>
|
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.
|
186
|
+
</p>
|
187
|
+
</div>
|
188
|
+
</div>
|
189
|
+
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
<div id="validator-badges">
|
198
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
199
|
+
</div>
|
200
|
+
|
201
|
+
</body>
|
202
|
+
</html>
|
@@ -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>
|
@@ -0,0 +1,227 @@
|
|
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>Class: ShortURL</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>Class</strong></td>
|
53
|
+
<td class="class-name-in-header">ShortURL</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
|
+
<tr class="top-aligned-row">
|
66
|
+
<td><strong>Parent:</strong></td>
|
67
|
+
<td>
|
68
|
+
Object
|
69
|
+
</td>
|
70
|
+
</tr>
|
71
|
+
</table>
|
72
|
+
</div>
|
73
|
+
<!-- banner header -->
|
74
|
+
|
75
|
+
<div id="bodyContent">
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<div id="contextContent">
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
</div>
|
84
|
+
|
85
|
+
<div id="method-list">
|
86
|
+
<h3 class="section-bar">Methods</h3>
|
87
|
+
|
88
|
+
<div class="name-list">
|
89
|
+
<a href="#M000002">shorten</a>
|
90
|
+
<a href="#M000001">valid_services</a>
|
91
|
+
</div>
|
92
|
+
</div>
|
93
|
+
|
94
|
+
</div>
|
95
|
+
|
96
|
+
|
97
|
+
<!-- if includes -->
|
98
|
+
|
99
|
+
<div id="section">
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
<!-- if method_list -->
|
109
|
+
<div id="methods">
|
110
|
+
<h3 class="section-bar">Public Class methods</h3>
|
111
|
+
|
112
|
+
<div id="method-M000002" class="method-detail">
|
113
|
+
<a name="M000002"></a>
|
114
|
+
|
115
|
+
<div class="method-heading">
|
116
|
+
<a href="ShortURL.src/M000002.html" target="Code" class="method-signature"
|
117
|
+
onclick="popupCode('ShortURL.src/M000002.html');return false;">
|
118
|
+
<span class="method-name">shorten</span><span class="method-args">(url, service = :rubyurl)</span>
|
119
|
+
</a>
|
120
|
+
</div>
|
121
|
+
|
122
|
+
<div class="method-description">
|
123
|
+
<p>
|
124
|
+
Main method of <a href="ShortURL.html">ShortURL</a>, its usage is quite
|
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
|
128
|
+
</p>
|
129
|
+
<p>
|
130
|
+
Valid <tt>service</tt> values:
|
131
|
+
</p>
|
132
|
+
<ul>
|
133
|
+
<li><tt>:rubyurl</tt>
|
134
|
+
|
135
|
+
</li>
|
136
|
+
<li><tt>:tinyurl</tt>
|
137
|
+
|
138
|
+
</li>
|
139
|
+
<li><tt>:shorl</tt>
|
140
|
+
|
141
|
+
</li>
|
142
|
+
<li><tt>:snipurl</tt>
|
143
|
+
|
144
|
+
</li>
|
145
|
+
<li><tt>:metamark</tt>
|
146
|
+
|
147
|
+
</li>
|
148
|
+
<li><tt>:makeashorterlink</tt>
|
149
|
+
|
150
|
+
</li>
|
151
|
+
<li><tt>:skinnylink</tt>
|
152
|
+
|
153
|
+
</li>
|
154
|
+
<li><tt>:linktrim</tt>
|
155
|
+
|
156
|
+
</li>
|
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>
|
170
|
+
|
171
|
+
</li>
|
172
|
+
<li><tt>:shiturl</tt>
|
173
|
+
|
174
|
+
</li>
|
175
|
+
<li><tt>:littlink</tt>
|
176
|
+
|
177
|
+
</li>
|
178
|
+
<li><tt>:clipurl</tt>
|
179
|
+
|
180
|
+
</li>
|
181
|
+
<li><tt>:shortify</tt>
|
182
|
+
|
183
|
+
</li>
|
184
|
+
<li><tt>:orz</tt>
|
185
|
+
|
186
|
+
</li>
|
187
|
+
</ul>
|
188
|
+
<p>
|
189
|
+
call-seq:
|
190
|
+
</p>
|
191
|
+
<pre>
|
192
|
+
ShortURL.shorten("http://mypage.com") => Uses RubyURL
|
193
|
+
ShortURL.shorten("http://mypage.com", :tinyurl)
|
194
|
+
</pre>
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
|
198
|
+
<div id="method-M000001" class="method-detail">
|
199
|
+
<a name="M000001"></a>
|
200
|
+
|
201
|
+
<div class="method-heading">
|
202
|
+
<a href="ShortURL.src/M000001.html" target="Code" class="method-signature"
|
203
|
+
onclick="popupCode('ShortURL.src/M000001.html');return false;">
|
204
|
+
<span class="method-name">valid_services</span><span class="method-args">()</span>
|
205
|
+
</a>
|
206
|
+
</div>
|
207
|
+
|
208
|
+
<div class="method-description">
|
209
|
+
<p>
|
210
|
+
Returns @@<a href="ShortURL.html#M000001">valid_services</a>
|
211
|
+
</p>
|
212
|
+
</div>
|
213
|
+
</div>
|
214
|
+
|
215
|
+
|
216
|
+
</div>
|
217
|
+
|
218
|
+
|
219
|
+
</div>
|
220
|
+
|
221
|
+
|
222
|
+
<div id="validator-badges">
|
223
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
224
|
+
</div>
|
225
|
+
|
226
|
+
</body>
|
227
|
+
</html>
|