Top Banner
Adam Kalsey [email protected] @akalsey Tropo www.Tropo.com @tropo
25

Introduction to jRuby

Dec 01, 2014

Download

Technology

Adam Kalsey

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.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to jRuby

Adam [email protected]

@akalsey

Tropowww.Tropo.com

@tropo

Page 2: Introduction to jRuby
Page 3: Introduction to jRuby

http://www.flickr.com/photos/chefranden/

Page 4: Introduction to jRuby

http://www.flickr.com/photos/malias/

Page 5: Introduction to jRuby

http://www.flickr.com/photos/thatguyfromcchs08/

Page 6: Introduction to jRuby

include Javaimport java.lang.ArrayListimport javax.swing.JFrame

list = ArrayList.newframe = JFrame.new("Ruby SWINGS!")list << framelist.each {|f| f.set_size(200,200) }

Page 7: Introduction to jRuby

http://www.flickr.com/photos/yakobusan/

Page 8: Introduction to jRuby

http://www.flickr.com/photos/thisisbossi/

Page 9: Introduction to jRuby

include_class 'java.lang.String'

Page 10: Introduction to jRuby

include_class('java.lang.String') {|package,name| "J#{name}"}

Page 11: Introduction to jRuby

1. Download & unpack jRuby

2. ???

3. Profit

Page 12: Introduction to jRuby

Demo Time

Page 13: Introduction to jRuby

bin/gem install <package>

Page 14: Introduction to jRuby

Demo Time

Page 15: Introduction to jRuby

http://www.flickr.com/photos/oneaustin/

Page 16: Introduction to jRuby

http://www.flickr.com/photos/underbiteman/

Page 17: Introduction to jRuby
Page 18: Introduction to jRuby

• Call

• Answer

• Transfer

• Reject

• Hangup

• Say

• Ask

• Record

• Conference

Page 19: Introduction to jRuby

answer

say 'Yes, this works across channels.'

hangup

Page 20: Introduction to jRuby

Mozilla RhinoQuercus

PythonJython

JRuby

Page 21: Introduction to 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

Page 22: Introduction to jRuby

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')) ...

Page 23: Introduction to jRuby

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; }

...

Page 24: Introduction to jRuby

Call or SMS: (407) 374-9954

GTalk, XMPP: [email protected]

Twitter: @tropobart

http://github.com/voxeo/tropo-samples/

Page 25: Introduction to jRuby

Adam [email protected]

@akalsey

Tropowww.Tropo.com

@tropo