utility_belt 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -35,14 +35,6 @@ sudo gem install utility_belt
35
35
  * Grammatically-correct is_an? method - no more "is_a? Array" statements
36
36
  * One-character exit command
37
37
 
38
- == MAYBE GONNA HAPPEN
39
-
40
- * Class and method greps to take regexes and symbols
41
- * Gem require to take arrays and symbols
42
- * Copy history to clipboard or arbitrary editor
43
- * Verbosity off switch for Rails
44
- * Test-driven strategy encompassing IRB and external editors
45
-
46
38
  == COMMUNITY EFFORT
47
39
 
48
40
  The majority of this code was written by other people and compiled, nicked, nabbed, herded, gathered, copied, or pilfered by me (Giles Bowkett). See copyright notice for the credits. A lot of this code comes from blogs. Check out the source code for numerous links to the original posts the code came from.
@@ -319,7 +311,7 @@ Because life is too short to type whole words.
319
311
  Portions Copyright (c) 2006-2007 Ara T. Howard
320
312
  Portions Copyright (c) 2006-2007 Pat Maddox
321
313
  Portions Copyright (c) 2006-2007 Marcel Molina, Jr.
322
- Portions Copyright (c) 2006-2007 Rick D. Natale
314
+ Portions Copyright (c) 2006-2007 Rick DeNatale
323
315
  Portions Copyright (c) 2006-2007 Projectionist (Marcel Molina? Chad Fowler?)
324
316
  Portions Copyright (c) 2006-2007 Dan Yoder
325
317
 
data/bin/amazon CHANGED
@@ -1,21 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
- %w{rubygems platform aws/s3 optparse}.each {|library| require library}
2
+ %w{rubygems platform optparse}.each {|library| require library}
3
3
 
4
+ # command-line args
4
5
  option_parser = OptionParser.new
5
6
  option_parser.on("-b", "--bucket NAME", String) {|bucket| @bucket = bucket}
6
7
  filenames = option_parser.parse(ARGV)
8
+ abort "Usage: amazon -b bucket_name file_name" unless @bucket && filenames
7
9
 
8
- if @bucket && filenames
9
- UTILITY_BELT_IRB_STARTUP_PROCS = {}
10
+ # require files, populate hash
11
+ UTILITY_BELT_IRB_STARTUP_PROCS = {}
12
+ utility_belt_lib = File.dirname(__FILE__) + '/../lib'
13
+ require "#{utility_belt_lib}/mac_clipboard"
14
+ require "#{utility_belt_lib}/amazon_upload_shortcut"
15
+ UTILITY_BELT_IRB_STARTUP_PROCS[:define_s3_convenience_methods].call
10
16
 
11
- utility_belt_lib = File.dirname(__FILE__) + '/../lib'
12
- require "#{utility_belt_lib}/mac_clipboard"
13
- require "#{utility_belt_lib}/amazon_upload_shortcut"
14
-
15
- UTILITY_BELT_IRB_STARTUP_PROCS[:define_s3_convenience_methods].call
16
-
17
- filenames.each {|filename| puts aws_upload(@bucket, filename)}
18
- else
19
- puts "Usage: amazon -b bucket_name file_name"
20
- exit
21
- end
17
+ # baddabing, baddaboom
18
+ filenames.each {|filename| puts aws_upload(@bucket, filename)}
data/bin/google CHANGED
@@ -1,15 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
- %w{rubygems platform}.each {|library| require library}
3
- require "#{File.dirname(__FILE__) + '/../lib'}/mac_clipboard"
2
+ %w{rubygems platform cgi}.each {|library| require library}
4
3
 
5
- if :macosx == Platform::IMPL
4
+ if :macosx != Platform::IMPL
5
+ abort "Utility Belt's command-line Google shortcut only works on OS X. Sorry."
6
+ else
7
+ require "#{File.dirname(__FILE__) + '/../lib'}/mac_clipboard"
6
8
  search_term = ARGV[0] || MacClipboard.read
7
9
  if search_term.empty?
8
10
  puts "Usage: google search_term_without_spaces"
9
11
  puts " google 'search term with spaces'"
10
12
  puts " google"
11
- puts " (if invoking without command-line args, must have text in clipboard buffer)"
13
+ puts " (if invoking without command-line args, must have text in clipboard)"
14
+ puts " (if you're seeing this there's a good chance you copied an image or something)"
12
15
  exit
13
16
  end
14
- system("open http://google.com/search?q=#{search_term.gsub(/ |\n/, '%20')}")
17
+ system("open http://google.com/search?q=#{CGI.escape(search_term)}")
15
18
  end
