campfire-bot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. data/.autotest +11 -0
  2. data/.gitignore +6 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +57 -0
  5. data/README.textile +52 -0
  6. data/TODO +72 -0
  7. data/bin/bot +13 -0
  8. data/campfire-bot.gemspec +27 -0
  9. data/cfbot-stop.sh +8 -0
  10. data/config.example.yml +31 -0
  11. data/lib/bot.rb +194 -0
  12. data/lib/event.rb +114 -0
  13. data/lib/message.rb +30 -0
  14. data/lib/plugin.rb +77 -0
  15. data/lib/version.rb +3 -0
  16. data/plugins/accountability.rb +45 -0
  17. data/plugins/austin.rb +29 -0
  18. data/plugins/basecamp.rb +48 -0
  19. data/plugins/beer.rb +214 -0
  20. data/plugins/beijing_tally.rb +30 -0
  21. data/plugins/boop.rb +127 -0
  22. data/plugins/bruce.rb +15 -0
  23. data/plugins/bugzilla.rb +198 -0
  24. data/plugins/calvin.rb +43 -0
  25. data/plugins/chuck.rb +23 -0
  26. data/plugins/dilbert.rb +51 -0
  27. data/plugins/excuse.rb +478 -0
  28. data/plugins/fail.rb +16 -0
  29. data/plugins/figlet.rb +10 -0
  30. data/plugins/fun.rb +95 -0
  31. data/plugins/garfield.rb +43 -0
  32. data/plugins/generic_search.rb +66 -0
  33. data/plugins/help.rb +13 -0
  34. data/plugins/infobot.rb +58 -0
  35. data/plugins/insult.rb +87 -0
  36. data/plugins/jira.rb +197 -0
  37. data/plugins/lolcats.rb +17 -0
  38. data/plugins/our_quotes.rb +195 -0
  39. data/plugins/quote.rb +31 -0
  40. data/plugins/schneier.rb +28 -0
  41. data/plugins/seen.rb +88 -0
  42. data/plugins/signal_filter.rb +9 -0
  43. data/plugins/svn.rb +167 -0
  44. data/plugins/twitter_echo.rb +54 -0
  45. data/plugins/unfuddle.rb +69 -0
  46. data/plugins/weather.rb +25 -0
  47. data/plugins/xkcd.rb +43 -0
  48. data/spec/beer_spec.rb +224 -0
  49. data/spec/bugzilla_spec.rb +90 -0
  50. data/spec/command_spec.rb +96 -0
  51. data/spec/jira_spec.rb +264 -0
  52. data/spec/our_quotes_spec.rb +186 -0
  53. data/spec/plugin_spec.rb +43 -0
  54. data/spec/spec.opts +1 -0
  55. data/vendor/escape/ChangeLog +30 -0
  56. data/vendor/escape/Makefile +5 -0
  57. data/vendor/escape/README +81 -0
  58. data/vendor/escape/VERSION +1 -0
  59. data/vendor/escape/escape.rb +302 -0
  60. data/vendor/escape/install.rb +109 -0
  61. data/vendor/escape/misc/README.erb +85 -0
  62. data/vendor/escape/rdoc/classes/Escape.html +427 -0
  63. data/vendor/escape/rdoc/classes/Escape.src/M000022.html +19 -0
  64. data/vendor/escape/rdoc/classes/Escape.src/M000023.html +32 -0
  65. data/vendor/escape/rdoc/classes/Escape.src/M000024.html +24 -0
  66. data/vendor/escape/rdoc/classes/Escape.src/M000025.html +19 -0
  67. data/vendor/escape/rdoc/classes/Escape.src/M000026.html +48 -0
  68. data/vendor/escape/rdoc/classes/Escape.src/M000027.html +19 -0
  69. data/vendor/escape/rdoc/classes/Escape.src/M000028.html +19 -0
  70. data/vendor/escape/rdoc/classes/Escape/HTMLAttrValue.html +113 -0
  71. data/vendor/escape/rdoc/classes/Escape/HTMLEscaped.html +113 -0
  72. data/vendor/escape/rdoc/classes/Escape/PercentEncoded.html +113 -0
  73. data/vendor/escape/rdoc/classes/Escape/ShellEscaped.html +113 -0
  74. data/vendor/escape/rdoc/classes/Escape/StringWrapper.html +242 -0
  75. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000029.html +18 -0
  76. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000030.html +18 -0
  77. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000031.html +18 -0
  78. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000032.html +18 -0
  79. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000033.html +18 -0
  80. data/vendor/escape/rdoc/classes/Escape/StringWrapper.src/M000035.html +18 -0
  81. data/vendor/escape/rdoc/classes/TestEscapeHTML.html +182 -0
  82. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000008.html +18 -0
  83. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000009.html +18 -0
  84. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000010.html +18 -0
  85. data/vendor/escape/rdoc/classes/TestEscapeHTML.src/M000011.html +18 -0
  86. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.html +182 -0
  87. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000012.html +18 -0
  88. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000013.html +19 -0
  89. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000014.html +20 -0
  90. data/vendor/escape/rdoc/classes/TestEscapePercentEncoded.src/M000015.html +22 -0
  91. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.html +167 -0
  92. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.src/M000016.html +18 -0
  93. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.src/M000017.html +20 -0
  94. data/vendor/escape/rdoc/classes/TestEscapeShellEscaped.src/M000018.html +20 -0
  95. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.html +167 -0
  96. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.src/M000019.html +20 -0
  97. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.src/M000020.html +24 -0
  98. data/vendor/escape/rdoc/classes/TestEscapeStringWrapper.src/M000021.html +22 -0
  99. data/vendor/escape/rdoc/files/escape_rb.html +136 -0
  100. data/vendor/escape/rdoc/files/install_rb.html +250 -0
  101. data/vendor/escape/rdoc/files/install_rb.src/M000001.html +23 -0
  102. data/vendor/escape/rdoc/files/install_rb.src/M000002.html +31 -0
  103. data/vendor/escape/rdoc/files/install_rb.src/M000003.html +27 -0
  104. data/vendor/escape/rdoc/files/install_rb.src/M000004.html +27 -0
  105. data/vendor/escape/rdoc/files/install_rb.src/M000005.html +21 -0
  106. data/vendor/escape/rdoc/files/install_rb.src/M000006.html +23 -0
  107. data/vendor/escape/rdoc/files/install_rb.src/M000007.html +21 -0
  108. data/vendor/escape/rdoc/files/test/test-escape_rb.html +109 -0
  109. data/vendor/escape/rdoc/fr_class_index.html +36 -0
  110. data/vendor/escape/rdoc/fr_file_index.html +29 -0
  111. data/vendor/escape/rdoc/fr_method_index.html +61 -0
  112. data/vendor/escape/rdoc/index.html +24 -0
  113. data/vendor/escape/rdoc/rdoc-style.css +208 -0
  114. data/vendor/escape/test/test-escape.rb +90 -0
  115. metadata +259 -0
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # usage: ruby install.rb [-n]
4
+ # options:
5
+ # -n : don't install
6
+ #
7
+ # Author: Tanaka Akira <akr@m17n.org>
8
+
9
+ require 'optparse'
10
+ require 'fileutils'
11
+
12
+ def target_directory
13
+ $:.each {|loc|
14
+ if %r{/site_ruby/[\d.]+\z} =~ loc
15
+ return loc
16
+ end
17
+ }
18
+ raise "could not find target install directory"
19
+ end
20
+
21
+ CVS_FILES = {}
22
+ def cvs_files(dir)
23
+ return CVS_FILES[dir] if CVS_FILES.include? dir
24
+ if File.directory? "#{dir}/CVS"
25
+ result = {}
26
+ File.foreach("#{dir}/CVS/Entries") {|line|
27
+ case line
28
+ when %r{\A/([^/]+)/} then result[$1] = true
29
+ when %r{\AD/([^/]+)/} then result[$1] = true
30
+ end
31
+ }
32
+ else
33
+ result = nil
34
+ end
35
+ CVS_FILES[dir] = result
36
+ result
37
+ end
38
+
39
+ def each_target(&block)
40
+ target_set = {}
41
+ cvs = cvs_files('.')
42
+ Dir.glob("*.rb") {|filename|
43
+ next if /\Atest-/ =~ filename
44
+ next if /\Ainstall/ =~ filename
45
+ next if cvs && !cvs.include?(filename)
46
+ target_set[filename] = true
47
+ yield filename
48
+ each_require(filename, target_set, &block)
49
+ }
50
+ end
51
+
52
+ def each_require(file, target_set, &block)
53
+ File.foreach(file) {|line|
54
+ next if /\A\s*require\s+['"]([^'"]+)['"]/ !~ line
55
+ feature = $1
56
+ filename = "#{feature}.rb"
57
+ next if target_set.include? filename
58
+ next if !File.exist?(filename)
59
+ target_set[filename] = true
60
+ yield filename
61
+ each_require(filename, target_set, &block)
62
+ }
63
+ end
64
+
65
+ def collect_target
66
+ result = []
67
+ each_target {|filename| result << filename }
68
+ result.sort!
69
+ result
70
+ end
71
+
72
+ def install_file(src, dst)
73
+ ignore_exc(Errno::ENOENT) { return if FileUtils.compare_file src, dst }
74
+ # check shadow
75
+ ignore_exc(Errno::ENOENT) { File.unlink dst }
76
+ FileUtils.mkdir_p(File.dirname(dst), :mode=>0755)
77
+ FileUtils.cp(src, dst, :verbose => true)
78
+ File.chmod(0644, dst)
79
+ end
80
+
81
+ def ignore_exc(exc)
82
+ begin
83
+ yield
84
+ rescue exc
85
+ end
86
+ end
87
+
88
+ $opt_n = false
89
+ ARGV.options {|q|
90
+ q.banner = 'ruby install.rb [opts]'
91
+ q.def_option('--help', 'show this message') {puts q; exit(0)}
92
+ q.def_option('-n', "don't install") { $opt_n = true }
93
+ q.parse!
94
+ }
95
+
96
+ if $opt_n
97
+ dir = target_directory
98
+ collect_target.each {|filename|
99
+ puts "-> #{dir}/#{filename}"
100
+ }
101
+ exit
102
+ else
103
+ File.umask 022
104
+ dir = target_directory
105
+ collect_target.each {|filename|
106
+ install_file filename, "#{dir}/#{filename}"
107
+ }
108
+ end
109
+
@@ -0,0 +1,85 @@
1
+ = escape - HTML/URI/shell escaping utilities
2
+ <%
3
+ def version
4
+ File.read("VERSION").chomp
5
+ end
6
+ %>
7
+
8
+ escape library provides several HTML/URI/shell escaping functions.
9
+
10
+ == Author
11
+
12
+ Tanaka Akira <akr@fsij.org>
13
+
14
+ == Home Page
15
+
16
+ ((<URL:http://www.a-k-r.org/escape/>))
17
+
18
+ == Feature
19
+
20
+ * several escaping/composing functions
21
+ * HTML text
22
+ * HTML attribute value
23
+ * HTML form (x-www-form-urlencoded)
24
+ * URI path
25
+ * shell command line
26
+ * dedicated classes for escaped strings
27
+ * escape and compose strongly related strings at once
28
+
29
+ == Usage
30
+
31
+ require 'escape'
32
+
33
+ Escape.shell_command(["echo", "*"]) #=> #<Escape::ShellEscaped: echo '*'>
34
+ Escape.uri_path("a?b/c?d/e?f") #=> #<Escape::PercentEncoded: a%3Fb/c%3Fd/e%3Ff>
35
+ Escape.html_form([["a","b"], ["c","d"]]) #=> #<Escape::PercentEncoded: a=b&c=d>
36
+ Escape.html_form({"a"=>"b", "c"=>"d"}) #=> #<Escape::PercentEncoded: a=b&c=d>
37
+ Escape.html_text("a & b < c > d") #=> #<Escape::HTMLEscaped: a &amp; b &lt; c &gt; d>
38
+ Escape.html_attr_value("ab&<>\"c") #=> #<Escape::HTMLAttrValue: "ab&amp;&lt;&gt;&quot;c">
39
+
40
+ == Requirements
41
+
42
+ * ruby : http://www.ruby-lang.org/
43
+
44
+ == Download
45
+
46
+ * latest release: ((<escape-<%=version%>.tar.gz|URL:escape-<%=version%>.tar.gz>))
47
+
48
+ * development version in Subversion repository:
49
+
50
+ % svn co svn://svn@svn.a-k-r.org/akr/escape/trunk escape
51
+
52
+ == Install
53
+
54
+ % ruby install.rb
55
+
56
+ == Reference Manual
57
+
58
+ See rdoc/classes/Escape.html or
59
+ ((<URL:http://www.a-k-r.org/escape/rdoc/classes/Escape.html>))
60
+
61
+ == License
62
+
63
+ The modified BSD licence
64
+
65
+ Redistribution and use in source and binary forms, with or without
66
+ modification, are permitted provided that the following conditions are met:
67
+
68
+ 1. Redistributions of source code must retain the above copyright notice, this
69
+ list of conditions and the following disclaimer.
70
+ 2. Redistributions in binary form must reproduce the above copyright notice,
71
+ this list of conditions and the following disclaimer in the documentation
72
+ and/or other materials provided with the distribution.
73
+ 3. The name of the author may not be used to endorse or promote products
74
+ derived from this software without specific prior written permission.
75
+
76
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
77
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
78
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
79
+ EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
80
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
81
+ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
82
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
83
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
84
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
85
+ OF SUCH DAMAGE.
@@ -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>