sakai on rails integrating ruby and sakai david adams, virginia tech

18
Sakai on Rails Integrating Ruby and Sakai David Adams, Virginia Tech

Upload: cleopatra-gregory

Post on 17-Dec-2015

221 views

Category:

Documents


1 download

TRANSCRIPT

Sakai on Rails

Integrating Ruby and Sakai

David Adams, Virginia Tech

Topics to cover

• Quick introduction to Ruby and Rails• Why consider Rails for Sakai?• How to integrate Ruby and Java• How to integrate Rails and Sakai• Tiny demo if we have time

Caveats

• I’m a sysadmin, not a programmer• I’m new to Sakai• I’ve never written a Sakai tool in Java• This is bleeding edge technology• This presentation is a starting point

What is Ruby?

• Programming language• Dynamic, interpreted, strongly-typed• Built on ideas from many other languages:

– The good parts of Perl– Smalltalk-like OO: everything is an object– A few dashes of Scheme

• http://www.ruby-lang.org

Really Cool Stuff about Ruby

• Concise syntax, easy to read• Metaprogramming

– Redefine classes at runtime• Like Javascript, “a crazed language” per Antranig

– method_missing?

• Duck typing– If it looks like a duck and quacks like a duck…

• (These can be good and bad)

The Ruby Community

“Ruby may not actually be the be-all and end-all of programming languages. But right now, make no mistake, it's a white-hot nexus of innovation.”

-- Tim Bray, Sun Microsystems, co-creator of XML

What is Rails?

• Web application framework• Built on Ruby• Unique to Ruby• Strict MVC pattern• More than just a CRUD generator

Really Cool Stuff about Rails

• Convention over configuration• Use Ruby for everything (DSLs)

– SQL migrations, schemas– Javascript (RJS)– Templates (Markaby)– URL mapping (Routes)– Maintenance tasks (Rake)– Okay, some stuff has to be in YAML

More Really Cool Stuff about Rails

• Integrated testing framework• Integrated data validation• Robust plugin system• Robust AJAX integration• ActiveRecord (ORM)

– Discovers the database structure without help– Harnesses Ruby’s metaprogramming abilities– Just as useful outside of web applications

Why use Rails?

• Write applications quickly• “Powerful web applications that formerly

might have taken weeks or monthsto develop can be produced in a matter of days.” – Tim O’Reilly

• Less code, better maintainability• Ruby is fun!

Who cares?

• Why should the Sakai community care?– Perfect for ad hoc and internal use tools– Rapid prototyping – with functionality

• B-but Rails is Ruby; Sakai runs on Java…

JRuby 1.0

• Released June 10, 2007• “Our main goal for 1.0 has been Ruby

compatibility.  We feel this goal has been reached.” – Thomas Enebo

• Run Ruby (and thus Rails) in the JVM• In some cases, can be faster than C Ruby• http://www.jruby.org

Rails in a Servlet

• Goldspike (Rails-Integration)– Rails plugin– Packs Rails app (and dependencies) in a WAR– Experimental Maven 2 support– Kinda flaky; needs tweaking to work with Sakai

– http://www.headius.com/jrubywiki/index.php/Rails_Integration

A Sakai Tool in Rails

• Take a Goldspike WAR• Tweak the web.xml file• Add the sakai.toolname.xml file• Done! (mostly)• Sakai on Rails plugin:

– https://source.edtech.vt.edu/svn/sakai/rails/trunk/plugin

– Generator, templates, library

Demo

• Create a Rails app that runs as a Sakai tool• I won’t go through the environment setup

– It’s painful and error prone– Goldspike requires tweaks to work with Sakai

• No time to do anything fancy

Downsides

• Something new to learn• Sakai is built on Java idioms• No way (yet?) to call Ruby classes from

Java directly• ActiveRecord versus Sakai APIs• “Attempts to code directly to Sakai databases will only lead

to heartache and disappointment.” – Mark Norton

Now what?

• Sakai on Rails not yet ready for prime time• Study performance impact• Streamline/document environment setup• Goldspike needs to be “fixed”• Provide Ruby-ized access to Sakai APIs• Start building small tools

Thanks!

David Adams, [email protected]