Use Helpers::BaseHelpers.<foo>? MOAR

This commit is contained in:
Conrad Irwin 2011-12-27 22:38:25 +00:00
parent a01d1de27d
commit 30e1e0941e
8 changed files with 9 additions and 19 deletions

View File

@ -215,12 +215,12 @@ class Pry
config.exception_whitelist = DEFAULT_EXCEPTION_WHITELIST
config.hooks = DEFAULT_HOOKS
config.input_stack = []
config.color = Pry::Helpers::BaseHelpers.use_ansi_codes?
config.color = Helpers::BaseHelpers.use_ansi_codes?
config.pager = true
config.system = DEFAULT_SYSTEM
config.editor = default_editor_for_platform
config.should_load_rc = true
config.should_trap_interrupts = defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
config.should_trap_interrupts = Helpers::BaseHelpers.jruby?
config.disable_auto_reload = false
config.command_prefix = ""
config.auto_indent = true

View File

@ -54,7 +54,7 @@ class Pry
def singleton_instance
raise ArgumentError, "tried to get instance of non singleton class" unless singleton_class?
if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
if Helpers::BaseHelpers.jruby?
wrapped.to_java.attached
else
@singleton_instance ||= ObjectSpace.each_object(wrapped).detect{ |x| (class << x; self; end) == wrapped }

View File

@ -49,16 +49,6 @@ class MockPryException
end
end
# are we on Jruby platform?
def jruby?
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /jruby/
end
# are we on rbx platform?
def rbx?
defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
end
Pry.reset_defaults
# this is to test exception code (cat --ex)
@ -183,7 +173,7 @@ end
# to help with tracking down bugs that cause an infinite loop in the test suite
if ENV["SET_TRACE_FUNC"]
require 'set_trace' if defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/ # gem install 'rbx-tracer'
require 'set_trace' if Pry::Helpers::BaseHelpers.rbx?
set_trace_func proc { |event, file, line, id, binding, classname|
STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}

View File

@ -16,7 +16,7 @@ describe Pry::InputCompleter do
end
# another jruby hack :((
if !jruby?
if !Pry::Helpers::BaseHelpers.jruby?
it "should not crash if there's a Module that has a symbolic name." do
completer = Pry::InputCompleter.build_completion_proc(Pry.binding_for(Object.new))
lambda{ completer.call "a.to_s." }.should.not.raise Exception

View File

@ -92,7 +92,7 @@ describe "ls" do
describe "when no arguments given" do
describe "when at the top-level" do
# rubinius has a bug that means local_variables of "main" aren't reported inside eval()
unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
unless Pry::Helpers::BaseHelpers.rbx?
it "should show local variables" do
mock_pry("ls").should =~ /_pry_/
mock_pry("arbitrar = 1", "ls").should =~ /arbitrar/

View File

@ -47,7 +47,7 @@ describe "Pry::DefaultCommands::Shell" do
# this doesnt work so well on rbx due to differences in backtrace
# so we currently skip rbx until we figure out a workaround
describe "with --ex" do
if !rbx?
if !Pry::Helpers::BaseHelpers.rbx?
it 'cat --ex should correctly display code that generated exception even if raised in repl' do
mock_pry("this raises error", "cat --ex").should =~ /\d+:(\s*) this raises error/
end

View File

@ -98,7 +98,7 @@ describe Pry::Method do
end
# Our source_location trick doesn't work, due to https://github.com/rubinius/rubinius/issues/953
unless defined?(RUBY_ENGINE) && RUBY_ENGINE =~ /rbx/
unless Pry::Helpers::BaseHelpers.rbx?
it 'should find the super method correctly' do
a = Class.new{ def gag; binding; end; def self.line; __LINE__; end }
b = Class.new(a){ def gag; super; end }

View File

@ -26,7 +26,7 @@ describe Pry do
["1 1"],
["puts :"],
# in this case the syntax error is "expecting ')'".
((defined? RUBY_ENGINE && RUBY_ENGINE == "rbx") ? nil : ["def", "method(1"])
(Pry::Helpers::BaseHelpers.rbx? ? nil : ["def", "method(1"])
].compact.each do |foo|
it "should raise an error on invalid syntax like #{foo.inspect}" do
output = StringIO.new