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.
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
@@ -1,18 +0,0 @@
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 177</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>
@@ -1,22 +0,0 @@
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 210</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>
@@ -1 +0,0 @@
1
- Mon, 02 Mar 2009 08:13:08 -0800
@@ -1,190 +0,0 @@
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>File: ChangeLog</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="fileHeader">
50
- <h1>ChangeLog</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>ChangeLog
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Mon Mar 02 08:07:08 -0800 2009</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <p>
73
- 0.8.4:
74
- </p>
75
- <pre>
76
- - Fixed support for RubyURL.com
77
- - Added support for urlTea.com
78
- - Added support for moourl.com
79
- </pre>
80
- <p>
81
- 0.7.0:
82
- </p>
83
- <pre>
84
- - Added shortify.com, 0rz.net
85
- - Modified unit tests
86
- - Started using CVS on RubyForge
87
- </pre>
88
- <p>
89
- 0.6.0:
90
- </p>
91
- <pre>
92
- - Changed the method for getting the URL for ln-s.net to use their
93
- API. So basically, this means the new additional argument attribute
94
- in the Service class is now useless, because no service uses it. I've
95
- removed it along with the Hash#to_html_args method.
96
- - Added d62.net, shiturl.com, littlink.com and clipurl.com
97
- </pre>
98
- <p>
99
- 0.5.0:
100
- </p>
101
- <pre>
102
- - Added two services: fyad.org and ln-s.net (thanks to Daniel
103
- Dipaolo)
104
- - Added an property to the Service class: args. This allows to give
105
- additional arguments to services using the GET method (this was
106
- needed by ln-s.net)
107
- - Added a method to Hash to convert to an HTML arguments style
108
- - Added a script called &quot;shorturl&quot; (duh) in the bin directory for
109
- usage from the command line.
110
- </pre>
111
- <p>
112
- 0.4.0:
113
- </p>
114
- <pre>
115
- - Added minilink.org
116
- - More tests for the Service class
117
- - Changed the ArgumentError exception for an InvalidService exception in ShortURL.shorten
118
- - Created examples/shorten.rb
119
- - Added a stats task to the Rakefile. Requires code_statistics, provided by Rails.
120
- </pre>
121
- <p>
122
- 0.3.0:
123
- </p>
124
- <pre>
125
- - Added linktrim.com and shorterlink.com
126
- - Replaced get_short_url and all the private class methods in favor of a Service class, which makes things clearer
127
- </pre>
128
- <p>
129
- 0.2.1:
130
- </p>
131
- <pre>
132
- - Added makeashorterlink.com and skinnylink.com
133
- - Refactored get_short_url
134
- </pre>
135
- <p>
136
- 0.2.0:
137
- </p>
138
- <pre>
139
- - Added shorl.com, snipurl.com and metamark.net
140
- </pre>
141
- <p>
142
- 0.1.0:
143
- </p>
144
- <pre>
145
- - Refactored the tinyurl and rubyurl methods
146
- - URI.extract to get URLs instead of regular expressions
147
- - Added exception handling to get_short_url to return nil in case
148
- of a network error
149
- - More thorough unit tests
150
- - Made tinyurl, rubyurl and get_short_url private class methods
151
- </pre>
152
- <p>
153
- 0.0.1:
154
- </p>
155
- <pre>
156
- - Initial release
157
- </pre>
158
-
159
- </div>
160
-
161
-
162
- </div>
163
-
164
-
165
- </div>
166
-
167
-
168
- <!-- if includes -->
169
-
170
- <div id="section">
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
- <!-- if method_list -->
180
-
181
-
182
- </div>
183
-
184
-
185
- <div id="validator-badges">
186
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
187
- </div>
188
-
189
- </body>
190
- </html>
@@ -1,129 +0,0 @@
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>File: MIT-LICENSE</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="fileHeader">
50
- <h1>MIT-LICENSE</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>MIT-LICENSE
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Mon Mar 02 08:07:08 -0800 2009</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <p>
73
- Copyright (c) 2005, Vincent Foley
74
- </p>
75
- <p>
76
- Permission is hereby granted, free of charge, to any person obtaining a
77
- copy of this software and associated documentation files (the
78
- &quot;Software&quot;), to deal in the Software without restriction,
79
- including without limitation the rights to use, copy, modify, merge,
80
- publish, distribute, sublicense, and/or sell copies of the Software, and to
81
- permit persons to whom the Software is furnished to do so, subject to the
82
- following conditions:
83
- </p>
84
- <p>
85
- The above copyright notice and this permission notice shall be included in
86
- all copies or substantial portions of the Software.
87
- </p>
88
- <p>
89
- THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
90
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
91
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
92
- NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
93
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
94
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
95
- USE OR OTHER DEALINGS IN THE SOFTWARE.
96
- </p>
97
-
98
- </div>
99
-
100
-
101
- </div>
102
-
103
-
104
- </div>
105
-
106
-
107
- <!-- if includes -->
108
-
109
- <div id="section">
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
- <!-- if method_list -->
119
-
120
-
121
- </div>
122
-
123
-
124
- <div id="validator-badges">
125
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
126
- </div>
127
-
128
- </body>
129
- </html>
@@ -1,289 +0,0 @@
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>File: README</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="fileHeader">
50
- <h1>README</h1>
51
- <table class="header-table">
52
- <tr class="top-aligned-row">
53
- <td><strong>Path:</strong></td>
54
- <td>README
55
- </td>
56
- </tr>
57
- <tr class="top-aligned-row">
58
- <td><strong>Last Update:</strong></td>
59
- <td>Mon Mar 02 08:07:08 -0800 2009</td>
60
- </tr>
61
- </table>
62
- </div>
63
- <!-- banner header -->
64
-
65
- <div id="bodyContent">
66
-
67
-
68
-
69
- <div id="contextContent">
70
-
71
- <div id="description">
72
- <h1><a href="../classes/ShortURL.html">ShortURL</a> 0.8.4</h1>
73
- <h2>Summary</h2>
74
- <p>
75
- <a href="../classes/ShortURL.html">ShortURL</a> is a very simple library to
76
- use URL shortening services such as RubyURL, urlTea, and TinyURL.
77
- </p>
78
- <h2>Installation</h2>
79
- <p>
80
- <a href="../classes/ShortURL.html">ShortURL</a> is available as a gem,
81
- installation is just like any other gem: <tt>$ gem install shorturl</tt>
82
- </p>
83
- <p>
84
- You can also download the tar.bz2 archive at <a
85
- href="http://rubyforge.org/frs/?group_id=732">rubyforge.org/frs/?group_id=732</a>
86
- if you do not want to use the gem.
87
- </p>
88
- <h2>Supported services</h2>
89
- <p>
90
- Here is the list of the services supported by <a
91
- href="../classes/ShortURL.html">ShortURL</a>:
92
- </p>
93
- <ul>
94
- <li><a href="http://rubyurl.com">rubyurl.com</a>
95
-
96
- </li>
97
- <li><a href="http://tinyurl.com">tinyurl.com</a>
98
-
99
- </li>
100
- <li><a href="http://shorl.com">shorl.com</a>
101
-
102
- </li>
103
- <li><a href="http://snipurl.com">snipurl.com</a>
104
-
105
- </li>
106
- <li><a href="http://metamark.net">metamark.net</a>
107
-
108
- </li>
109
- <li><a href="http://makeashorterlink.com">makeashorterlink.com</a>
110
-
111
- </li>
112
- <li><a href="http://skinnylink.com">skinnylink.com</a>
113
-
114
- </li>
115
- <li><a href="http://linktrim.com">linktrim.com</a>
116
-
117
- </li>
118
- <li><a href="http://shorterlink.com">shorterlink.com</a>
119
-
120
- </li>
121
- <li><a href="http://minilink.org">minilink.org</a>
122
-
123
- </li>
124
- <li><a href="http://ln-s.net">ln-s.net</a>
125
-
126
- </li>
127
- <li><a href="http://fyad.org">fyad.org</a>
128
-
129
- </li>
130
- <li><a href="http://d62.net">d62.net</a>
131
-
132
- </li>
133
- <li><a href="http://shiturl.com">shiturl.com</a>
134
-
135
- </li>
136
- <li><a href="http://littlink.com">littlink.com</a>
137
-
138
- </li>
139
- <li><a href="http://clipurl.com">clipurl.com</a>
140
-
141
- </li>
142
- <li><a href="http://shortify.com">shortify.com</a>
143
-
144
- </li>
145
- <li><a href="http://0rz.net">0rz.net</a>
146
-
147
- </li>
148
- <li><a href="http://moourl.com">moourl.com</a>
149
-
150
- </li>
151
- <li><a href="http://urltea.com">urltea.com</a>
152
-
153
- </li>
154
- </ul>
155
- <h2>Usage:</h2>
156
- <p>
157
- call-seq:
158
- </p>
159
- <pre>
160
- require &quot;shorturl&quot;
161
- puts ShortURL.shorten(&quot;http://mypage.com&quot;)
162
- puts ShortURL.shorten(&quot;http://mypage.com&quot;, :moourl)
163
- </pre>
164
- <p>
165
- The second parameter represents the service you want to use. These are:
166
- </p>
167
- <ul>
168
- <li><tt>:rubyurl</tt>
169
-
170
- </li>
171
- <li><tt>:tinyurl</tt>
172
-
173
- </li>
174
- <li><tt>:shorl</tt>
175
-
176
- </li>
177
- <li><tt>:snipurl</tt>
178
-
179
- </li>
180
- <li><tt>:metamark</tt>
181
-
182
- </li>
183
- <li><tt>:makeashorterlink</tt>
184
-
185
- </li>
186
- <li><tt>:skinnylink</tt>
187
-
188
- </li>
189
- <li><tt>:linktrim</tt>
190
-
191
- </li>
192
- <li><tt>:shorterlink</tt>
193
-
194
- </li>
195
- <li><tt>:minlink</tt>
196
-
197
- </li>
198
- <li><tt>:lns</tt>
199
-
200
- </li>
201
- <li><tt>:fyad</tt>
202
-
203
- </li>
204
- <li><tt>:d62</tt>
205
-
206
- </li>
207
- <li><tt>:shiturl</tt>
208
-
209
- </li>
210
- <li><tt>:littlink</tt>
211
-
212
- </li>
213
- <li><tt>:clipurl</tt>
214
-
215
- </li>
216
- <li><tt>:shortify</tt>
217
-
218
- </li>
219
- <li><tt>:orz</tt>
220
-
221
- </li>
222
- <li><tt>:moourl</tt>
223
-
224
- </li>
225
- <li><tt>:urltea</tt>
226
-
227
- </li>
228
- </ul>
229
- <p>
230
- You can use <tt><a
231
- href="../classes/ShortURL.html#M000001">ShortURL.valid_services</a></tt> to
232
- obtain a list of the valid services (in case I forget to update the
233
- documentation)
234
- </p>
235
- <h2>Thanks</h2>
236
- <ul>
237
- <li>Marcel Molina Jr., Devin Mullins for some ideas
238
-
239
- </li>
240
- <li>imperator from ruby-lang (I don&#8216;t know your real name, sorry) for
241
- helping me with creating and uploading a RubyGem
242
-
243
- </li>
244
- <li>Daniel Dipaolo for telling me about ln-s.net and fyad.org
245
-
246
- </li>
247
- </ul>
248
- <h2>Authors</h2>
249
- <ul>
250
- <li>Vincent Foley (original developer)
251
-
252
- </li>
253
- <li>Robby Russell &lt;robbyrussell@gmail.com&gt;
254
-
255
- </li>
256
- </ul>
257
-
258
- </div>
259
-
260
-
261
- </div>
262
-
263
-
264
- </div>
265
-
266
-
267
- <!-- if includes -->
268
-
269
- <div id="section">
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
- <!-- if method_list -->
279
-
280
-
281
- </div>
282
-
283
-
284
- <div id="validator-badges">
285
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
286
- </div>
287
-
288
- </body>
289
- </html>