introduction to jruby
DESCRIPTION
jRuby allows a developer to run Ruby applications in a Java Virtual Machine. Adam Kalsey from Tropo explains why you'd want to do that, what jRuby can do for you, and show how Tropo uses jRuby in building a real-time communications cloud service. Includes how to deploy apps on jRuby, and some of the pitfalls to watch out for.TRANSCRIPT
http://www.flickr.com/photos/chefranden/
http://www.flickr.com/photos/malias/
http://www.flickr.com/photos/thatguyfromcchs08/
include Javaimport java.lang.ArrayListimport javax.swing.JFrame
list = ArrayList.newframe = JFrame.new("Ruby SWINGS!")list << framelist.each {|f| f.set_size(200,200) }
http://www.flickr.com/photos/yakobusan/
http://www.flickr.com/photos/thisisbossi/
include_class 'java.lang.String'
include_class('java.lang.String') {|package,name| "J#{name}"}
1. Download & unpack jRuby
2. ???
3. Profit
Demo Time
bin/gem install <package>
Demo Time
http://www.flickr.com/photos/oneaustin/
http://www.flickr.com/photos/underbiteman/
• Call
• Answer
• Transfer
• Reject
• Hangup
• Say
• Ask
• Record
• Conference
answer
say 'Yes, this works across channels.'
hangup
Mozilla RhinoQuercus
PythonJython
JRuby
answer
options = { :choices => '1 (1,sales), 2 (2 support)' }result = ask 'Hi. For sales, say Sales or press 1. For support, say Support or press 2.', options
if result.name == 'choice' case result.value when '1' say 'Your money is important to us.' when '2' say 'Your call will be ignored in the order received.' end end
hangup
def ask (ttsOrUrl, options={})
...
result = call.prompt(ttsOrUrl, localOptions[:voice], localOptions[:recognizer], localOptions[:bargein], localOptions[:grammar], localOptions[:terminator], localOptions[:choiceConfidence], localOptions[:choiceMode], localOptions[:timeout]) if (result.get('event.name')) ...
public Map<String, Object> prompt(final String ttsOrUrl, final String ttsResourceName, ...) { LOG.info(this + "->prompt(\"" + ttsOrUrl + "\", ... )"); Map<String, Object> retval = null; try { assertReady("prompt", Call.State.ANSWERED);
if (!Strings.isEmpty(termChar) && Strings.isEmpty(grammar)) { log("termChar with no grammar. Setting grammar to equal termChar: " + termChar); grammar = termChar; termChar = null; }
...
Call or SMS: (407) 374-9954
GTalk, XMPP: [email protected]
Twitter: @tropobart
http://github.com/voxeo/tropo-samples/