mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
- JRuby makes us not need any ruby monkeypatches. LOGSTASH-30
This commit is contained in:
parent
0c0101206b
commit
7415a9c445
2 changed files with 0 additions and 48 deletions
|
@ -1,21 +0,0 @@
|
|||
# Ruby 1.8.7 added String#start_with? - monkeypatch the
|
||||
# String class if it isn't supported (<= ruby 1.8.6)
|
||||
if !String.instance_methods.include?("start_with?")
|
||||
class String
|
||||
public
|
||||
def start_with?(str)
|
||||
return self[0 .. (str.length-1)] == str
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Ruby 1.8.7 added String#bytesize, used by the latest amqp gem to get the
|
||||
# size of a string (instead of String#length). This monkeypatch enables older
|
||||
# ruby to work, but may cause AMQP trouble on UTF-8 strings.
|
||||
if !String.instance_methods.include?("bytesize")
|
||||
class String
|
||||
alias :bytesize :length
|
||||
end
|
||||
end
|
||||
|
||||
require "logstash/rubyfixes/regexp_union_takes_array"
|
|
@ -1,27 +0,0 @@
|
|||
# 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