module Monkey::Engine
Makes sure we always have RUBY_ENGINE
, RUBY_ENGINE_VERSION
and RUBY_DESCRIPTION
TODO: Check IronRuby version detection.
Constants
- REAL_RUBY_ENGINE
- REAL_RUBY_ENGINE_VERSION
- RUBY_DESCRIPTION
- RUBY_ENGINE
- RUBY_ENGINE_VERSION
- RUBY_ENINGE
Public Class Methods
Source
# File lib/monkey/engine.rb, line 10 def ironruby?; RUBY_ENGINE == "ironruby"; end
Source
# File lib/monkey/engine.rb, line 9 def rbx?; RUBY_ENGINE == "rbx"; end
Also aliased as: rubinius?
Source
# File lib/monkey/engine.rb, line 16 def ree? !!(RUBY_DESCRIPTION =~ /Ruby Enterprise Edition/) || RUBY_ENGINE == "ree" end
Source
# File lib/monkey/engine.rb, line 84 def ruby_engine(engine = RUBY_ENGINE, pretty = true) return engine unless pretty case engine when "ruby" then ree? ? "Ruby Enterprise Edition" : "Ruby" when "ree" then "Ruby Enterprise Edition" when "rbx" then "Rubinius" when "maglev" then "MagLev" else engine.capitalize.gsub("ruby", "Ruby") end end
Source
# File lib/monkey/engine.rb, line 97 def self.set_engine(engine, engine_version = nil) Object.send :remove_const, "RUBY_ENGINE" Object.const_set "RUBY_ENGINE", engine if engine_version Object.send :remove_const, "RUBY_ENGINE_VERSION" Object.const_set "RUBY_ENGINE_VERSION", engine_version end end
Source
# File lib/monkey/engine.rb, line 130 def use_original_ruby_engine(&block) if defined? ::OLD_RUBY_ENGINE then with_ruby_engine(::OLD_RUBY_ENGINE, ::OLD_RUBY_ENGINE_VERSION, &block) else with_ruby_engine(::RUBY_ENGINE, ::RUBY_ENGINE_VERSION, &block) end end
Source
# File lib/monkey/engine.rb, line 124 def use_real_ruby_engine(&block) with_ruby_engine(::REAL_RUBY_ENGINE, ::REAL_RUBY_ENGINE_VERSION, &block) end
Source
# File lib/monkey/engine.rb, line 106 def with_ruby_engine(engine, engine_version) engine_was, engine_version_was = ::RUBY_ENGINE, ::RUBY_ENGINE_VERSION unless defined? ::OLD_RUBY_ENGINE Object.const_set("OLD_RUBY_ENGINE", ::RUBY_ENGINE) Object.const_set("OLD_RUBY_ENGINE_VERSION", ::RUBY_ENGINE_VERSION) end Monkey::Engine.set_engine engine, engine_version if block_given? result = yield Monkey::Engine.set_engine engine_was, engine_version_was result else [engine_was, engine_version_was] end end
Private Instance Methods
Source
# File lib/monkey/engine.rb, line 10 def ironruby?; RUBY_ENGINE == "ironruby"; end
Source
# File lib/monkey/engine.rb, line 9 def rbx?; RUBY_ENGINE == "rbx"; end
Also aliased as: rubinius?
Source
# File lib/monkey/engine.rb, line 16 def ree? !!(RUBY_DESCRIPTION =~ /Ruby Enterprise Edition/) || RUBY_ENGINE == "ree" end
Source
# File lib/monkey/engine.rb, line 84 def ruby_engine(engine = RUBY_ENGINE, pretty = true) return engine unless pretty case engine when "ruby" then ree? ? "Ruby Enterprise Edition" : "Ruby" when "ree" then "Ruby Enterprise Edition" when "rbx" then "Rubinius" when "maglev" then "MagLev" else engine.capitalize.gsub("ruby", "Ruby") end end
Source
# File lib/monkey/engine.rb, line 130 def use_original_ruby_engine(&block) if defined? ::OLD_RUBY_ENGINE then with_ruby_engine(::OLD_RUBY_ENGINE, ::OLD_RUBY_ENGINE_VERSION, &block) else with_ruby_engine(::RUBY_ENGINE, ::RUBY_ENGINE_VERSION, &block) end end
Source
# File lib/monkey/engine.rb, line 124 def use_real_ruby_engine(&block) with_ruby_engine(::REAL_RUBY_ENGINE, ::REAL_RUBY_ENGINE_VERSION, &block) end
Source
# File lib/monkey/engine.rb, line 106 def with_ruby_engine(engine, engine_version) engine_was, engine_version_was = ::RUBY_ENGINE, ::RUBY_ENGINE_VERSION unless defined? ::OLD_RUBY_ENGINE Object.const_set("OLD_RUBY_ENGINE", ::RUBY_ENGINE) Object.const_set("OLD_RUBY_ENGINE_VERSION", ::RUBY_ENGINE_VERSION) end Monkey::Engine.set_engine engine, engine_version if block_given? result = yield Monkey::Engine.set_engine engine_was, engine_version_was result else [engine_was, engine_version_was] end end