aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMisty De Meo2017-05-29 17:51:38 -0700
committerMisty De Meo2017-06-03 20:47:39 -0700
commitffa65c749856d525edef6029d774de2486d1cccd (patch)
tree920f5a25641149c40ea3a09ecea01915e5c2c7b6 /Library/Homebrew
parent98959f1fb9c667abde593dcd92128aed5367d29a (diff)
downloadbrew-ffa65c749856d525edef6029d774de2486d1cccd.tar.bz2
String: backport #match? from 2.4.0
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/extend/string.rb3
-rw-r--r--Library/Homebrew/vendor/README.md26
-rw-r--r--Library/Homebrew/vendor/backports/string.rb12
3 files changed, 41 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index 809242db9..ae7a209db 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -1,3 +1,6 @@
+# Contains backports from newer versions of Ruby
+require_relative "../vendor/backports/string"
+
class String
def undent
gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "")
diff --git a/Library/Homebrew/vendor/README.md b/Library/Homebrew/vendor/README.md
index b408631c7..79b118ce4 100644
--- a/Library/Homebrew/vendor/README.md
+++ b/Library/Homebrew/vendor/README.md
@@ -5,6 +5,8 @@ Vendored Dependencies
* [ruby-macho](https://github.com/Homebrew/ruby-macho), version 1.1.0
+* [backports](https://github.com/marcandre/backports), version 3.8.0
+
## Licenses:
### plist
@@ -52,3 +54,27 @@ Vendored Dependencies
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
+
+### backports
+
+> Copyright (c) 2009 Marc-Andre Lafortune
+
+> Permission is hereby granted, free of charge, to any person obtaining
+> a copy of this software and associated documentation files (the
+> "Software"), to deal in the Software without restriction, including
+> without limitation the rights to use, copy, modify, merge, publish,
+> distribute, sublicense, and/or sell copies of the Software, and to
+> permit persons to whom the Software is furnished to do so, subject to
+> the following conditions:
+
+> The above copyright notice and this permission notice shall be
+> included in all copies or substantial portions of the Software.
+
+> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+> NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+> LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+> OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+> WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/Library/Homebrew/vendor/backports/string.rb b/Library/Homebrew/vendor/backports/string.rb
new file mode 100644
index 000000000..6299a3fb4
--- /dev/null
+++ b/Library/Homebrew/vendor/backports/string.rb
@@ -0,0 +1,12 @@
+# Taken from https://github.com/marcandre/backports/blob/v3.8.0/lib/backports/2.4.0/string/match.rb
+unless String.method_defined? :match?
+ class String
+ def match?(*args)
+ # Fiber to avoid setting $~
+ f = Fiber.new do
+ !match(*args).nil?
+ end
+ f.resume
+ end
+ end
+end