module Toys::Compat
Compatibility wrappers for older Ruby versions. @private
Public Class Methods
absolute_path?(path)
click to toggle source
@private
# File lib/toys/compat.rb, line 92 def self.absolute_path?(path) ::File.absolute_path?(path) end
allow_fork?()
click to toggle source
@private
# File lib/toys/compat.rb, line 25 def self.allow_fork? !jruby? && !windows? end
glob_in_dir(glob, dir)
click to toggle source
@private
# File lib/toys/compat.rb, line 59 def self.glob_in_dir(glob, dir) ::Dir.glob(glob, base: dir) end
instantiate(klass, args, kwargs, block)
click to toggle source
@private
# File lib/toys/compat.rb, line 73 def self.instantiate(klass, args, kwargs, block) klass.new(*args, **kwargs, &block) end
jruby?()
click to toggle source
@private
# File lib/toys/compat.rb, line 15 def self.jruby? ::RUBY_PLATFORM == "java" end
suggestions(word, list)
click to toggle source
@private
# File lib/toys/compat.rb, line 48 def self.suggestions(word, list) if supports_suggestions? ::DidYouMean::SpellChecker.new(dictionary: list).correct(word) else [] end end
supports_suggestions?()
click to toggle source
@private
# File lib/toys/compat.rb, line 30 def self.supports_suggestions? unless defined?(@supports_suggestions) begin require "did_you_mean" rescue ::LoadError require "rubygems" begin require "did_you_mean" rescue ::LoadError # Oh well, it's not available end end @supports_suggestions = defined?(::DidYouMean::SpellChecker) end @supports_suggestions end
windows?()
click to toggle source
@private
# File lib/toys/compat.rb, line 20 def self.windows? ::RbConfig::CONFIG["host_os"] =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/ end