mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
- Backport Ruby 1.8.7 Regexp.union([array]) so Rack 1.2.1 works in Ruby
<= 1.8.6. This should fix issue http://code.google.com/p/logstash/issues/detail?id=5 Tested in rvm with: 'rvm 1.8.6 exec bin/logstash-web'
This commit is contained in:
parent
fb6e0d590d
commit
6e0684bf84
2 changed files with 29 additions and 0 deletions
|
@ -8,3 +8,5 @@ if !String.instance_methods.include?("start_with?")
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
require "logstash/rubyfixes/regexp_union_takes_array"
|
||||
|
|
27
lib/logstash/rubyfixes/regexp_union_takes_array.rb
Normal file
27
lib/logstash/rubyfixes/regexp_union_takes_array.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# Check if Regexp.union takes an array. If not, monkeypatch it.
|
||||
# This feature was added in Ruby 1.8.7 and is required by
|
||||
# Rack 1.2.1, breaking ruby <= 1.8.6
|
||||
|
||||
needs_fix = false
|
||||
begin
|
||||
Regexp.union(["a", "b"])
|
||||
rescue TypeError => e
|
||||
if e.message == "can't convert Array into String"
|
||||
needs_fix = true
|
||||
end
|
||||
end
|
||||
|
||||
if needs_fix
|
||||
class Regexp
|
||||
class << self
|
||||
alias_method :orig_regexp_union, :union
|
||||
public
|
||||
def union(*args)
|
||||
if args[0].is_a?(Array) && args.size == 1
|
||||
return orig_regexp_union(*args[0])
|
||||
end
|
||||
return orig_regexp_union(*args)
|
||||
end # def union
|
||||
end # class << self
|
||||
end # class Regexp
|
||||
end # if needs_fix
|
Loading…
Add table
Add a link
Reference in a new issue