• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
JRuby on Rails, Flying Saucer
 

JRuby on Rails, Flying Saucer

on

  • 2,494 views

A brief introduction to JRuby and JRuby on Rails, and an example of using a Java library from a JRuby on Rails application; the flying saucer library used to convert XHTML to PDF. ...

A brief introduction to JRuby and JRuby on Rails, and an example of using a Java library from a JRuby on Rails application; the flying saucer library used to convert XHTML to PDF.

Slides for presentation given at ArrrrCamp on October 16th 2009.

Statistics

Views

Total Views
2,494
Views on SlideShare
2,430
Embed Views
64

Actions

Likes
1
Downloads
7
Comments
0

6 Embeds 64

http://www.catsolutions.be 50
http://www.slideshare.net 5
http://catsolutions.be 4
http://www.docseek.net 3
http://new-site.catsolutions.be 1
http://webcache.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    JRuby on Rails, Flying Saucer JRuby on Rails, Flying Saucer Presentation Transcript

    • Who's this then? Alexander Malfait Enjoying Rails since 2007 Tallest employee at CAT Solutions
    • Wait, didn't we hate Java? JVM is fast JVM is everywhere, corporate approved Tons of useful & widely used libraries Runs great on Windows
    • Running Rails jruby -S gem install glassfish jruby -S glassfish -e production config.threadsafe! Works on other app servers (.war file)
    • Hiding behind Apache <VirtualHost *:80> ServerName my.awesome.app.be RewriteEngine On ProxyPass / http://localhost:3000/ retry=0 ProxyPassReverse / http://localhost:3000/ ErrorDocument 503 "<b>Come back in 10 seconds</b>" </VirtualHost> http://blog.headius.com/2009/04/apache-jruby-rails-glassfish-easy.html
    • Talking to Java Just create java objects like Ruby objects Extend Java classes in Ruby Require jars from Ruby without mucking about with the JVM ClassPath
    • Ruby Style Java java.lang.System.current_time_millis x.setSomething(var) => x.something = var button = javax.swing.JButton.new "Press me!" button.add_action_listener do |event| event.source.text = "You did it!" end
    • Flying Saucer Renders XHTML/CSS3 to PDF (very well!) Written in Java Handles any reporting problem you can throw at it
    • acts_as_flying_saucer Rails apps produce HTML You know HTML Report to PDF using HTML
    • Cocktail Reporting class DrinksController < ApplicationController acts_as_flying_saucer def mojito @ingredients = [ "4.0 cl White Rum", "3.0 cl Fresh lime juice", "3 sprigs of Mint", "2 teaspoons Sugar", "Soda Water" ] render_pdf :send_file => { :filename => "tasty.pdf" } end end
    • Cocktail Reporting <h1 style="color: green;">Mojito!</h1> <ul> <% @ingredients.each do |ingredient| %> <li><%=h ingredient %></li> <% end %> </ul> render_pdf
    • I want my mojito NOW! Rendering drinks/mojito Completed in 16ms ~62 mojitos/second
    • Larger documents Rendering the holy bible 4.5MB of HTML Resulting PDF: 1134 pages Completed in 22500ms
    • Real Example
    • Typical Reporting Problems Repeating headers / footers Paginating/nesting tables Lots of data Maintaining uniform reporting style All covered by the flying saucer!
    • Script anything! JFreeChart: powerful charting Apache POI: read & write Excel files JODConvertor: convert (almost) anything to anything using OpenOffice.org Swing Hundreds more...
    • References http://github.com/alexandermalfait/acts_as_flying_saucer http://bosmeeuw.wordpress.com/ http://www.catsolutions.be/