@@ -0,0 +1,449 @@
1
+ /* andreas00 - an open source xhtml/css website layout by Andreas Viklund - http://andreasviklund.com . Free to use for any purpose as long as the proper credits are given to the original author.
2
+ Version: 1.1 (Apr 20, 2006) */
3
+
4
+ /***** Body and main container *****/
5
+
6
+ body {
7
+ margin:0 auto;
8
+ padding:0;
9
+ font:76% Verdana,Tahoma,Arial,sans-serif;
10
+ background:#eaeaea url(bg.gif) top center repeat-y;
11
+ color:#3a3a3a;
12
+ }
13
+
14
+ #wrap {
15
+ background-color:#ffffff;
16
+ color:#303030;
17
+ margin:0 auto;
18
+ padding:1px 5px;
19
+ width:760px;
20
+ }
21
+
22
+ /***** Header *****/
23
+
24
+ #header {
25
+ color:#505050;
26
+ background:#ffffff url(http://s3.amazonaws.com/giles/the_tao_of_bondage_vigilantes.jpg) bottom left no-repeat;
27
+ height:250px;
28
+ margin:0 0 10px 0;
29
+ padding:0;
30
+ }
31
+
32
+ #header h1 {
33
+ font-size:2.5em;
34
+ font-weight:normal;
35
+ letter-spacing:-2px;
36
+ margin:0 0 4px 15px;
37
+ padding:15px 0 0 0;
38
+ }
39
+
40
+ #header h1 a,#header h1 a:hover {
41
+ padding:0;
42
+ }
43
+
44
+ #header p {
45
+ font-size:1.1em;
46
+ letter-spacing:-1px;
47
+ margin:0 0 20px 15px;
48
+ padding:0 0 0 3px;
49
+ }
50
+
51
+ /***** Left sidebar *****/
52
+
53
+ #avmenu {
54
+ clear:left;
55
+ float:left;
56
+ width:150px;
57
+ margin:0 0 10px 0;
58
+ padding:0;
59
+ }
60
+
61
+ #avmenu ul {
62
+ list-style:none;
63
+ width:150px;
64
+ margin:0 0 20px 0;
65
+ padding:0;
66
+ }
67
+
68
+ #avmenu li {
69
+ margin-bottom:5px;
70
+ }
71
+
72
+ #avmenu li a {
73
+ font-weight:bold;
74
+ height:20px;
75
+ text-decoration:none;
76
+ color:#505050;
77
+ display:block;
78
+ padding:6px 0 0 10px;
79
+ background:#f4f4f4 url(menubg.gif) bottom left repeat-x;
80
+ border-top:1px solid #d8d8d8;
81
+ border-right:1px solid #d8d8d8;
82
+ border-bottom:1px solid #d8d8d8;
83
+ border-left:4px solid #cccccc;
84
+ }
85
+
86
+ #avmenu li a:hover, #avmenu li a.current {
87
+ background:#eaeaea url(menubg2.gif) bottom left repeat-x;
88
+ color:#505050;
89
+ border-top:1px solid #b0b0b0;
90
+ border-right:1px solid #b0b0b0;
91
+ border-bottom:1px solid #b0b0b0;
92
+ border-left:4px solid #505050;
93
+ }
94
+
95
+ #avmenu ul ul {
96
+ margin:5px 0 5px 15px;
97
+ font-size:0.9em;
98
+ width:135px;
99
+ }
100
+
101
+ #avmenu ul ul a {
102
+ height:16px;
103
+ margin:0;
104
+ padding:4px 0 0 8px;
105
+ }
106
+
107
+ #avmenu h2 {
108
+ font-size:1.5em;
109
+ font-weight:normal;
110
+ line-height:1.8em;
111
+ }
112
+
113
+ /***** Right sidebar *****/
114
+
115
+ #extras {
116
+ float:right;
117
+ width:130px;
118
+ margin:0 0 10px 0;
119
+ padding:0;
120
+ font-size:0.9em;
121
+ }
122
+
123
+ #extras p, #extras ul {
124
+ margin:0 0 1.5em 0;
125
+ line-height:1.3em;
126
+ padding:0;
127
+ }
128
+
129
+ #extras a {
130
+ font-weight:bold;
131
+ }
132
+
133
+ #extras li {
134
+ list-style:none;
135
+ margin:0 0 6px 0;
136
+ padding:0;
137
+ }
138
+
139
+ #extras h2 {
140
+ font-size:1.6em;
141
+ font-weight:normal;
142
+ margin:0 0 6px 0;
143
+ ;
144
+ letter-spacing:-1px;
145
+ }
146
+
147
+ /***** Main content *****/
148
+
149
+ #content {
150
+ margin:10px 140px 10px 160px;
151
+ padding:0;
152
+ line-height:1.5em;
153
+ text-align:left;
154
+ }
155
+
156
+ #contentwide {
157
+ margin:10px 0 10px 160px;
158
+ padding:0;
159
+ line-height:1.5em;
160
+ text-align:left;
161
+ }
162
+
163
+ #contentfull {
164
+ margin:10px 10px 10px 10px;
165
+ padding:2px 0 0 0;
166
+ line-height:1.5em;
167
+ text-align:left;
168
+ }
169
+
170
+ #content h2, #contentwide h2, #contentfull h2 {
171
+ font-size:1.8em;
172
+ font-weight:normal;
173
+ margin:8px 0 10px 0px;
174
+ padding:0;
175
+ padding-left: 10px;
176
+ line-height:1.8em;
177
+ background-color: #440055;
178
+ color: white;
179
+ }
180
+
181
+ #content h3, #contentwide h3, #contentfull h3 {
182
+ line-height:1.8em;
183
+ background-color: black;
184
+ color: white;
185
+ font-size:1.5em;
186
+ font-weight:normal;
187
+ margin:6px 0 6px 0;
188
+ padding:0;
189
+ padding-left: 10px;
190
+ }
191
+
192
+ #content img, #contentwide img, #contentfull img {
193
+ padding:1px;
194
+ display:inline;
195
+ background:#cccccc;
196
+ color:#303030;
197
+ border:4px solid #f0f0f0;
198
+ }
199
+
200
+ #content a, #contentwide a, #contentfull a {
201
+ }
202
+
203
+ #content ul, #content ol,
204
+ #contentwide ul, #contentwide ol,
205
+ #contentfull ul, #contentfull ol {
206
+ margin:0 0 16px 20px;
207
+ padding:0;
208
+ }
209
+
210
+ #content ul ul, #content ol ol,
211
+ #contentwide ul ul, #contentwide ol ol,
212
+ #contentfull ul ul, #contentfull ol ol {
213
+ margin:2px 0 2px 20px;
214
+ }
215
+
216
+ #content li, #contentwide li, #contentfull li {
217
+ margin:0 0 2px 10px;
218
+ padding:0 0 0 4px;
219
+ }
220
+
221
+ /***** Footer *****/
222
+
223
+ #footer {
224
+ clear:both;
225
+ margin:0 auto;
226
+ padding:8px 0;
227
+ border-top:2px solid #dadada;
228
+ width:760px;
229
+ text-align:center;
230
+ color:#808080;
231
+ background-color:#ffffff;
232
+ font-size:0.9em;
233
+ }
234
+
235
+ #footer p {
236
+ padding:0;
237
+ margin:0;
238
+ }
239
+
240
+ #footer a {
241
+ color:#808080;
242
+ background-color:inherit;
243
+ text-decoration:none;
244
+ }
245
+
246
+ #footer a:hover {
247
+ text-decoration:underline;
248
+ }
249
+
250
+ /***** Various tags *****/
251
+
252
+ a {
253
+ text-decoration:none;
254
+ color:#505050;
255
+ background-color:inherit;
256
+ }
257
+
258
+ a:hover {
259
+ text-decoration:underline;
260
+ color:#286ea0;
261
+ background-color:inherit;
262
+ }
263
+
264
+ a img {
265
+ border:0;
266
+ }
267
+
268
+ p {
269
+ margin:0 0 16px 0;
270
+ }
271
+
272
+ blockquote {
273
+ border-top:1px solid #d8d8d8;
274
+ border-right:1px solid #d8d8d8;
275
+ border-bottom:1px solid #d8d8d8;
276
+ border-left:4px solid #cccccc;
277
+ margin:16px;
278
+ padding:7px 7px 7px 11px;
279
+ background:#f4f4f4 url(menubg.gif) bottom left repeat-x;
280
+ color:#505050;
281
+ }
282
+
283
+ blockquote p {
284
+ font-size:1.1em;
285
+ line-height:1.3em;
286
+ margin:0;
287
+ }
288
+
289
+ /***** Table styles *****/
290
+
291
+ table {
292
+ margin:0 0 16px 0;
293
+ padding:0;
294
+ line-height:1.3em;
295
+ border-collapse:collapse;
296
+ border:1px solid #d8d8d8;
297
+ }
298
+
299
+ caption {
300
+ text-align:left;
301
+ font-size:1.5em;
302
+ font-weight:normal;
303
+ margin:0;
304
+ padding:6px 0 8px 0;
305
+ }
306
+
307
+ th {
308
+ padding:7px;
309
+ text-align:left;
310
+ background:#eaeaea url(menubg2.gif) bottom left repeat-x;
311
+ color:#505050;
312
+ }
313
+
314
+ td {
315
+ padding:7px;
316
+ font-size:0.9em;
317
+ text-align:left;
318
+ background:#f4f4f4 url(menubg.gif) bottom left repeat-x;
319
+ color:#303030;
320
+ }
321
+
322
+ /***** Form styles *****/
323
+
324
+ .button {
325
+ border-top:1px solid #d8d8d8;
326
+ border-right:1px solid #d8d8d8;
327
+ border-bottom:1px solid #d8d8d8;
328
+ border-left:4px solid #cccccc;
329
+ margin:0 0 15px 0;
330
+ padding:7px 7px 7px 11px;
331
+ background:#f4f4f4 url(menubg.gif) bottom left repeat-x;
332
+ color:#505050;
333
+ font-weight:bold;
334
+ width:120px;
335
+ }
336
+
337
+ input, textarea {
338
+ border:1px solid #cccccc;
339
+ font-family:Verdana,Tahoma,Arial,Sans-Serif;
340
+ font-size:1em;
341
+ margin:0;
342
+ padding:4px;
343
+ }
344
+
345
+ label {
346
+ margin:2px;
347
+ }
348
+
349
+ input {
350
+ width:200px;
351
+ }
352
+
353
+ textarea {
354
+ width:400px;
355
+ }
356
+
357
+ /***** Search box *****/
358
+
359
+ #searchbox {
360
+ padding:0;
361
+ margin:6px 0 16px 0;
362
+ }
363
+
364
+ #searchform {
365
+ background:#ffffff;
366
+ border:1px solid #cccccc;
367
+ color:#505050;
368
+ font-size:0.9em;
369
+ padding:4px;
370
+ width:116px;
371
+ }
372
+
373
+ #searchbox label {
374
+ display:none;
375
+ }
376
+
377
+ /***** Various classes *****/
378
+
379
+ .left {
380
+ margin:10px 10px 5px 0;
381
+ float:left;
382
+ }
383
+
384
+ .right {
385
+ margin:10px 0 5px 10px;
386
+ float:right;
387
+ }
388
+
389
+ .announce {
390
+ margin:10px 0 10px 0;
391
+ padding:10px 10px 5px 10px;
392
+ width:105px;
393
+ color:#505050;
394
+ background:#f4f4f4 url(menubg.gif) bottom left repeat-x;
395
+ border-top:1px solid #d8d8d8;
396
+ border-right:1px solid #d8d8d8;
397
+ border-bottom:1px solid #d8d8d8;
398
+ border-left:4px solid #cccccc;
399
+ line-height:1.3em;
400
+ }
401
+
402
+ .announce a {
403
+ font-weight:bold;
404
+ }
405
+
406
+ .announce p {
407
+ font-size:0.9em;
408
+ }
409
+
410
+ .announce h2 {
411
+ margin:0 0 10px 0;
412
+ padding:0;
413
+ }
414
+
415
+ #avmenu .announce {
416
+ width:125px;
417
+ }
418
+
419
+ .textright {
420
+ text-align:right;
421
+ margin:-10px 0 4px 0;
422
+ }
423
+
424
+ .center {
425
+ text-align:center;
426
+ }
427
+
428
+ .small {
429
+ font-size:0.8em;
430
+ }
431
+
432
+ .large {
433
+ font-size:1.3em;
434
+ }
435
+
436
+ .bold {
437
+ font-weight:bold;
438
+ }
439
+
440
+ .highlighted {
441
+ padding:3px;
442
+ background-color:#f0f0f0;
443
+ color:#303030;
444
+ border:1px solid #b0b0b0;
445
+ }
446
+
447
+ .hide {
448
+ display:none;
449
+ }
@@ -0,0 +1,85 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6
+ <meta name="description" content="Baddest Ruby gem evar." />
7
+ <meta name="keywords" content="ruby, giles bowkett, batman, utility belt, gem, attack of the killer tomatoes" />
8
+ <meta name="author" content="Giles Bowkett / Original design: Andreas Viklund - http://andreasviklund.com/" />
9
+ <link rel="stylesheet" type="text/css" href="andreas00.css" media="screen,projection" />
10
+ <title>Utility Belt: Usage</title>
11
+ </head>
12
+
13
+ <body>
14
+ <div id="wrap">
15
+ <div id="header">
16
+ <h1><a href="http://utilitybelt.rubyforge.org">Utility Belt</a></h1>
17
+ <p><strong>IRB tools, tricks, and techniques</strong></p>
18
+ </div>
19
+
20
+ <div id="avmenu">
21
+ <h2 class="hide">Site menu:</h2>
22
+ <ul>
23
+ <li><a href="index.html">Overview</a></li>
24
+ <li><a href="usage.html">Usage</a></li>
25
+ <li><a href="authorship.html">Authorship</a></li>
26
+ </ul>
27
+ </div>
28
+
29
+ <div id="contentwide">
30
+ <h2>Copyright And Authorship</h2>
31
+ <h3>COMMUNITY EFFORT</h3>
32
+
33
+ <p>The majority of this code was written by other people and compiled, nicked, nabbed, herded, gathered, copied, or pilfered by me (Giles Bowkett). Check the links in the copyright notice for more detail.</p>
34
+
35
+ <h3>LICENSE</h3>
36
+
37
+ <pre>
38
+ (The MIT License)
39
+
40
+ Copyright (c) 2006-2007 <a href="http://gilesbowkett.blogspot.com/" title="Giles Bowkett">Giles Bowkett</a>
41
+ Portions Copyright (c) 2006-2007 <a href="http://blog.bleything.net/2007/7/30/announcing-shell-style-history-for-irb-the-fixed-edition" title="bleything.blog(:stuff) Announcing Shell-Style History for irb, the fixed edition!">Ben Bleything</a>
42
+ Portions Copyright (c) 2006-2007 <a href="http://weblog.raganwald.com/2007/10/stringtoproc.html" title="String#to_proc">Reginald Braithwaite-Lee</a>
43
+ Portions Copyright (c) 2006-2007 <a href="http://gilesbowkett.blogspot.com/2007/10/use-vi-or-any-text-editor-from-within.html" title="Giles Bowkett: Use vi (Or Any Text Editor) From Within irb">Gregory Brown</a>
44
+ Portions Copyright (c) 2006-2007 <a href="http://weblog.jamisbuck.org/2007/1/8/watching-activerecord-do-it-s-thing" title="the { buckblogs :here : Watching ActiveRecord Do Its Thing}">Jamis Buck</a>
45
+ Portions Copyright (c) 2006-2007 <a href="http://clarkware.com/cgi/blosxom/2007/09/03" title="Mike Clark's Weblog">Mike Clark</a>
46
+ Portions Copyright (c) 2006-2007 <a href="http://blog.jayfields.com/2007/08/ruby-adding-not-method-for-readability.html" title="Jay Fields Thoughts: Ruby: Adding a "not" method for readability">Jay Fields</a>
47
+ Portions Copyright (c) 2005 <a href="http://api.rubyonrails.org/classes/Symbol.html" title="Class: Symbol">David Heinemeier Hansson</a>
48
+ Portions Copyright (c) 2006-2007 <a href="http://groups.google.com/group/ruby-talk-google/browse_thread/thread/9c1febbe05513dc0" title="shutting irb up - ruby-talk-google | Google Groups">Ara T. Howard</a>
49
+ Portions Copyright (c) 2006-2007 <a href="http://gilesbowkett.blogspot.com/2006/12/smalltalk-cleverness-in-rails-revisited.html" title="Giles Bowkett: Smalltalk Cleverness in Rails, Revisited">Pat Maddox</a>
50
+ Portions Copyright (c) 2006-2007 <a href="http://amazon.rubyforge.org/" title="AWS::S3 - Ruby Library for Amazon Simple Storage Service (S3)">Marcel Molina, Jr.</a>
51
+ Portions Copyright (c) 2006-2007 <a href="http://groups.google.com/group/ruby-talk-google/browse_thread/thread/9c1febbe05513dc0" title="shutting irb up - ruby-talk-google | Google Groups">Rick DeNatale</a>
52
+ Portions Copyright (c) 2006-2007 <a href="http://project.ioni.st/post/1334" title="Projectionist: A tumblelog">Projectionist</a> (Marcel Molina? Chad Fowler?)
53
+ Portions Copyright (c) 2006-2007 <a href="http://aspn.activestate.com/ASPN/Mail/Message/ruby-talk/3573982" title="Re: "with" statement :: ASPN Mail Archive :: ruby-talk">Dan Yoder</a>
54
+
55
+ Permission is hereby granted, free of charge, to any person obtaining
56
+ a copy of this software and associated documentation files (the
57
+ 'Software'), to deal in the Software without restriction, including
58
+ without limitation the rights to use, copy, modify, merge, publish,
59
+ distribute, sublicense, and/or sell copies of the Software, and to
60
+ permit persons to whom the Software is furnished to do so, subject to
61
+ the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be
64
+ included in all copies or substantial portions of the Software.
65
+
66
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
67
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
68
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
69
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
70
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
71
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
72
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</pre>
73
+
74
+ <h3>THE BATMAN GRAPHIC</h3>
75
+
76
+ <p>Is that cool or what? I have no idea where I found it. (If you're the creator, a thousand apologies. I just hella dig it.)</p>
77
+
78
+ </div>
79
+
80
+ <div id="footer">
81
+ <p>Copyright &copy; 2007 Giles Bowkett | Design by <a href="http://andreasviklund.com">Andreas Viklund</a>.</p>
82
+ </div>
83
+ </div>
84
+ </body>
85
+ </html>
data/html/bg.gif ADDED
Binary file
data/html/front.jpg ADDED
Binary file
data/html/index.html ADDED
@@ -0,0 +1,79 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6
+ <meta name="description" content="Baddest Ruby gem evar." />
7
+ <meta name="keywords" content="ruby, giles bowkett, batman, utility belt, gem, attack of the killer tomatoes" />
8
+ <meta name="author" content="Giles Bowkett / Original design: Andreas Viklund - http://andreasviklund.com/" />
9
+ <link rel="stylesheet" type="text/css" href="andreas00.css" media="screen,projection" />
10
+ <title>Utility Belt: Usage</title>
11
+ </head>
12
+
13
+ <body>
14
+ <div id="wrap">
15
+ <div id="header">
16
+ <h1><a href="http://utilitybelt.rubyforge.org">Utility Belt</a></h1>
17
+ <p><strong>IRB tools, tricks, and techniques</strong></p>
18
+ </div>
19
+
20
+ <div id="avmenu">
21
+ <h2 class="hide">Site menu:</h2>
22
+ <ul>
23
+ <li><a href="index.html">Overview</a></li>
24
+ <li><a href="usage.html">Usage</a></li>
25
+ <li><a href="authorship.html">Authorship</a></li>
26
+ </ul>
27
+
28
+ </div>
29
+
30
+ <div id="contentwide">
31
+ <h2>Installation And Overview</h2>
32
+
33
+ <p>Utility Belt is a grab-bag of tricks, tools, techniques, trifles, and toys for IRB, including convenience methods, language patches, and useful extensions. It also includes a couple command-line widgets. Its primary inspirations were <a href="http://pablotron.org/software/wirble/" title="Pablotron: Wirble">an awesome gem called Wirble</a> and <a href="http://slash7.com/articles/2006/12/21/secrets-of-the-rails-console-ninjas" title="Slash7 with Amy Hoy - Secrets of the Rails Console Ninjas">a blog post by Amy Hoy called "Secrets Of The Rails Console Ninjas"</a>.</p>
34
+
35
+ <h3>INSTALL</h3>
36
+
37
+ <p>sudo gem install utility_belt</p>
38
+
39
+ <h3>FEATURES</h3>
40
+
41
+ <ul>
42
+ <li>Interactively edit IRB code in your preferred text editor</li>
43
+ <li>Read from and write to OS X clipboard</li>
44
+ <li>Post your code to Pastie with one command (OS X only)</li>
45
+ <li>Kick-ass Unix-style history buffer</li>
46
+ <li>Write command history to file or vi</li>
47
+ <li>Grep classes and methods for strings</li>
48
+ <li>Verbosity controls for regular IRB and Rails console</li>
49
+ <li>Finder shortcuts for Rails console</li>
50
+ <li>Upload shortcut for Amazon S3</li>
51
+ <li>Command-line Amazon S3 upload script</li>
52
+ <li>Command-line Google shortcut (OS X only)</li>
53
+ <li>Auto-indentation</li>
54
+ <li>_ special variable (like Unix shell var !!)</li>
55
+ <li>Extremely basic themes for Wirble syntax coloring</li>
56
+ <li>Pascal/JavaScript-style "with" statement</li>
57
+ <li>String#to_proc</li>
58
+ <li>Grammatically-correct is_an? method - no more "is_a? Array" statements</li>
59
+ <li>One-character exit command</li>
60
+ </ul>
61
+
62
+ <h3>REQUIREMENTS</h3>
63
+
64
+ <ul>
65
+ <li>ReadLine</li>
66
+ <li>Wirble</li>
67
+ <li>Amazon S3</li>
68
+ <li>Platform</li>
69
+ <li>Some features require OS X</li>
70
+ </ul>
71
+
72
+ </div>
73
+
74
+ <div id="footer">
75
+ <p>Copyright &copy; 2007 Giles Bowkett | Design by <a href="http://andreasviklund.com">Andreas Viklund</a>.</p>
76
+ </div>
77
+ </div>
78
+ </body>
79
+ </html>
data/html/menubg.gif ADDED
Binary file
data/html/menubg2.gif ADDED
Binary file
data/html/test.jpg ADDED
Binary file
data/html/usage.html ADDED
@@ -0,0 +1,286 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6
+ <meta name="description" content="Baddest Ruby gem evar." />
7
+ <meta name="keywords" content="ruby, giles bowkett, batman, utility belt, gem, attack of the killer tomatoes" />
8
+ <meta name="author" content="Giles Bowkett / Original design: Andreas Viklund - http://andreasviklund.com/" />
9
+ <link rel="stylesheet" type="text/css" href="andreas00.css" media="screen,projection" />
10
+ <title>Utility Belt: Usage</title>
11
+ </head>
12
+
13
+ <body>
14
+ <div id="wrap">
15
+ <div id="header">
16
+ <h1><a href="http://utilitybelt.rubyforge.org">Utility Belt</a></h1>
17
+ <p><strong>IRB tools, tricks, and techniques</strong></p>
18
+ </div>
19
+
20
+ <div id="avmenu">
21
+ <h2 class="hide">Site menu:</h2>
22
+ <ul>
23
+ <li><a href="index.html">Overview</a></li>
24
+ <li><a href="usage.html">Usage</a></li>
25
+ <li><a href="authorship.html">Authorship</a></li>
26
+ </ul>
27
+
28
+ </div>
29
+
30
+ <div id="contentwide">
31
+ <h2>Synopsis And Usage</h2>
32
+
33
+
34
+ <h3>SYNOPSIS</h3>
35
+
36
+ <p>Utility Belt gives you a ton of new options and techniques in IRB. (You may find yourself putting its language patches in actual projects as well.) The way to use Utility Belt is to edit, or create, your .irbrc file. This is analogous to a Unix .bashrc, .tcshrc, .profile, or similar file.</p>
37
+
38
+ <p>(Windows users are probably out of luck here - sorry. There may be a solution, but I don't know what it is.)</p>
39
+
40
+ <p>Adding Utility Belt to your .irbrc is easy:</p>
41
+
42
+ <pre>require 'rubygems'
43
+ require 'utility_belt'</pre>
44
+
45
+ <p>To use the Amazon shortcuts, you also need to set some environment variables. See the section on S3 under "Usage" for more. Also, if your terminal has a light background, you'll need to enable the light-background syntax coloring theme - see the section on themes under "Usage" for more.</p>
46
+
47
+ <h3>USAGE</h3>
48
+
49
+ <p>Using each of Utility Belt's tools is different:</p>
50
+
51
+ <h4>Interactively edit IRB code in your preferred text editor</h4>
52
+
53
+ <p>If your preferred text editor is vi(m), emacs, or TextMate, there are built-in commands: vi, emacs, and mate, respectively. To use another editor, use this command:</p>
54
+
55
+ <pre>edit(:the_name_of_my_editor)</pre>
56
+
57
+ <p>or</p>
58
+
59
+ <pre>edit("the name of my editor")</pre>
60
+
61
+ <p>or</p>
62
+
63
+ <pre>edit("/the/path/to/my/editor")</pre>
64
+
65
+ <h4>Read from and write to OS X clipboard</h4>
66
+
67
+ <p>To read:</p>
68
+
69
+ <pre>MacClipboard.read</pre>
70
+
71
+ <p>To write:</p>
72
+
73
+ <pre>MacClipboard.write("something")</pre>
74
+
75
+ <h4>Post your code to Pastie with one command (OS X only)</h4>
76
+
77
+ <p>First copy some code into your clipboard, or put it there with the MacClipboard.write() class method. Then use the command:</p>
78
+
79
+ <pre>pastie</pre>
80
+
81
+ <p>or the shortcut version:</p>
82
+
83
+ <pre>pst</pre>
84
+
85
+ <p>Note that this method currently auto-formats all code as Ruby. Support for other languages is possible but not implemented yet. Also, this code is OS X only because it uses the MacClipboard. (A platform-agnostic version without the clipboard aspect is certainly possible.)</p>
86
+
87
+ <h4>Unix-style history buffer</h4>
88
+
89
+ <p>Use "h" or "history" to view your command history, and "h! 123" to re-invoke command #123 in your buffer. "h!" with no args will run the last command.</p>
90
+
91
+ <h4>Write command history to file or vi</h4>
92
+
93
+ <p>To write your history to a file, use "history_write('/path/to/file')". To edit your history in vi, use "history_to_vi" or its shortcut alias "hvi".</p>
94
+
95
+ <h4>Grep classes and methods for strings</h4>
96
+
97
+ <p>Classes:</p>
98
+
99
+ <pre>&gt;&gt; grep_classes(&quot;ixnum&quot;)
100
+ #=&gt; [&quot;Fixnum&quot;]
101
+
102
+ &gt;&gt; grep_classes(&quot;num&quot;)
103
+ #=&gt; [&quot;Bignum&quot;, &quot;Fixnum&quot;, &quot;Numeric&quot;, &quot;REXML::SyncEnumerator&quot;]</pre>
104
+
105
+ <p>Methods:</p>
106
+
107
+ <pre>&gt;&gt; &quot;any arbitrary string&quot;.grep_methods(&quot;pretty&quot;)
108
+ #=&gt; [&quot;pretty_inspect&quot;, &quot;pretty_print_instance_variables&quot;,
109
+ &quot;pretty_print_inspect&quot;, &quot;pretty_print&quot;, &quot;pretty_print_cycle&quot;]
110
+
111
+ &gt;&gt; 32.grep_methods(&quot;*&quot;)
112
+ #=&gt; [&quot;*&quot;, &quot;**&quot;]</pre>
113
+
114
+ <p>At some point it'll probably be a good idea to add regex support for these methods. (Of course if I do that, I'll probably have to change the name from grep to ack.)</p>
115
+
116
+ <h4>Verbosity controls for regular IRB and Rails console</h4>
117
+
118
+ <p>regular IRB: "verbose" or "v" / "quiet" or "q"</p>
119
+
120
+ <p>Rails: "log" method turns verbosity on, there isn't actually any method for turning it off. (Might add one at some point.)</p>
121
+
122
+ <h4>Finder shortcuts for Rails console</h4>
123
+
124
+ <pre>user(:all) / user(1)</pre>
125
+
126
+ <p>instead of</p>
127
+
128
+ <pre>User.find(:all) / User.find(1)</pre>
129
+
130
+ <p>Supports arbitrarily complex finds.</p>
131
+
132
+ <h4>Upload shortcut for Amazon S3</h4>
133
+
134
+ <p>First, define your secret keys in your environment variables:</p>
135
+
136
+ <pre>export AMAZON_ACCESS_KEY_ID='foofoofoofoofoo'
137
+ export AMAZON_SECRET_ACCESS_KEY='barbarbarbarbar'</pre>
138
+
139
+ <p>(Obviously, replace those with actual values.)</p>
140
+
141
+ <p>Then, you can use</p>
142
+
143
+ <pre>aws_upload("bucket_name","filename")</pre>
144
+
145
+ <p>To easily upload public-access files. This method will automatically connect to Amazon S3 for you, if your keys are defined in your environment variables. It also writes the resulting Amazon URL to your clipboard, if you're on OS X, so you can easily share the file with others. Note that you have to create the initial buckets manually - see <a href="http://amazon.rubyforge.org" title="AWS::S3 - Ruby Library for Amazon Simple Storage Service (S3)">amazon.rubyforge.org</a> for details on that.</p>
146
+
147
+ <p>A good way to use this is actually to have a default bucket, and create a further method in your .irbrc file:</p>
148
+
149
+ <pre>def my_bucket_name(filename)
150
+ aws_upload("my_default_bucket",filename)
151
+ end</pre>
152
+
153
+ <h4>Command-line Amazon S3 upload script</h4>
154
+
155
+ <p>Utility Belt also includes <code>amazon</code>, a simple command-line uploader for S3. It requires that you set your Amazon environment variables (see above). The usage is:</p>
156
+
157
+ <pre>amazon -b my_bucket_name filename other_filename</pre>
158
+
159
+ <p>(For any arbitrary number of filenames.)</p>
160
+
161
+ <p>Anytime you want to upload a file to your default bucket on S3, for example, the "images" bucket for your blog - or the "mp3" bucket if you're running a blog like Projectionist - all you have to do is</p>
162
+
163
+ <pre>amazon -b blog_files some_file.name</pre>
164
+
165
+ <p>Or</p>
166
+
167
+ <pre>amazon --bucket blog_files some_file.name</pre>
168
+
169
+ <p>And you're good to go. Of course, if that were too many characters to type, you could always take it one step further with a shell script. For instance, in bash:</p>
170
+
171
+ <pre>alias b1="amazon --bucket my_main_bucket $1"
172
+ alias b2="amazon --bucket my_other_bucket $1"</pre>
173
+
174
+ <p>And then you would only have to type:</p>
175
+
176
+ <pre>b1 file.name</pre>
177
+
178
+ <p>And of course tab completion will handle all the typing of the file name, assuming you choose your file names deliberately ahead of time to make tab completion effective, in which case all you have to type is "b1 f[tab]" and bam.</p>
179
+
180
+ <h4>Command-line Google shortcut (OS X only)</h4>
181
+
182
+ <p>To pop open a new window in your default browser with Google search results for a given search term, do:</p>
183
+
184
+ <pre>google "any given term"</pre>
185
+
186
+ <p>For one-word terms, you can omit the quotes:</p>
187
+
188
+ <pre>google term</pre>
189
+
190
+ <p>If you already have the search term in your clipboard, you can just type:</p>
191
+
192
+ <pre>google</pre>
193
+
194
+ <p>(The last approach is useful for unusual command-line error messages.)</p>
195
+
196
+ <h4>Auto-indentation</h4>
197
+
198
+ <p>Just type as normally. This just enables built-in but underused functionality in IRB. (The IRB default auto-indentation isn't perfect, but it clobbers the living hell out of no indentation at all.)</p>
199
+
200
+ <h4>_ special variable (like Unix shell var !!)</h4>
201
+
202
+ <p>More activation of built-in but underused functionality in IRB. _ functions like !! in Unix, with one subtle difference. Instead of re-issuing the previous command in your history, it gives you the last result of evaluating a command. This means when you start a new IRB session, _ won't go to your history, it'll just give you nil, and it means that some commands can't be repeated exactly. Nine out of ten times, however, it's pretty much the same thing.</p>
203
+
204
+ <p>Note that when combined with the h! in the command history code, you basically have two synonyms for !! here. Neither one is an exact replica, but between the two of them, you should have what you need.</p>
205
+
206
+ <h4>Extremely basic themes for Wirble syntax coloring</h4>
207
+
208
+ <p>Utility Belt incorporates <a href="http://pablotron.org/software/wirble/" title="Pablotron: Wirble">Wirble</a> as a dependency. Wirble provides syntax coloring. Utility Belt allows you to choose between two syntax coloring themes: Wirble's default, and an alternate color set for terminals with light backgrounds. The default theme is enabled by default (duh), but if you have a terminal with a light background, you can enable the light-background theme just by putting the following line of code in your .irbrc:</p>
209
+
210
+ <pre>UtilityBelt::Themes.background(:light)</pre>
211
+
212
+ <p>To revert back to the default, just use this:</p>
213
+
214
+ <pre>UtilityBelt::Themes.background(:dark)</pre>
215
+
216
+ <p>To specify an entirely new syntax color scheme, see the source code for this gem or for Wirble.</p>
217
+
218
+ <h4>Pascal/JavaScript-style "with" statement</h4>
219
+
220
+ <p>I use this with RSpec's spec_helper. Instead of:</p>
221
+
222
+ <pre>Spec::Runner.configure do |config|
223
+ config.use_transactional_fixtures = true
224
+ config.use_instantiated_fixtures = false
225
+ config.fixture_path = RAILS_ROOT + '/spec/fixtures'
226
+ config.mock_with :flexmock
227
+ end</pre>
228
+
229
+ <p>I do this:</p>
230
+
231
+ <pre>Spec::Runner.configure do |config|
232
+ with(config) do
233
+ use_transactional_fixtures = true
234
+ use_instantiated_fixtures = false
235
+ fixture_path = RAILS_ROOT + '/spec/fixtures'
236
+ mock_with :flexmock
237
+ end
238
+ end</pre>
239
+
240
+ <p>Note however that this blew up once and I have no idea why. Caveat emptor, et cetera.</p>
241
+
242
+ <h4>String#to_proc</h4>
243
+
244
+ <p>Syntactic sugar for functional programming. (<a href="http://weblog.raganwald.com/2007/10/stringtoproc.html" title="String#to_proc">More detail here</a>.) Rails' Symbol#to_proc is also included.</p>
245
+
246
+ <pre>(1..3).map(&amp;&apos;*2&apos;) =&gt; [2, 4, 6]
247
+ (1..3).map(&amp;&apos;[-1, _, 0]&apos;) =&gt; [[-1, 1, 0], [-1, 2, 0], [-1, 3, 0]]
248
+ (1..3).map(&amp;&apos;x -&gt; y -&gt; x * y&apos;).map(&amp;&apos;[2]&apos;) =&gt; [2, 4, 6]
249
+ (1..5).select(&amp;&apos;&gt;2&apos;) =&gt; [3, 4, 5]
250
+ (1..3).map(&amp;&apos;x -&gt; y -&gt; x * y&apos;).map(&amp;&apos;.call(2)&apos;) =&gt; [2, 4, 6]
251
+ [5].map(&amp;&quot;(1.._).inject(&amp;&apos;*&apos;)&quot;) =&gt; [120]</pre>
252
+
253
+ <h4>Grammatically-correct is_an? method - no more "is_a? Array" statements</h4>
254
+
255
+ <pre>&gt;&gt; [].is_an? Array
256
+ #=&gt; true</pre>
257
+
258
+ <p>Most people don't care, but personally, "is_a? Array" drives me completely insane.</p>
259
+
260
+ <h4>Object#not</h4>
261
+
262
+ <p>Replace this:</p>
263
+
264
+ <pre>if !response.incomplete? &amp;&amp; !response.invalid? &amp;&amp; response.total &gt; 0</pre>
265
+
266
+ <p>With this:</p>
267
+
268
+ <pre>if response.not.incomplete? &amp;&amp; response.not.invalid? &amp;&amp; response.total &gt; 0</pre>
269
+
270
+ <p>Syntactic sugar for boolean conditions. (<a href="http://blog.jayfields.com/2007/08/ruby-adding-not-method-for-readability.html" title="Jay Fields Thoughts: Ruby: Adding a "not" method for readability">More detail here</a>.)</p>
271
+
272
+ <h4>One-character exit command</h4>
273
+
274
+ <pre>x</pre>
275
+
276
+ <p>Because life is too short to type whole words.</p>
277
+
278
+
279
+ </div>
280
+
281
+ <div id="footer">
282
+ <p>Copyright &copy; 2007 Giles Bowkett | Design by <a href="http://andreasviklund.com">Andreas Viklund</a>.</p>
283
+ </div>
284
+ </div>
285
+ </body>
286
+ </html>
@@ -1,6 +1,6 @@
1
1
  # S3 (http://amazon.rubyforge.org/)
2
2
  UTILITY_BELT_IRB_STARTUP_PROCS[:define_s3_convenience_methods] = lambda do
3
- require 'aws/s3'
3
+ %w{aws/s3 cgi}.each {|lib| require lib}
4
4
  def aws_upload(bucket,filename)
5
5
  AWS::S3::Base.establish_connection!(:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
6
6
  :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY'])
@@ -10,3 +10,7 @@ UTILITY_BELT_IRB_STARTUP_PROCS[:define_s3_convenience_methods] = lambda do
10
10
  url
11
11
  end
12
12
  end
13
+
14
+ # a quick note: the "google" command uses CGI.escape, but the URLs produced by CGI.escape
15
+ # don't seem to succeed here, in practice. this may differ by OS and/or browser. Let me
16
+ # know if you see something weird -- gilesb@gmail.com.
data/lib/pastie.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  class Object
3
3
  if :macosx == Platform::IMPL
4
4
  def pastie
5
- url =
6
5
  pastie_url = Net::HTTP.post_form(URI.parse("http://pastie.caboo.se/pastes/create"),
7
6
  {"paste_parser" => "ruby",
8
7
  "paste[authorization]" => "burger",
@@ -6,4 +6,3 @@ class Object
6
6
  ActiveRecord::Base.logger = Logger.new(STDOUT)
7
7
  end
8
8
  end
9
-
data/lib/utility_belt.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  # This started as my (Giles Bowkett's) .irbrc file, turned into a recipe on IRB for the Pragmatic Programmers,
2
2
  # and soon became a scrapbook of cool code snippets from all over the place. All the RDoc lives in the README.
3
- # Check that file for usage information, authorship, copyright, and extensive details. This file contains the
4
- # actual code (duh), and a bunch of links to relevant blog posts. You can also find a nice, HTMLified version
5
- # of the README content at http://utilitybelt.rubyforge.org.
3
+ # Check that file for usage information, authorship, copyright, and extensive details. You can also find a
4
+ # nice, HTMLified version of the README content at http://utilitybelt.rubyforge.org.
6
5
 
7
6
  UTILITY_BELT_IRB_STARTUP_PROCS = {}
8
7
 
data/utility_belt.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  SPEC = Gem::Specification.new do |s|
3
3
  s.name = "utility_belt"
4
- s.version = "1.0.0"
4
+ s.version = "1.0.1"
5
5
  s.author = "Giles Bowkett"
6
6
  s.email = "gilesb@gmail.com"
7
7
  s.homepage = "http://utilitybelt.rubyforge.org"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utility_belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giles Bowkett
@@ -9,7 +9,7 @@ autorequire: utility_belt
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-12-03 00:00:00 -08:00
12
+ date: 2007-12-10 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,6 +53,16 @@ files:
53
53
  - bin/amazon
54
54
  - bin/google
55
55
  - History.txt
56
+ - html
57
+ - html/andreas00.css
58
+ - html/authorship.html
59
+ - html/bg.gif
60
+ - html/front.jpg
61
+ - html/index.html
62
+ - html/menubg.gif
63
+ - html/menubg2.gif
64
+ - html/test.jpg
65
+ - html/usage.html
56
66
  - lib
57
67
  - lib/amazon_upload_shortcut.rb
58
68
  - lib/command_history.rb
@@ -77,7 +87,6 @@ files:
77
87
  - test
78
88
  - test/string_to_proc_spec.rb
79
89
  - test/utility_belt_spec.rb
80
- - utility_belt-1.0.0.gem
81
90
  - utility_belt.gemspec
82
91
  has_rdoc: true
83
92
  homepage: http://utilitybelt.rubyforge.org
File without changes