aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/string.rb
diff options
context:
space:
mode:
authorMax Howell2012-08-10 16:06:51 -0400
committerMax Howell2012-08-29 12:41:33 -0400
commit8c87b475a977afe1e32f617c3c748a3ab54e965d (patch)
tree2bd754b644b72da8e9003cd0d5cbc0d00459c491 /Library/Homebrew/extend/string.rb
parent0ed5daf86d4c3e86d9ce96439e0f4df30e089df4 (diff)
downloadhomebrew-8c87b475a977afe1e32f617c3c748a3ab54e965d.tar.bz2
Record HEAD SHA and date of installs in receipt
Diffstat (limited to 'Library/Homebrew/extend/string.rb')
-rw-r--r--Library/Homebrew/extend/string.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index 16171310b..e9f475b6e 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -21,6 +21,17 @@ class String
self[0, prefix.length] == prefix
end
end
+
+ # String.chomp, but if result is empty: returns nil instead.
+ # Allows `chuzzle || foo` short-circuits.
+ def chuzzle
+ s = chomp
+ s unless s.empty?
+ end
+end
+
+class NilClass
+ def chuzzle; end
end
# used by the inreplace function (in utils.rb)