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,111 +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>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>
@@ -1,202 +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>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>&nbsp;&nbsp;
90
- <a href="#M000003">new</a>&nbsp;&nbsp;
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">&nbsp;[RW]&nbsp;</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">&nbsp;[RW]&nbsp;</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">&nbsp;[RW]&nbsp;</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">&nbsp;[RW]&nbsp;</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">&nbsp;[RW]&nbsp;</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">&nbsp;[RW]&nbsp;</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>
@@ -1,28 +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>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">&quot;/&quot;</span>
20
- <span class="ruby-ivar">@field</span> = <span class="ruby-value str">&quot;url&quot;</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>
@@ -1,26 +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>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">&quot;#{@field}=#{url}&quot;</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">&quot;#{@action}?#{@field}=#{CGI.escape(url)}&quot;</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>
@@ -1,227 +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>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>&nbsp;&nbsp;
90
- <a href="#M000001">valid_services</a>&nbsp;&nbsp;
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(&quot;http://mypage.com&quot;) =&gt; Uses RubyURL
193
- ShortURL.shorten(&quot;http://mypage.com&quot;, :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>