Add backwards compatibility define_singleton_method for Ruby 1.8.
This commit is contained in:
parent
2de2bc908b
commit
4f775ac5ca
|
@ -1,6 +1,25 @@
|
||||||
require 'ffi'
|
require 'ffi'
|
||||||
|
|
||||||
|
if VERSION =~ /^1.8/
|
||||||
|
require 'process_shared/define_singleton_method'
|
||||||
|
|
||||||
|
module ProcessShared
|
||||||
|
module PSem
|
||||||
|
extend DefineSingletonMethod
|
||||||
|
end
|
||||||
|
|
||||||
|
module RT
|
||||||
|
extend DefineSingletonMethod
|
||||||
|
end
|
||||||
|
|
||||||
|
module LibC
|
||||||
|
extend DefineSingletonMethod
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
require 'process_shared/semaphore'
|
require 'process_shared/semaphore'
|
||||||
require 'process_shared/bounded_semaphore'
|
require 'process_shared/bounded_semaphore'
|
||||||
require 'process_shared/mutex'
|
require 'process_shared/mutex'
|
||||||
require 'process_shared/shared_memory'
|
require 'process_shared/shared_memory'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
module ProcessShared
|
||||||
|
module DefineSingletonMethod
|
||||||
|
# This method was added in Ruby 1.9.x. Include this module for
|
||||||
|
# backwards compatibility.
|
||||||
|
#
|
||||||
|
# This isn't exactly compatible with the method in 1.9 which can
|
||||||
|
# take a Proc, Method, or a block. This only accepts a block.
|
||||||
|
def define_singleton_method(sym, &block)
|
||||||
|
eigenclass = class << self; self; end
|
||||||
|
eigenclass.send(:define_method, sym, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
require 'rubygems' if VERSION =~ /^1.8/
|
||||||
gem 'minitest'
|
gem 'minitest'
|
||||||
require 'minitest/spec'
|
require 'minitest/spec'
|
||||||
require 'minitest/autorun'
|
require 'minitest/autorun'
|
||||||
require 'minitest/matchers'
|
require 'minitest/matchers'
|
||||||
|
|
||||||
|
require 'process_shared'
|
||||||
|
|
||||||
class RangeMatcher
|
class RangeMatcher
|
||||||
def initialize(operator, limit)
|
def initialize(operator, limit)
|
||||||
@operator = operator.to_sym
|
@operator = operator.to_sym
|
||||||
|
|
Loading…
Reference in New Issue