Skip to content

Commit d5c9df4

Browse files
committed
Fix for Ruby 1.9.x: Handle fact that IO.instance_methods can return either array of strings or symbols depending on version of Ruby.
1 parent a959bce commit d5c9df4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

Diff for: lib/cached_shell_redirector.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def self.execute(cmd_str, repo_id, options={}, &block)
4848
end
4949

5050
###############################################
51-
# Duck-typing of an IO interface #
51+
# Duck-typing of an IO interface #
5252
###############################################
5353
def respond_to?(my_method)
54-
!IO.instance_methods.index(my_method.to_s).nil? || super(my_method, *args, &block)
54+
IO.instance_methods.map(&:to_sym).include?(my_method.to_sym) || super(my_method, *args, &block)
5555
end
5656

5757
# Catch any extra args placed into stdin. We explicitly code the
@@ -104,7 +104,7 @@ def close_write
104104
# Ruby 1.8 define_method doesn't work with blocks.
105105
def method_missing(my_method, *args, &block)
106106
# Only handle IO methods!
107-
if IO.instance_methods.index(my_method.to_s).nil?
107+
unless IO.instance_methods.map(&:to_sym).include?(my_method.to_sym)
108108
return super(my_method, *args, &block)
109109
end
110110

@@ -195,8 +195,8 @@ def push_to_buffer(invalue)
195195
end
196196

197197
##############################################################################
198-
# The following three functions are the generic versions of what is #
199-
# currently "compiled" into function definitions above in missing_method(). #
198+
# The following three functions are the generic versions of what is #
199+
# currently "compiled" into function definitions above in missing_method(). #
200200
##############################################################################
201201
# Class #1 functions (Read functions with block/enumerator behavior)
202202
def enumerator_diverter(my_method,*args,&block)
@@ -229,7 +229,7 @@ def simple_proxy(my_method,*args,&block)
229229
end
230230

231231
###############################################
232-
# Basic redirector methods #
232+
# Basic redirector methods #
233233
###############################################
234234

235235
def initialize(cmd_str, repo_id, options={})
@@ -299,19 +299,19 @@ def exit_shell
299299
end
300300

301301
###############################################
302-
# Caching interface functions #
302+
# Caching interface functions #
303303
###############################################
304304

305305
def self.max_cache_time
306-
(Setting.plugin_redmine_git_hosting['gitCacheMaxTime']).to_i # in seconds, default = 60
306+
(Setting.plugin_redmine_git_hosting['gitCacheMaxTime']).to_i # in seconds, default = 60
307307
end
308308

309309
def self.max_cache_elements
310310
(Setting.plugin_redmine_git_hosting['gitCacheMaxElements']).to_i # default = 100
311311
end
312312

313313
def self.max_cache_size
314-
(Setting.plugin_redmine_git_hosting['gitCacheMaxSize']).to_i*1024*1024 # In MB, default = 16MB, converted to bytes
314+
(Setting.plugin_redmine_git_hosting['gitCacheMaxSize']).to_i*1024*1024 # In MB, default = 16MB, converted to bytes
315315
end
316316

317317
def self.compose_key(key1,key2)

0 commit comments

Comments
 (0)