firetower 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.bnsignore ADDED
@@ -0,0 +1,18 @@
1
+ # The list of files that should be ignored by Mr Bones.
2
+ # Lines that start with '#' are comments.
3
+ #
4
+ # A .gitignore file can be used instead by setting it as the ignore
5
+ # file in your Rakefile:
6
+ #
7
+ # Bones {
8
+ # ignore_file '.gitignore'
9
+ # }
10
+ #
11
+ # For a project with a C extension, the following would be a good set of
12
+ # exclude patterns (uncomment them if you want to use them):
13
+ # *.[oa]
14
+ # *~
15
+ announcement.txt
16
+ coverage
17
+ doc
18
+ pkg
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 1.0.0 / 2010-06-02
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
data/README.html ADDED
@@ -0,0 +1,406 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml"
5
+ lang="en" xml:lang="en">
6
+ <head>
7
+ <title>Firetower README</title>
8
+ <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
9
+ <meta name="generator" content="Org-mode"/>
10
+ <meta name="generated" content="2010-07-11 23:51:09 EDT"/>
11
+ <meta name="author" content="Avdi Grimm"/>
12
+ <meta name="description" content=""/>
13
+ <meta name="keywords" content=""/>
14
+ <style type="text/css">
15
+ <!--/*--><![CDATA[/*><!--*/
16
+ html { font-family: Times, serif; font-size: 12pt; }
17
+ .title { text-align: center; }
18
+ .todo { color: red; }
19
+ .done { color: green; }
20
+ .tag { background-color: #add8e6; font-weight:normal }
21
+ .target { }
22
+ .timestamp { color: #bebebe; }
23
+ .timestamp-kwd { color: #5f9ea0; }
24
+ p.verse { margin-left: 3% }
25
+ pre {
26
+ border: 1pt solid #AEBDCC;
27
+ background-color: #F3F5F7;
28
+ padding: 5pt;
29
+ font-family: courier, monospace;
30
+ font-size: 90%;
31
+ overflow:auto;
32
+ }
33
+ table { border-collapse: collapse; }
34
+ td, th { vertical-align: top; }
35
+ dt { font-weight: bold; }
36
+ div.figure { padding: 0.5em; }
37
+ div.figure p { text-align: center; }
38
+ .linenr { font-size:smaller }
39
+ .code-highlighted {background-color:#ffff00;}
40
+ .org-info-js_info-navigation { border-style:none; }
41
+ #org-info-js_console-label { font-size:10px; font-weight:bold;
42
+ white-space:nowrap; }
43
+ .org-info-js_search-highlight {background-color:#ffff00; color:#000000;
44
+ font-weight:bold; }
45
+ /*]]>*/-->
46
+ </style>
47
+ <script type="text/javascript">
48
+ <!--/*--><![CDATA[/*><!--*/
49
+ function CodeHighlightOn(elem, id)
50
+ {
51
+ var target = document.getElementById(id);
52
+ if(null != target) {
53
+ elem.cacheClassElem = elem.className;
54
+ elem.cacheClassTarget = target.className;
55
+ target.className = "code-highlighted";
56
+ elem.className = "code-highlighted";
57
+ }
58
+ }
59
+ function CodeHighlightOff(elem, id)
60
+ {
61
+ var target = document.getElementById(id);
62
+ if(elem.cacheClassElem)
63
+ elem.className = elem.cacheClassElem;
64
+ if(elem.cacheClassTarget)
65
+ target.className = elem.cacheClassTarget;
66
+ }
67
+ /*]]>*///-->
68
+ </script>
69
+ </head>
70
+ <body>
71
+ <div id="content">
72
+
73
+ <h1 class="title">Firetower README</h1>
74
+
75
+
76
+
77
+ <div id="table-of-contents">
78
+ <h2>Table of Contents</h2>
79
+ <div id="text-table-of-contents">
80
+ <ul>
81
+ <li><a href="#sec-1">1 Firetower </a>
82
+ <ul>
83
+ <li><a href="#sec-1.1">1.1 Requirements </a></li>
84
+ <li><a href="#sec-1.2">1.2 Install </a></li>
85
+ <li><a href="#sec-1.3">1.3 Configuration </a>
86
+ <ul>
87
+ <li><a href="#sec-1.3.1">1.3.1 A simple bot </a></li>
88
+ </ul>
89
+ </li>
90
+ <li><a href="#sec-1.4">1.4 Usage </a>
91
+ <ul>
92
+ <li><a href="#sec-1.4.1">1.4.1 Say something in campfire </a></li>
93
+ <li><a href="#sec-1.4.2">1.4.2 Say something to a non-default room </a></li>
94
+ <li><a href="#sec-1.4.3">1.4.3 Paste a code snippet into campfire </a></li>
95
+ <li><a href="#sec-1.4.4">1.4.4 Paste from the clipboaord </a></li>
96
+ <li><a href="#sec-1.4.5">1.4.5 Paste the selected text </a></li>
97
+ <li><a href="#sec-1.4.6">1.4.6 Start server (for notifications, bots, etc.) </a></li>
98
+ <li><a href="#sec-1.4.7">1.4.7 Stop server </a></li>
99
+ </ul>
100
+ </li>
101
+ <li><a href="#sec-1.5">1.5 Plugin API </a></li>
102
+ <li><a href="#sec-1.6">1.6 License </a></li>
103
+ </ul>
104
+ </li>
105
+ </ul>
106
+ </div>
107
+ </div>
108
+
109
+ <div id="outline-container-1" class="outline-2">
110
+ <h2 id="sec-1"><span class="section-number-2">1</span> Firetower </h2>
111
+ <div class="outline-text-2" id="text-1">
112
+
113
+
114
+ <p>
115
+ <img src="images/BaldMountainLookout.jpg" alt="images/BaldMountainLookout.jpg" />
116
+ </p>
117
+ <p>
118
+ A command-line interface to the Campfire API
119
+ (<a href="http://developer.37signals.com/campfire/">http://developer.37signals.com/campfire/</a>) by <a href="mailto:avdi@avdi.org">Avdi Grimm</a>
120
+ </p>
121
+ <p>
122
+ URL: <a href="http://github.com/avdi/firetower">http://github.com/avdi/firetower</a>
123
+ </p>
124
+
125
+ </div>
126
+
127
+ <div id="outline-container-1.1" class="outline-3">
128
+ <h3 id="sec-1.1"><span class="section-number-3">1.1</span> Requirements </h3>
129
+ <div class="outline-text-3" id="text-1.1">
130
+
131
+
132
+ <ul>
133
+ <li>
134
+ Linux (somebody please port this to OS X)
135
+ </li>
136
+ <li>
137
+ <a href="http://www.kfish.org/software/xsel/">xsel</a>
138
+ </li>
139
+ <li>
140
+ <a href="#apt:libnotify-bin">libnotify-bin</a>
141
+
142
+ </li>
143
+ </ul>
144
+ </div>
145
+
146
+ </div>
147
+
148
+ <div id="outline-container-1.2" class="outline-3">
149
+ <h3 id="sec-1.2"><span class="section-number-3">1.2</span> Install </h3>
150
+ <div class="outline-text-3" id="text-1.2">
151
+
152
+
153
+ <pre class="example">
154
+ sudo gem install firetower
155
+ firetower setup
156
+ </pre>
157
+
158
+
159
+ </div>
160
+
161
+ </div>
162
+
163
+ <div id="outline-container-1.3" class="outline-3">
164
+ <h3 id="sec-1.3"><span class="section-number-3">1.3</span> Configuration </h3>
165
+ <div class="outline-text-3" id="text-1.3">
166
+
167
+ <p>Edit $HOME/.firetower/firetower.conf
168
+ </p>
169
+ <p>
170
+ All configuration is done in Ruby. The context is a Firetower::Sesson
171
+ object. You can add handlers for events:
172
+ </p>
173
+ <pre class="example">
174
+ receive do |session, event| ... end
175
+ </pre>
176
+
177
+
178
+ <p>
179
+ Or enable plugins:
180
+ </p>
181
+ <pre class="example">
182
+ use NotifyPlugin
183
+ </pre>
184
+
185
+
186
+
187
+ </div>
188
+
189
+ <div id="outline-container-1.3.1" class="outline-4">
190
+ <h4 id="sec-1.3.1"><span class="section-number-4">1.3.1</span> A simple bot </h4>
191
+ <div class="outline-text-4" id="text-1.3.1">
192
+
193
+ <p>Drop this in ~/.firetower/firetower.conf for a simple (and VERY UNSAFE!) demo
194
+ of a Campfire bot which will eval arbitrary Ruby code:
195
+ </p>
196
+
197
+
198
+
199
+ <pre class="src src-ruby">receive <span style="color: #CC7832; font-weight: bold;">do</span> |session, event|
200
+ <span style="color: #CC7832; font-weight: bold;">if</span> event[<span style="color: #A5F26E;">'type'</span>] == <span style="color: #A5F26E;">'TextMessage'</span> &amp;&amp; event[<span style="color: #A5F26E;">'body'</span>] =~ <span style="color: #A5F26E;">/^!eval (.*)$/</span>
201
+ event.room.account.paste!(event.room.name, <span style="color: #A5F26E;">"Eval result:\n"</span> + eval(<span style="color: #D0D0F3;">$1</span>).to_s)
202
+ <span style="color: #CC7832; font-weight: bold;">end</span>
203
+ <span style="color: #CC7832; font-weight: bold;">end</span>
204
+ </pre>
205
+
206
+
207
+
208
+
209
+ </div>
210
+ </div>
211
+
212
+ </div>
213
+
214
+ <div id="outline-container-1.4" class="outline-3">
215
+ <h3 id="sec-1.4"><span class="section-number-3">1.4</span> Usage </h3>
216
+ <div class="outline-text-3" id="text-1.4">
217
+
218
+
219
+ </div>
220
+
221
+ <div id="outline-container-1.4.1" class="outline-4">
222
+ <h4 id="sec-1.4.1"><span class="section-number-4">1.4.1</span> Say something in campfire </h4>
223
+ <div class="outline-text-4" id="text-1.4.1">
224
+
225
+ <pre class="example">
226
+ firetower say 'blah blah blah'
227
+ </pre>
228
+
229
+ </div>
230
+
231
+ </div>
232
+
233
+ <div id="outline-container-1.4.2" class="outline-4">
234
+ <h4 id="sec-1.4.2"><span class="section-number-4">1.4.2</span> Say something to a non-default room </h4>
235
+ <div class="outline-text-4" id="text-1.4.2">
236
+
237
+ <pre class="example">
238
+ firetower say subdomain='mycompany' room='Water Cooler' 'blah blah blah'
239
+ </pre>
240
+
241
+ </div>
242
+
243
+ </div>
244
+
245
+ <div id="outline-container-1.4.3" class="outline-4">
246
+ <h4 id="sec-1.4.3"><span class="section-number-4">1.4.3</span> Paste a code snippet into campfire </h4>
247
+ <div class="outline-text-4" id="text-1.4.3">
248
+
249
+ <pre class="example">
250
+ firetower paste &lt; hello.rb
251
+ </pre>
252
+
253
+ </div>
254
+
255
+ </div>
256
+
257
+ <div id="outline-container-1.4.4" class="outline-4">
258
+ <h4 id="sec-1.4.4"><span class="section-number-4">1.4.4</span> Paste from the clipboaord </h4>
259
+ <div class="outline-text-4" id="text-1.4.4">
260
+
261
+ <pre class="example">
262
+ firetower paste --from=clip
263
+ </pre>
264
+
265
+ </div>
266
+
267
+ </div>
268
+
269
+ <div id="outline-container-1.4.5" class="outline-4">
270
+ <h4 id="sec-1.4.5"><span class="section-number-4">1.4.5</span> Paste the selected text </h4>
271
+ <div class="outline-text-4" id="text-1.4.5">
272
+
273
+ <pre class="example">
274
+ firetower paste --from=sel
275
+ </pre>
276
+
277
+ </div>
278
+
279
+ </div>
280
+
281
+ <div id="outline-container-1.4.6" class="outline-4">
282
+ <h4 id="sec-1.4.6"><span class="section-number-4">1.4.6</span> Start server (for notifications, bots, etc.) </h4>
283
+ <div class="outline-text-4" id="text-1.4.6">
284
+
285
+ <pre class="example">
286
+ firetower start
287
+ </pre>
288
+
289
+ </div>
290
+
291
+ </div>
292
+
293
+ <div id="outline-container-1.4.7" class="outline-4">
294
+ <h4 id="sec-1.4.7"><span class="section-number-4">1.4.7</span> Stop server </h4>
295
+ <div class="outline-text-4" id="text-1.4.7">
296
+
297
+ <pre class="example">
298
+ firetower stop
299
+ </pre>
300
+
301
+
302
+ </div>
303
+ </div>
304
+
305
+ </div>
306
+
307
+ <div id="outline-container-1.5" class="outline-3">
308
+ <h3 id="sec-1.5"><span class="section-number-3">1.5</span> Plugin API </h3>
309
+ <div class="outline-text-3" id="text-1.5">
310
+
311
+ <p>If you want to write your own Firetower plugins, you should create a gem
312
+ that contains a path something like this:
313
+ </p>
314
+ <pre class="example">
315
+ lib/firetower/plugins/my_awesome_plugin/init_v1.rb
316
+ </pre>
317
+
318
+
319
+ <p>
320
+ Firetower will load the init<sub>v1</sub>.rb file on startup. Typically, a plugin
321
+ will define a Firetower::Session::Listener class (or more than one) in the
322
+ Firetower::Plugins namespace:
323
+ </p>
324
+
325
+
326
+
327
+ <pre class="src src-ruby"><span style="color: #CC7832; font-weight: bold;">module</span> <span style="color: #8888ff; font-weight: bold;">Firetower</span>
328
+ <span style="color: #CC7832; font-weight: bold;">module</span> <span style="color: #8888ff; font-weight: bold;">Plugins</span>
329
+ <span style="color: #CC7832; font-weight: bold;">class</span> <span style="color: #8888ff; font-weight: bold;">MyAwesomePlugin</span> &lt; <span style="color: #8888ff; font-weight: bold;">Firetower::Session::Listener</span>
330
+ <span style="color: #CC7832; font-weight: bold;">def</span> <span style="color: #E8BF6A; font-weight: bold;">startup</span>(session)
331
+ <span style="color: #888888;"># </span><span style="color: #B150E7; font-style: italic;">Some one-time startup code...
332
+ </span> <span style="color: #CC7832; font-weight: bold;">end</span>
333
+
334
+ <span style="color: #CC7832; font-weight: bold;">def</span> <span style="color: #E8BF6A; font-weight: bold;">receive</span>(session, event)
335
+ <span style="color: #888888;"># </span><span style="color: #B150E7; font-style: italic;">Some event-handling code...
336
+ </span> <span style="color: #CC7832; font-weight: bold;">end</span>
337
+ <span style="color: #CC7832; font-weight: bold;">end</span>
338
+ <span style="color: #CC7832; font-weight: bold;">end</span>
339
+ <span style="color: #CC7832; font-weight: bold;">end</span>
340
+ </pre>
341
+
342
+
343
+
344
+
345
+ <p>
346
+ Users can then enable your plugin by installing your gem and adding a line
347
+ line to their firetower.conf:
348
+ </p>
349
+
350
+
351
+
352
+ <pre class="src src-ruby">use <span style="color: #8888ff; font-weight: bold;">MyAwesomePlugin</span>
353
+ </pre>
354
+
355
+
356
+
357
+
358
+ </div>
359
+
360
+ </div>
361
+
362
+ <div id="outline-container-1.6" class="outline-3">
363
+ <h3 id="sec-1.6"><span class="section-number-3">1.6</span> License </h3>
364
+ <div class="outline-text-3" id="text-1.6">
365
+
366
+
367
+ <p>
368
+ (The MIT License)
369
+ </p>
370
+ <p>
371
+ Copyright (c) 2010 Avdi Grimm
372
+ </p>
373
+ <p>
374
+ Permission is hereby granted, free of charge, to any person obtaining
375
+ a copy of this software and associated documentation files (the
376
+ 'Software'), to deal in the Software without restriction, including
377
+ without limitation the rights to use, copy, modify, merge, publish,
378
+ distribute, sublicense, and/or sell copies of the Software, and to
379
+ permit persons to whom the Software is furnished to do so, subject to
380
+ the following conditions:
381
+ </p>
382
+ <p>
383
+ The above copyright notice and this permission notice shall be
384
+ included in all copies or substantial portions of the Software.
385
+ </p>
386
+ <p>
387
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
388
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
389
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
390
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
391
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
392
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
393
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
394
+ </p></div>
395
+ </div>
396
+ </div>
397
+ <div id="postamble">
398
+ <p class="author"> Author: Avdi Grimm
399
+ <a href="mailto:avdi@avdi.org">&lt;avdi@avdi.org&gt;</a>
400
+ </p>
401
+ <p class="date"> Date: 2010-07-11 23:51:09 EDT</p>
402
+ <p class="creator">HTML generated by org-mode 6.33trans in emacs 23</p>
403
+ </div>
404
+ </div>
405
+ </body>
406
+ </html>
data/README.org ADDED
@@ -0,0 +1,135 @@
1
+ #+Title: Firetower README
2
+ #+AUTHOR: Avdi Grimm
3
+ #+EMAIL: avdi@avdi.org
4
+
5
+ # Configuration:
6
+ #+STARTUP: odd
7
+ #+STARTUP: hi
8
+ #+STARTUP: hidestars
9
+
10
+ * Firetower
11
+
12
+ [[file:images/BaldMountainLookout.jpg]]
13
+
14
+ A command-line interface to the Campfire API
15
+ (http://developer.37signals.com/campfire/) by [[mailto:avdi@avdi.org][Avdi Grimm]]
16
+
17
+ URL: http://github.com/avdi/firetower
18
+
19
+ *** Requirements
20
+
21
+ - Linux (somebody please port this to OS X)
22
+ - [[http://www.kfish.org/software/xsel/][xsel]]
23
+ - [[apt:libnotify-bin][libnotify-bin]]
24
+
25
+ *** Install
26
+
27
+ : sudo gem install firetower
28
+ : firetower setup
29
+
30
+ *** Usage
31
+ ***** Say something in campfire
32
+ : firetower say 'blah blah blah'
33
+ ***** Say something to a non-default room
34
+ : firetower say subdomain='mycompany' room='Water Cooler' 'blah blah blah'
35
+ ***** Paste a code snippet into campfire
36
+ : firetower paste < hello.rb
37
+ ***** Paste from the clipboaord
38
+ : firetower paste --from=clip
39
+ ***** Paste the selected text
40
+ : firetower paste --from=sel
41
+ ***** Start server (for notifications, bots, etc.)
42
+ : firetower start
43
+ ***** Stop server
44
+ : firetower stop
45
+
46
+ *** Configuration
47
+ Edit $HOME/.firetower/firetower.conf
48
+
49
+ All configuration is done in Ruby. The context is a Firetower::Sesson
50
+ object. You can add handlers for events:
51
+
52
+ : receive do |session, event| ... end
53
+
54
+ Or enable plugins:
55
+
56
+ : use NotifyPlugin
57
+
58
+ ***** A simple bot
59
+ Drop this in ~/.firetower/firetower.conf for a simple (and VERY UNSAFE!) demo
60
+ of a Campfire bot which will eval arbitrary Ruby code whenever someone
61
+ prefaces a message with "!eval":
62
+
63
+ #+BEGIN_SRC ruby
64
+ receive do |session, event|
65
+ if event['type'] == 'TextMessage' && event['body'] =~ /^!eval (.*)$/
66
+ event.room.account.paste!(event.room.name, "Eval result:\n" + eval($1).to_s)
67
+ end
68
+ end
69
+ #+END_SRC
70
+
71
+ The event hooks are [[http://hookr.rubyforge.org][HookR]] events, so any number of handlers can be stacked on
72
+ a given event. And more advanced usage are possible; for instance, you can
73
+ attach a Listener object to receive all types of events. In fact, this last is
74
+ how plugins are implemented.
75
+
76
+ *** Plugin API
77
+ If you want to write your own Firetower plugins, you should create a gem
78
+ that contains a path something like this:
79
+
80
+ : lib/firetower/plugins/my_awesome_plugin/init_v1.rb
81
+
82
+ Firetower will load the init_v1.rb file on startup. Typically, a plugin
83
+ will define a Firetower::Session::Listener class (or more than one) in the
84
+ Firetower::Plugins namespace:
85
+
86
+ #+BEGIN_SRC ruby
87
+ module Firetower
88
+ module Plugins
89
+ class MyAwesomePlugin < Firetower::Session::Listener
90
+ def startup(session)
91
+ # Some one-time startup code...
92
+ end
93
+
94
+ def receive(session, event)
95
+ # Some event-handling code...
96
+ end
97
+ end
98
+ end
99
+ end
100
+ #+END_SRC
101
+
102
+ Users can then enable your plugin by installing your gem and adding a line
103
+ line to their firetower.conf:
104
+
105
+ #+BEGIN_SRC ruby
106
+ use MyAwesomePlugin
107
+ #+END_SRC
108
+
109
+ *** Not yet implemented:
110
+ ***** TODO Join/leave rooms when subscribing/unsubscribing
111
+ ***** TODO Fire all defined hooks, including :shutdown and :leave
112
+ *** License
113
+
114
+ (The MIT License)
115
+
116
+ Copyright (c) 2010 Avdi Grimm
117
+
118
+ Permission is hereby granted, free of charge, to any person obtaining
119
+ a copy of this software and associated documentation files (the
120
+ 'Software'), to deal in the Software without restriction, including
121
+ without limitation the rights to use, copy, modify, merge, publish,
122
+ distribute, sublicense, and/or sell copies of the Software, and to
123
+ permit persons to whom the Software is furnished to do so, subject to
124
+ the following conditions:
125
+
126
+ The above copyright notice and this permission notice shall be
127
+ included in all copies or substantial portions of the Software.
128
+
129
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
130
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
131
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
132
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
133
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
134
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
135
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.