1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Use RbConfig::CONFIG['host_os'] for OS checks.

Fixes: #386
Switch jruby? to use JRUBY_VERSION
Switch rbx? to use RbConfig['ruby_install_name']
Signed-off-by: Jordon Bedwell <jordon@envygeeks.com>
This commit is contained in:
Jordon Bedwell 2011-12-26 15:57:40 -06:00
parent ba34c98d21
commit 67e98174a0
4 changed files with 14 additions and 7 deletions

View file

@ -157,8 +157,9 @@ require "stringio"
require "coderay"
require "optparse"
require "slop"
require "rbconfig"
if RUBY_PLATFORM =~ /jruby/
if defined? JRUBY_VERSION
begin
require 'ffi'
rescue LoadError
@ -166,7 +167,7 @@ if RUBY_PLATFORM =~ /jruby/
end
end
if RUBY_PLATFORM =~ /mswin/ || RUBY_PLATFORM =~ /mingw/
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
begin
require 'win32console'
rescue LoadError

View file

@ -93,12 +93,16 @@ class Pry
# are we on Jruby platform?
def jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
defined? JRUBY_VERSION
end
# are we on rbx platform?
def rbx?
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
if RbConfig['ruby_install_name'] == 'rbx'
return true
end
nil
end
# a simple pager for systems without `less`. A la windows.

View file

@ -187,7 +187,9 @@ class Pry
# Return the syntax for a given editor for starting the editor
# and moving to a particular line within that file
def start_line_syntax_for_editor(file_name, line_number)
file_name = file_name.gsub(/\//, '\\') if RUBY_PLATFORM =~ /mswin|mingw/
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
file_name = file_name.gsub(/\//, '\\')
end
# special case for 1st line
return file_name if line_number <= 1
@ -202,7 +204,7 @@ class Pry
when /^jedit/
"#{file_name} +line:#{line_number}"
else
if RUBY_PLATFORM =~ /mswin|mingw/
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
"#{file_name}"
else
"+#{line_number} #{file_name}"

View file

@ -192,7 +192,7 @@ class Pry
end
def self.default_editor_for_platform
if RUBY_PLATFORM =~ /mswin|mingw/
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
ENV['VISUAL'] || ENV['EDITOR'] || "notepad"
else
if ENV['VISUAL'] and not ENV['VISUAL'].empty?