campfire-bot_alexchee 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 (80) hide show
  1. data/.autotest +11 -0
  2. data/.gitignore +6 -0
  3. data/Gemfile +12 -0
  4. data/README.textile +62 -0
  5. data/TODO +72 -0
  6. data/bin/campfire-bot +59 -0
  7. data/campfire-bot.gemspec +24 -0
  8. data/cfbot-stop.sh +8 -0
  9. data/config.example.yml +32 -0
  10. data/lib/bot.rb +194 -0
  11. data/lib/event.rb +114 -0
  12. data/lib/message.rb +30 -0
  13. data/lib/plugin.rb +77 -0
  14. data/lib/version.rb +3 -0
  15. data/plugins-example/fun.rb +95 -0
  16. data/spec/command_spec.rb +96 -0
  17. data/spec/plugin_spec.rb +43 -0
  18. data/spec/spec.opts +1 -0
  19. data/tmp/.gitignore +0 -0
  20. data/vendor/escape/ChangeLog +30 -0
  21. data/vendor/escape/Makefile +5 -0
  22. data/vendor/escape/README +81 -0
  23. data/vendor/escape/VERSION +1 -0
  24. data/vendor/escape/escape.rb +302 -0
  25. data/vendor/escape/install.rb +109 -0
  26. data/vendor/escape/misc/README.erb +85 -0
  27. data/vendor/escape/rdoc/classes/Escape/HTMLAttrValue.html +113 -0
  28. data/vendor/escape/rdoc/classes/Escape/HTMLEscaped.html +113 -0
  29. data/vendor/escape/rdoc/classes/Escape/PercentEncoded.html +113 -0
  30. data/vendor/escape/rdoc/classes/Escape/ShellEscaped.html +113 -0
  31. data/vendor/escape/rdoc/classes/Escape/StringWrapper.html +242 -0
  32. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000029.html +18 -0
  33. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000030.html +18 -0
  34. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000031.html +18 -0
  35. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000032.html +18 -0
  36. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000033.html +18 -0
  37. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000035.html +18 -0
  38. data/vendor/escape/rdoc/classes/Escape.html +427 -0
  39. data/vendor/escape/rdoc/classes/Escape.src/M000022.html +19 -0
  40. data/vendor/escape/rdoc/classes/Escape.src/M000023.html +32 -0
  41. data/vendor/escape/rdoc/classes/Escape.src/M000024.html +24 -0
  42. data/vendor/escape/rdoc/classes/Escape.src/M000025.html +19 -0
  43. data/vendor/escape/rdoc/classes/Escape.src/M000026.html +48 -0
  44. data/vendor/escape/rdoc/classes/Escape.src/M000027.html +19 -0
  45. data/vendor/escape/rdoc/classes/Escape.src/M000028.html +19 -0
  46. data/vendor/escape/rdoc/classes/TestEscapeHTML.html +182 -0
  47. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000008.html +18 -0
  48. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000009.html +18 -0
  49. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000010.html +18 -0
  50. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000011.html +18 -0
  51. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.html +182 -0
  52. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000012.html +18 -0
  53. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000013.html +19 -0
  54. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000014.html +20 -0
  55. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000015.html +22 -0
  56. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.html +167 -0
  57. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.src/M000016.html +18 -0
  58. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.src/M000017.html +20 -0
  59. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.src/M000018.html +20 -0
  60. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.html +167 -0
  61. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.src/M000019.html +20 -0
  62. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.src/M000020.html +24 -0
  63. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.src/M000021.html +22 -0
  64. data/vendor/escape/rdoc/files/escape_rb.html +136 -0
  65. data/vendor/escape/rdoc/files/install_rb.html +250 -0
  66. data/vendor/escape/rdoc/files/install_rb.src/M000001.html +23 -0
  67. data/vendor/escape/rdoc/files/install_rb.src/M000002.html +31 -0
  68. data/vendor/escape/rdoc/files/install_rb.src/M000003.html +27 -0
  69. data/vendor/escape/rdoc/files/install_rb.src/M000004.html +27 -0
  70. data/vendor/escape/rdoc/files/install_rb.src/M000005.html +21 -0
  71. data/vendor/escape/rdoc/files/install_rb.src/M000006.html +23 -0
  72. data/vendor/escape/rdoc/files/install_rb.src/M000007.html +21 -0
  73. data/vendor/escape/rdoc/files/test/test-escape_rb.html +109 -0
  74. data/vendor/escape/rdoc/fr_class_index.html +36 -0
  75. data/vendor/escape/rdoc/fr_file_index.html +29 -0
  76. data/vendor/escape/rdoc/fr_method_index.html +61 -0
  77. data/vendor/escape/rdoc/index.html +24 -0
  78. data/vendor/escape/rdoc/rdoc-style.css +208 -0
  79. data/vendor/escape/test/test-escape.rb +90 -0
  80. metadata +209 -0
