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
commit50767c60773b290eb8d203695852a6a0c21c71e4 (patch)
tree350492373da4f93cc528b93637be57d71d394db0 /Library/Homebrew/extend/string.rb
parent05991dd846ac54b10cd78453b140de8bfb259392 (diff)
downloadbrew-50767c60773b290eb8d203695852a6a0c21c71e4.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)