lib/adhearsion/console.rb in adhearsion-2.3.5 vs lib/adhearsion/console.rb in adhearsion-2.4.0.beta1
- old
+ new
@@ -30,17 +30,17 @@
# Start the Adhearsion console
#
def run
set_prompt
Pry.config.command_prefix = "%"
- if libedit?
- logger.error "Cannot start. You are running Adhearsion on Ruby with libedit. You must use readline for the console to work."
- else
+ if jruby? || cruby_with_readline?
logger.info "Launching Adhearsion Console"
@pry_thread = Thread.current
pry
logger.info "Adhearsion Console exiting"
+ else
+ logger.error "Unable to launch Adhearsion Console: This version of Ruby is using libedit. You must use readline for the console to work."
end
end
def stop
return unless instance_variable_defined?(:@pry_thread)
@@ -63,10 +63,14 @@
def calls
Adhearsion.active_calls
end
+ def originate(*args, &block)
+ Adhearsion::OutboundCall.originate(*args, &block)
+ end
+
def take(call = nil)
case call
when Call
interact_with_call call
when String
@@ -99,17 +103,21 @@
ensure
set_prompt
pry
end
- def libedit?
+ def cruby_with_readline?
begin
# If NotImplemented then this might be libedit
Readline.emacs_editing_mode
- false
- rescue NotImplementedError
true
+ rescue NotImplementedError
+ false
end
+ end
+
+ def jruby?
+ defined? JRUBY_VERSION
end
private
def set_prompt