@@ -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>hash (Escape::StringWrapper)</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 escape.rb, line 59</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">hash</span>
15
+ <span class="ruby-ivar">@str</span>.<span class="ruby-identifier">hash</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,427 @@
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: Escape</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">Escape</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/escape_rb.html">
59
+ escape.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
+ <div id="description">
76
+ <p>
77
+ <a href="Escape.html">Escape</a> module provides several escape functions.
78
+ </p>
79
+ <ul>
80
+ <li>URI
81
+
82
+ </li>
83
+ <li>HTML
84
+
85
+ </li>
86
+ <li>shell command
87
+
88
+ </li>
89
+ </ul>
90
+
91
+ </div>
92
+
93
+
94
+ </div>
95
+
96
+ <div id="method-list">
97
+ <h3 class="section-bar">Methods</h3>
98
+
99
+ <div class="name-list">
100
+ <a href="#M000028">html_attr_value</a>&nbsp;&nbsp;
101
+ <a href="#M000026">html_form</a>&nbsp;&nbsp;
102
+ <a href="#M000027">html_text</a>&nbsp;&nbsp;
103
+ <a href="#M000022">shell_command</a>&nbsp;&nbsp;
104
+ <a href="#M000023">shell_single_word</a>&nbsp;&nbsp;
105
+ <a href="#M000025">uri_path</a>&nbsp;&nbsp;
106
+ <a href="#M000024">uri_segment</a>&nbsp;&nbsp;
107
+ </div>
108
+ </div>
109
+
110
+ </div>
111
+
112
+
113
+ <!-- if includes -->
114
+
115
+ <div id="section">
116
+
117
+ <div id="class-list">
118
+ <h3 class="section-bar">Classes and Modules</h3>
119
+
120
+ Class <a href="Escape/HTMLAttrValue.html" class="link">Escape::HTMLAttrValue</a><br />
121
+ Class <a href="Escape/HTMLEscaped.html" class="link">Escape::HTMLEscaped</a><br />
122
+ Class <a href="Escape/PercentEncoded.html" class="link">Escape::PercentEncoded</a><br />
123
+ Class <a href="Escape/ShellEscaped.html" class="link">Escape::ShellEscaped</a><br />
124
+ Class <a href="Escape/StringWrapper.html" class="link">Escape::StringWrapper</a><br />
125
+
126
+ </div>
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ <!-- if method_list -->
135
+ <div id="methods">
136
+ <h3 class="section-bar">Public Instance methods</h3>
137
+
138
+ <div id="method-M000028" class="method-detail">
139
+ <a name="M000028"></a>
140
+
141
+ <div class="method-heading">
142
+ <a href="Escape.src/M000028.html" target="Code" class="method-signature"
143
+ onclick="popupCode('Escape.src/M000028.html');return false;">
144
+ <span class="method-name">html_attr_value</span><span class="method-args">(str)</span>
145
+ </a>
146
+ </div>
147
+
148
+ <div class="method-description">
149
+ <p>
150
+ <a href="Escape.html#M000028">Escape.html_attr_value</a> encodes a string
151
+ as a double-quoted HTML attribute using character references. It returns an
152
+ instance of <a href="Escape/HTMLAttrValue.html">HTMLAttrValue</a>.
153
+ </p>
154
+ <pre>
155
+ Escape.html_attr_value(&quot;abc&quot;) #=&gt; #&lt;Escape::HTMLAttrValue: &quot;abc&quot;&gt;
156
+ Escape.html_attr_value(&quot;a&amp;b&quot;) #=&gt; #&lt;Escape::HTMLAttrValue: &quot;a&amp;amp;b&quot;&gt;
157
+ Escape.html_attr_value(&quot;ab&amp;&lt;&gt;\&quot;c&quot;) #=&gt; #&lt;Escape::HTMLAttrValue: &quot;ab&amp;amp;&amp;lt;&amp;gt;&amp;quot;c&quot;&gt;
158
+ Escape.html_attr_value(&quot;a'c&quot;) #=&gt; #&lt;Escape::HTMLAttrValue: &quot;a'c&quot;&gt;
159
+ </pre>
160
+ <p>
161
+ It escapes 4 characters:
162
+ </p>
163
+ <ul>
164
+ <li>&#8217;&amp;&#8217; to &#8217;&amp;amp;&#8217;
165
+
166
+ </li>
167
+ <li>&#8217;&lt;&#8217; to &#8217;&amp;lt;&#8217;
168
+
169
+ </li>
170
+ <li>&#8217;&gt;&#8217; to &#8217;&amp;gt;&#8217;
171
+
172
+ </li>
173
+ <li>&#8217;&quot;&#8217; to &#8217;&amp;quot;&#8217;
174
+
175
+ </li>
176
+ </ul>
177
+ </div>
178
+ </div>
179
+
180
+ <div id="method-M000026" class="method-detail">
181
+ <a name="M000026"></a>
182
+
183
+ <div class="method-heading">
184
+ <a href="Escape.src/M000026.html" target="Code" class="method-signature"
185
+ onclick="popupCode('Escape.src/M000026.html');return false;">
186
+ <span class="method-name">html_form</span><span class="method-args">(pairs, sep='&amp;')</span>
187
+ </a>
188
+ </div>
189
+
190
+ <div class="method-description">
191
+ <p>
192
+ <a href="Escape.html#M000026">Escape.html_form</a> composes HTML form
193
+ key-value pairs as a x-www-form-urlencoded encoded string. It returns an
194
+ instance of <a href="Escape/PercentEncoded.html">PercentEncoded</a>.
195
+ </p>
196
+ <p>
197
+ <a href="Escape.html#M000026">Escape.html_form</a> takes an array of pair
198
+ of strings or an hash from string to string.
199
+ </p>
200
+ <pre>
201
+ Escape.html_form([[&quot;a&quot;,&quot;b&quot;], [&quot;c&quot;,&quot;d&quot;]]) #=&gt; #&lt;Escape::PercentEncoded: a=b&amp;c=d&gt;
202
+ Escape.html_form({&quot;a&quot;=&gt;&quot;b&quot;, &quot;c&quot;=&gt;&quot;d&quot;}) #=&gt; #&lt;Escape::PercentEncoded: a=b&amp;c=d&gt;
203
+ </pre>
204
+ <p>
205
+ In the array form, it is possible to use same key more than once. (It is
206
+ required for a HTML form which contains checkboxes and select element with
207
+ multiple attribute.)
208
+ </p>
209
+ <pre>
210
+ Escape.html_form([[&quot;k&quot;,&quot;1&quot;], [&quot;k&quot;,&quot;2&quot;]]) #=&gt; #&lt;Escape::PercentEncoded: k=1&amp;k=2&gt;
211
+ </pre>
212
+ <p>
213
+ If the strings contains characters which must be escaped in
214
+ x-www-form-urlencoded, they are escaped using %-encoding.
215
+ </p>
216
+ <pre>
217
+ Escape.html_form([[&quot;k=&quot;,&quot;&amp;;=&quot;]]) #=&gt; #&lt;Escape::PercentEncoded: k%3D=%26%3B%3D&gt;
218
+ </pre>
219
+ <p>
220
+ The separator can be specified by the optional second argument.
221
+ </p>
222
+ <pre>
223
+ Escape.html_form([[&quot;a&quot;,&quot;b&quot;], [&quot;c&quot;,&quot;d&quot;]], &quot;;&quot;) #=&gt; #&lt;Escape::PercentEncoded: a=b;c=d&gt;
224
+ </pre>
225
+ <p>
226
+ See HTML 4.01 for details.
227
+ </p>
228
+ </div>
229
+ </div>
230
+
231
+ <div id="method-M000027" class="method-detail">
232
+ <a name="M000027"></a>
233
+
234
+ <div class="method-heading">
235
+ <a href="Escape.src/M000027.html" target="Code" class="method-signature"
236
+ onclick="popupCode('Escape.src/M000027.html');return false;">
237
+ <span class="method-name">html_text</span><span class="method-args">(str)</span>
238
+ </a>
239
+ </div>
240
+
241
+ <div class="method-description">
242
+ <p>
243
+ <a href="Escape.html#M000027">Escape.html_text</a> escapes a string
244
+ appropriate for HTML text using character references. It returns an
245
+ instance of <a href="Escape/HTMLEscaped.html">HTMLEscaped</a>.
246
+ </p>
247
+ <p>
248
+ It escapes 3 characters:
249
+ </p>
250
+ <ul>
251
+ <li>&#8217;&amp;&#8217; to &#8217;&amp;amp;&#8217;
252
+
253
+ </li>
254
+ <li>&#8217;&lt;&#8217; to &#8217;&amp;lt;&#8217;
255
+
256
+ </li>
257
+ <li>&#8217;&gt;&#8217; to &#8217;&amp;gt;&#8217;
258
+
259
+ </li>
260
+ </ul>
261
+ <pre>
262
+ Escape.html_text(&quot;abc&quot;) #=&gt; #&lt;Escape::HTMLEscaped: abc&gt;
263
+ Escape.html_text(&quot;a &amp; b &lt; c &gt; d&quot;) #=&gt; #&lt;Escape::HTMLEscaped: a &amp;amp; b &amp;lt; c &amp;gt; d&gt;
264
+ </pre>
265
+ <p>
266
+ This function is not appropriate for escaping HTML element attribute
267
+ because quotes are not escaped.
268
+ </p>
269
+ </div>
270
+ </div>
271
+
272
+ <div id="method-M000022" class="method-detail">
273
+ <a name="M000022"></a>
274
+
275
+ <div class="method-heading">
276
+ <a href="Escape.src/M000022.html" target="Code" class="method-signature"
277
+ onclick="popupCode('Escape.src/M000022.html');return false;">
278
+ <span class="method-name">shell_command</span><span class="method-args">(command)</span>
279
+ </a>
280
+ </div>
281
+
282
+ <div class="method-description">
283
+ <p>
284
+ <a href="Escape.html#M000022">Escape.shell_command</a> composes a sequence
285
+ of words to a single shell command line. All shell meta characters are
286
+ quoted and the words are concatenated with interleaving space. It returns
287
+ an instance of <a href="Escape/ShellEscaped.html">ShellEscaped</a>.
288
+ </p>
289
+ <pre>
290
+ Escape.shell_command([&quot;ls&quot;, &quot;/&quot;]) #=&gt; #&lt;Escape::ShellEscaped: ls /&gt;
291
+ Escape.shell_command([&quot;echo&quot;, &quot;*&quot;]) #=&gt; #&lt;Escape::ShellEscaped: echo '*'&gt;
292
+ </pre>
293
+ <p>
294
+ Note that system(*command) and system(<a
295
+ href="Escape.html#M000022">Escape.shell_command(command)</a>) is roughly
296
+ same. There are two exception as follows.
297
+ </p>
298
+ <ul>
299
+ <li>The first is that the later may invokes /bin/sh.
300
+
301
+ </li>
302
+ <li>The second is an interpretation of an array with only one element: the
303
+ element is parsed by the shell with the former but it is recognized as
304
+ single word with the later. For example, system(*[&quot;echo foo&quot;])
305
+ invokes echo command with an argument &quot;foo&quot;. But system(<a
306
+ href="Escape.html#M000022">Escape.shell_command</a>([&quot;echo
307
+ foo&quot;])) invokes &quot;echo foo&quot; command without arguments (and it
308
+ probably fails).
309
+
310
+ </li>
311
+ </ul>
312
+ </div>
313
+ </div>
314
+
315
+ <div id="method-M000023" class="method-detail">
316
+ <a name="M000023"></a>
317
+
318
+ <div class="method-heading">
319
+ <a href="Escape.src/M000023.html" target="Code" class="method-signature"
320
+ onclick="popupCode('Escape.src/M000023.html');return false;">
321
+ <span class="method-name">shell_single_word</span><span class="method-args">(str)</span>
322
+ </a>
323
+ </div>
324
+
325
+ <div class="method-description">
326
+ <p>
327
+ <a href="Escape.html#M000023">Escape.shell_single_word</a> quotes shell
328
+ meta characters. It returns an instance of <a
329
+ href="Escape/ShellEscaped.html">ShellEscaped</a>.
330
+ </p>
331
+ <p>
332
+ The result string is always single shell word, even if the argument is
333
+ &quot;&quot;. <a
334
+ href="Escape.html#M000023">Escape.shell_single_word</a>(&quot;&quot;)
335
+ returns #&lt;<a href="Escape/ShellEscaped.html">Escape::ShellEscaped</a>:
336
+ &#8217;&#8217;&gt;.
337
+ </p>
338
+ <pre>
339
+ Escape.shell_single_word(&quot;&quot;) #=&gt; #&lt;Escape::ShellEscaped: ''&gt;
340
+ Escape.shell_single_word(&quot;foo&quot;) #=&gt; #&lt;Escape::ShellEscaped: foo&gt;
341
+ Escape.shell_single_word(&quot;*&quot;) #=&gt; #&lt;Escape::ShellEscaped: '*'&gt;
342
+ </pre>
343
+ </div>
344
+ </div>
345
+
346
+ <div id="method-M000025" class="method-detail">
347
+ <a name="M000025"></a>
348
+
349
+ <div class="method-heading">
350
+ <a href="Escape.src/M000025.html" target="Code" class="method-signature"
351
+ onclick="popupCode('Escape.src/M000025.html');return false;">
352
+ <span class="method-name">uri_path</span><span class="method-args">(str)</span>
353
+ </a>
354
+ </div>
355
+
356
+ <div class="method-description">
357
+ <p>
358
+ <a href="Escape.html#M000025">Escape.uri_path</a> escapes URI path using
359
+ percent-encoding. The given path should be a sequence of (non-escaped)
360
+ segments separated by &quot;/&quot;. The segments cannot contains
361
+ &quot;/&quot;. It returns an instance of <a
362
+ href="Escape/PercentEncoded.html">PercentEncoded</a>.
363
+ </p>
364
+ <pre>
365
+ Escape.uri_path(&quot;a/b/c&quot;) #=&gt; #&lt;Escape::PercentEncoded: a/b/c&gt;
366
+ Escape.uri_path(&quot;a?b/c?d/e?f&quot;) #=&gt; #&lt;Escape::PercentEncoded: a%3Fb/c%3Fd/e%3Ff&gt;
367
+ </pre>
368
+ <p>
369
+ The path is the part after authority before query in URI, as follows.
370
+ </p>
371
+ <pre>
372
+ scheme://authority/path#fragment
373
+ </pre>
374
+ <p>
375
+ See RFC 3986 for details of URI.
376
+ </p>
377
+ <p>
378
+ Note that this function is not appropriate to convert OS path to URI.
379
+ </p>
380
+ </div>
381
+ </div>
382
+
383
+ <div id="method-M000024" class="method-detail">
384
+ <a name="M000024"></a>
385
+
386
+ <div class="method-heading">
387
+ <a href="Escape.src/M000024.html" target="Code" class="method-signature"
388
+ onclick="popupCode('Escape.src/M000024.html');return false;">
389
+ <span class="method-name">uri_segment</span><span class="method-args">(str)</span>
390
+ </a>
391
+ </div>
392
+
393
+ <div class="method-description">
394
+ <p>
395
+ <a href="Escape.html#M000024">Escape.uri_segment</a> escapes URI segment
396
+ using percent-encoding. It returns an instance of <a
397
+ href="Escape/PercentEncoded.html">PercentEncoded</a>.
398
+ </p>
399
+ <pre>
400
+ Escape.uri_segment(&quot;a/b&quot;) #=&gt; #&lt;Escape::PercentEncoded: a%2Fb&gt;
401
+ </pre>
402
+ <p>
403
+ The segment is &quot;/&quot;-splitted element after authority before query
404
+ in URI, as follows.
405
+ </p>
406
+ <pre>
407
+ scheme://authority/segment1/segment2/.../segmentN?query#fragment
408
+ </pre>
409
+ <p>
410
+ See RFC 3986 for details of URI.
411
+ </p>
412
+ </div>
413
+ </div>
414
+
415
+
416
+ </div>
417
+
418
+
419
+ </div>
420
+
421
+
422
+ <div id="validator-badges">
423
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
424
+ </div>
425
+
426
+ </body>
427
+ </html>
@@ -0,0 +1,19 @@
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>shell_command (Escape)</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 escape.rb, line 86</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shell_command</span>(<span class="ruby-identifier">command</span>)
15
+ <span class="ruby-identifier">s</span> = <span class="ruby-identifier">command</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">word</span><span class="ruby-operator">|</span> <span class="ruby-identifier">shell_single_word</span>(<span class="ruby-identifier">word</span>) }.<span class="ruby-identifier">join</span>(<span class="ruby-value str">' '</span>)
16
+ <span class="ruby-constant">ShellEscaped</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">s</span>)
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,32 @@
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>shell_single_word (Escape)</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 escape.rb, line 101</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shell_single_word</span>(<span class="ruby-identifier">str</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">empty?</span>
16
+ <span class="ruby-constant">ShellEscaped</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-value str">&quot;''&quot;</span>)
17
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-regexp re">%r{\A[0-9A-Za-z+,./:=@_-]+\z}</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">str</span>
18
+ <span class="ruby-constant">ShellEscaped</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">str</span>)
19
+ <span class="ruby-keyword kw">else</span>
20
+ <span class="ruby-identifier">result</span> = <span class="ruby-value str">''</span>
21
+ <span class="ruby-identifier">str</span>.<span class="ruby-identifier">scan</span>(<span class="ruby-regexp re">/('+)|[^']+/</span>) {
22
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">$1</span>
23
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">%q{\'}</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">$1</span>.<span class="ruby-identifier">length</span>
24
+ <span class="ruby-keyword kw">else</span>
25
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;'#{$&amp;}'&quot;</span>
26
+ <span class="ruby-keyword kw">end</span>
27
+ }
28
+ <span class="ruby-constant">ShellEscaped</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">result</span>)
29
+ <span class="ruby-keyword kw">end</span>
30
+ <span class="ruby-keyword kw">end</span></pre>
31
+ </body>
32
+ </html>
@@ -0,0 +1,24 @@
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>uri_segment (Escape)</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 escape.rb, line 132</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_segment</span>(<span class="ruby-identifier">str</span>)
15
+ <span class="ruby-comment cmt"># pchar - pct-encoded = unreserved / sub-delims / &quot;:&quot; / &quot;@&quot;</span>
16
+ <span class="ruby-comment cmt"># unreserved = ALPHA / DIGIT / &quot;-&quot; / &quot;.&quot; / &quot;_&quot; / &quot;~&quot;</span>
17
+ <span class="ruby-comment cmt"># sub-delims = &quot;!&quot; / &quot;$&quot; / &quot;&amp;&quot; / &quot;'&quot; / &quot;(&quot; / &quot;)&quot; / &quot;*&quot; / &quot;+&quot; / &quot;,&quot; / &quot;;&quot; / &quot;=&quot;</span>
18
+ <span class="ruby-identifier">s</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">%r{[^A-Za-z0-9\-._~!$&amp;'()*+,;=:@]}n</span>) {
19
+ <span class="ruby-value str">'%'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">$&amp;</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">&quot;H2&quot;</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">upcase</span>
20
+ }
21
+ <span class="ruby-constant">PercentEncoded</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">s</span>)
22
+ <span class="ruby-keyword kw">end</span></pre>
23
+ </body>
24
+ </html>
@@ -0,0 +1,19 @@
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>uri_path (Escape)</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 escape.rb, line 157</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uri_path</span>(<span class="ruby-identifier">str</span>)
15
+ <span class="ruby-identifier">s</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">%r{[^/]+}n</span>) { <span class="ruby-identifier">uri_segment</span>(<span class="ruby-identifier">$&amp;</span>) }
16
+ <span class="ruby-constant">PercentEncoded</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">s</span>)
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,48 @@
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>html_form (Escape)</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 escape.rb, line 209</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html_form</span>(<span class="ruby-identifier">pairs</span>, <span class="ruby-identifier">sep</span>=<span class="ruby-value str">'&amp;'</span>)
15
+ <span class="ruby-identifier">r</span> = <span class="ruby-value str">''</span>
16
+ <span class="ruby-identifier">first</span> = <span class="ruby-keyword kw">true</span>
17
+ <span class="ruby-identifier">pairs</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
18
+ <span class="ruby-comment cmt"># query-chars - pct-encoded - x-www-form-urlencoded-delimiters =</span>
19
+ <span class="ruby-comment cmt"># unreserved / &quot;!&quot; / &quot;$&quot; / &quot;'&quot; / &quot;(&quot; / &quot;)&quot; / &quot;*&quot; / &quot;,&quot; / &quot;:&quot; / &quot;@&quot; / &quot;/&quot; / &quot;?&quot;</span>
20
+ <span class="ruby-comment cmt"># query-char - pct-encoded = unreserved / sub-delims / &quot;:&quot; / &quot;@&quot; / &quot;/&quot; / &quot;?&quot;</span>
21
+ <span class="ruby-comment cmt"># query-char = pchar / &quot;/&quot; / &quot;?&quot; = unreserved / pct-encoded / sub-delims / &quot;:&quot; / &quot;@&quot; / &quot;/&quot; / &quot;?&quot;</span>
22
+ <span class="ruby-comment cmt"># unreserved = ALPHA / DIGIT / &quot;-&quot; / &quot;.&quot; / &quot;_&quot; / &quot;~&quot;</span>
23
+ <span class="ruby-comment cmt"># sub-delims = &quot;!&quot; / &quot;$&quot; / &quot;&amp;&quot; / &quot;'&quot; / &quot;(&quot; / &quot;)&quot; / &quot;*&quot; / &quot;+&quot; / &quot;,&quot; / &quot;;&quot; / &quot;=&quot;</span>
24
+ <span class="ruby-comment cmt"># x-www-form-urlencoded-delimiters = &quot;&amp;&quot; / &quot;+&quot; / &quot;;&quot; / &quot;=&quot;</span>
25
+ <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">sep</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">first</span>
26
+ <span class="ruby-identifier">first</span> = <span class="ruby-keyword kw">false</span>
27
+ <span class="ruby-identifier">k</span>.<span class="ruby-identifier">each_byte</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">byte</span><span class="ruby-operator">|</span>
28
+ <span class="ruby-identifier">ch</span> = <span class="ruby-identifier">byte</span>.<span class="ruby-identifier">chr</span>
29
+ <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">%r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">ch</span>
30
+ <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;%&quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ch</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">&quot;H2&quot;</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">upcase</span>
31
+ <span class="ruby-keyword kw">else</span>
32
+ <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ch</span>
33
+ <span class="ruby-keyword kw">end</span>
34
+ }
35
+ <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">'='</span>
36
+ <span class="ruby-identifier">v</span>.<span class="ruby-identifier">each_byte</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">byte</span><span class="ruby-operator">|</span>
37
+ <span class="ruby-identifier">ch</span> = <span class="ruby-identifier">byte</span>.<span class="ruby-identifier">chr</span>
38
+ <span class="ruby-keyword kw">if</span> <span class="ruby-regexp re">%r{[^0-9A-Za-z\-\._~:/?@!\$'()*,]}n</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">ch</span>
39
+ <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;%&quot;</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ch</span>.<span class="ruby-identifier">unpack</span>(<span class="ruby-value str">&quot;H2&quot;</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">upcase</span>
40
+ <span class="ruby-keyword kw">else</span>
41
+ <span class="ruby-identifier">r</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">ch</span>
42
+ <span class="ruby-keyword kw">end</span>
43
+ }
44
+ }
45
+ <span class="ruby-constant">PercentEncoded</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">r</span>)
46
+ <span class="ruby-keyword kw">end</span></pre>
47
+ </body>
48
+ </html>
@@ -0,0 +1,19 @@
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>html_text (Escape)</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 escape.rb, line 267</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html_text</span>(<span class="ruby-identifier">str</span>)
15
+ <span class="ruby-identifier">s</span> = <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[&amp;&lt;&gt;]/</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ch</span><span class="ruby-operator">|</span> <span class="ruby-constant">HTML_TEXT_ESCAPE_HASH</span>[<span class="ruby-identifier">ch</span>] }
16
+ <span class="ruby-constant">HTMLEscaped</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">s</span>)
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,19 @@
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>html_attr_value (Escape)</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 escape.rb, line 298</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">html_attr_value</span>(<span class="ruby-identifier">str</span>)
15
+ <span class="ruby-identifier">s</span> = <span class="ruby-value str">'&quot;'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">str</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/[&amp;&lt;&gt;&quot;]/</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">ch</span><span class="ruby-operator">|</span> <span class="ruby-constant">HTML_ATTR_ESCAPE_HASH</span>[<span class="ruby-identifier">ch</span>] } <span class="ruby-operator">+</span> <span class="ruby-value str">'&quot;'</span>
16
+ <span class="ruby-constant">HTMLAttrValue</span>.<span class="ruby-identifier">new_no_dup</span>(<span class="ruby-identifier">s</span>)
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>