utility_belt 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -32,6 +32,7 @@ sudo gem install utility_belt
32
32
  * Extremely basic themes for Wirble syntax coloring
33
33
  * Pascal/JavaScript-style "with" statement
34
34
  * String#to_proc
35
+ * Add and subtract Hashes with + and -
35
36
  * Grammatically-correct is_an? method - no more "is_a? Array" statements
36
37
  * One-character exit command
37
38
 
@@ -43,7 +44,7 @@ The majority of this code was written by other people and compiled, nicked, nabb
43
44
 
44
45
  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.
45
46
 
46
- Windows users have a couple options. The easiest is to define an environment variable called IRBRC and set it to the full path of your irbrc (e.g. "C:\Documents and Settings\<username>\_irbrc"). Presto, .irbrc for Windows. If you've already got HOME defined as an env var, you may be able to get away with just calling the file "irbrc". It's also technically possible on at least some versions of Windows to actually name your file .irbrc, you just have to get around the limitations imposed by Windows Explorer.
47
+ Windows users have a couple options. The easiest is to define an environment variable called IRBRC and set it to the full path of your irbrc (e.g. "C:\Documents and Settings\<username>\_irbrc"). Presto, .irbrc for Windows. You could also set your HOME-Variable to any directory you want and put your ".irbrc" in there. (It needs to be called ".irbrc", "_irbrc" won't work). Since Windows Explorer won't let you create a file with a dot in the beginning, use any text editor (Notepad will do just fine) and "Save As" to save it as ".irbrc". (The quotation marks make the magic happen.) We don't recommend this if you're also using MSYS or Cygwin, as they use the same variable for their own purposes.
47
48
 
48
49
  Adding Utility Belt to your .irbrc is easy:
49
50
 
@@ -60,15 +61,19 @@ Using each of Utility Belt's tools is different:
60
61
 
61
62
  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:
62
63
 
63
- edit(:the_name_of_my_editor)
64
+ edit_interactively(:the_name_of_my_editor)
64
65
 
65
66
  or
66
67
 
67
- edit("the name of my editor")
68
+ edit_interactively("the name of my editor")
68
69
 
69
70
  or
70
71
 
71
- edit("/the/path/to/my/editor")
72
+ edit_interactively("/the/path/to/my/editor")
73
+
74
+ If you're wondering why the method name is so ridiculously long, there's a story there:
75
+
76
+ http://gilesbowkett.blogspot.com/2007/12/utility-belt-vs-rails.html
72
77
 
73
78
  == Read from and write to OS X clipboard
74
79
 
@@ -259,6 +264,14 @@ Syntactic sugar for functional programming.
259
264
 
260
265
  For more detail see: http://weblog.raganwald.com/2007/10/stringtoproc.html
261
266
 
267
+ == Add and subtract Hashes with + and -
268
+
269
+ {:a => :b} + {:c => :d} = {:a => :b, :c => :d}
270
+ {:a => :b, :c => :d} - {:c => :d} = {:a => :b}
271
+ {:a => :b, :c => :d} - :c = {:a => :b}
272
+
273
+ You could already do this with Arrays; now you can do it with Hashes as well. (I was kinda surprised the first time I tried to do this and realized I'd have to write it myself.)
274
+
262
275
  == Grammatically-correct is_an? method - no more "is_a? Array" statements
263
276
 
264
277
  >> [].is_an? Array
data/html/index.html CHANGED
@@ -56,6 +56,7 @@
56
56
  <li>Extremely basic themes for Wirble syntax coloring</li>
57
57
  <li>Pascal/JavaScript-style "with" statement</li>
58
58
  <li>String#to_proc</li>
59
+ <li>Add and subtract Hashes with + and -</li>
59
60
  <li>Grammatically-correct is_an? method - no more "is_a? Array" statements</li>
60
61
  <li>One-character exit command</li>
61
62
  </ul>
data/html/usage.html CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  <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>
38
38
 
39
- <p>Windows users have a couple options. The easiest is to define an environment variable called IRBRC and set it to the full path of your irbrc (e.g. "C:\Documents and Settings\<username>\_irbrc"). Presto, .irbrc for Windows. If you've already got HOME defined as an env var, you may be able to get away with just calling the file "irbrc". It's also technically possible on at least some versions of Windows to actually name your file .irbrc, you just have to get around the limitations imposed by Windows Explorer.</p>
39
+ <p>Windows users have a couple options. The easiest is to define an environment variable called IRBRC and set it to the full path of your irbrc (e.g. "C:\Documents and Settings\<username>\_irbrc"). Presto, .irbrc for Windows. You could also set your HOME-Variable to any directory you want and put your ".irbrc" in there. (It needs to be called ".irbrc", "_irbrc" won't work). Since Windows Explorer won't let you create a file with a dot in the beginning, use any text editor (Notepad will do just fine) and "Save As" to save it as ".irbrc". (The quotation marks make the magic happen.) We don't recommend this if you're also using MSYS or Cygwin, as they use the same variable for their own purposes.</p>
40
40
 
41
41
  <p>Adding Utility Belt to your .irbrc is easy:</p>
42
42
 
@@ -53,15 +53,17 @@ require 'utility_belt'</pre>
53
53
 
54
54
  <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>
55
55
 
56
- <pre>edit(:the_name_of_my_editor)</pre>
56
+ <pre>edit_interactively(:the_name_of_my_editor)</pre>
57
57
 
58
58
  <p>or</p>
59
59
 
60
- <pre>edit("the name of my editor")</pre>
60
+ <pre>edit_interactively("the name of my editor")</pre>
61
61
 
62
62
  <p>or</p>
63
63
 
64
- <pre>edit("/the/path/to/my/editor")</pre>
64
+ <pre>edit_interactively("/the/path/to/my/editor")</pre>
65
+
66
+ <p>If you're wondering why the method name is so ridiculously long, <a href="http://gilesbowkett.blogspot.com/2007/12/utility-belt-vs-rails.html" title="Giles Bowkett: Utility Belt vs. Rails">there's a story there</a>.</p>
65
67
 
66
68
  <h4>Read from and write to OS X clipboard</h4>
67
69
 
@@ -251,6 +253,15 @@ end</pre>
251
253
  (1..3).map(&amp;&apos;x -&gt; y -&gt; x * y&apos;).map(&amp;&apos;.call(2)&apos;) =&gt; [2, 4, 6]
252
254
  [5].map(&amp;&quot;(1.._).inject(&amp;&apos;*&apos;)&quot;) =&gt; [120]</pre>
253
255
 
256
+ <h4>Add and subtract Hashes with + and -</h4>
257
+
258
+ <pre>{:a =&gt; :b} + {:c =&gt; :d} = {:a =&gt; :b, :c =&gt; :d}
259
+ {:a =&gt; :b, :c =&gt; :d} - {:c =&gt; :d} = {:a =&gt; :b}
260
+ {:a =&gt; :b, :c =&gt; :d} - :c = {:a =&gt; :b}</pre>
261
+
262
+ <p>You could already do this with Arrays; now you can do it with Hashes as well. (I was kinda surprised the first time I tried to do this and realized I'd have to write it myself.)</p>
263
+
264
+
254
265
  <h4>Grammatically-correct is_an? method - no more "is_a? Array" statements</h4>
255
266
 
256
267
  <pre>&gt;&gt; [].is_an? Array
@@ -7,7 +7,7 @@ class InteractiveEditor
7
7
  @editor = "mate -w"
8
8
  end
9
9
  end
10
- def edit
10
+ def edit_interactively
11
11
  unless @file
12
12
  @file = Tempfile.new("irb_tempfile")
13
13
  end
@@ -19,24 +19,24 @@ class InteractiveEditor
19
19
  end
20
20
 
21
21
  class Object
22
- def edit(editor)
22
+ def edit_interactively(editor)
23
23
  unless IRB.conf[:interactive_editors] && IRB.conf[:interactive_editors][editor]
24
24
  IRB.conf[:interactive_editors] ||= {}
25
25
  IRB.conf[:interactive_editors][editor] = InteractiveEditor.new(editor)
26
26
  end
27
- IRB.conf[:interactive_editors][editor].edit
27
+ IRB.conf[:interactive_editors][editor].edit_interactively
28
28
  end
29
29
 
30
30
  def vi
31
- edit(:vim)
31
+ edit_interactively(:vim)
32
32
  end
33
33
 
34
34
  def mate
35
- edit(:mate)
35
+ edit_interactively(:mate)
36
36
  end
37
37
 
38
38
  def emacs
39
- edit(:emacs)
39
+ edit_interactively(:emacs)
40
40
  end
41
41
  end
42
42
 
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.5"
4
+ s.version = "1.0.6"
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.5
4
+ version: 1.0.6
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-15 00:00:00 -08:00
12
+ date: 2007-12-16 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency