JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new...
Transcript of JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new...
![Page 2: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/2.jpg)
Ruby: Developer Happiness
=
![Page 3: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/3.jpg)
“Ruby is the glue that doesn't set”
http://pragdave.pragprog.com/pragdave/2006/06/glue_that_doesn.html
– Dave Thomas
![Page 4: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/4.jpg)
http://www.flickr.com/photos/vermininc/2777441779/
Ruby = innovation
![Page 5: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/5.jpg)
Testing
RSpechttp://cukes.info/http://rspec.info/
![Page 6: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/6.jpg)
![Page 7: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/7.jpg)
RubyDynamic language of the cloud
![Page 8: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/8.jpg)
http://www.flickr.com/photos/listenmissy/4869202176/
Ruby: Dynamic, Object-Oriented
![Page 9: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/9.jpg)
Duck-Typingdef area(width = 10, height = 2 * width) width * heightend
p area # => 200p area 5 # => 50p area 5, 20 # => 100p area "10", 4 # => ?
![Page 10: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/10.jpg)
Duck-Typingp area "10", 4 # => "10101010"
# From Ruby API docs:
# String#*(num)## Returns a new String containing num copies of# the receiver.## "Ho! " * 3 #=> "Ho! Ho! Ho! "
area true, false # => NoMethodError: undefined method `*' for # true:TrueClass
![Page 11: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/11.jpg)
Flexible Syntaxdef set_options(env, opts)end
set_options(:production, {"caching" => "on", "debug" => "false"})
set_options(:production, "caching" => "on", "debug" => "false")
set_options :production, {"caching" => "on", "debug" => "false"}
set_options :production, "caching" => "on", "debug" => "false"
![Page 12: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/12.jpg)
Blocks
Ruby
Java
list = [1, 2, 3, 4]
list.each {|n| puts n }
list.each do |n| puts nend
List<Integer> list = Arrays.asList(1, 2, 3, 4);
for (Integer n : list) { System.out.println(n);}
![Page 13: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/13.jpg)
Blocks
Ruby
Java
File.open(__FILE__) do |file| file.each_line do |line| puts line endend
BufferedReader file = new BufferedReader(new FileReader("Blocks.java"));try { String line; while ((line = buf.readLine()) != null) { System.out.println(line); }} finally { file.close();}
![Page 14: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/14.jpg)
Open Classes
msg = "Scramble this so you can't read it!"msg.rot13!
# => NoMethodError: undefined method `rot13!' for # "Scramble this so you can't read it!":String
![Page 15: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/15.jpg)
Open Classesclass String def rot13! 0.upto(length - 1) do |i| case self[i] when ?a..?z self[i] = ?a + ((self[i] - ?a) + 13) % 26 when ?A..?Z self[i] = ?A + ((self[i] - ?A) + 13) % 26 end end self endend
![Page 16: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/16.jpg)
Open Classes
puts msg.rot13! # => "Fpenzoyr guvf fb lbh pna'g ernq vg!"puts msg.rot13! # => "Scramble this so you can't read it!"
![Page 17: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/17.jpg)
Rails 3Dynamic framework of the cloud
![Page 18: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/18.jpg)
Opinionated Framework
Place foreverything
Request-basedMVC
Conventionover
Configuration
Defaultswith
Choices
![Page 19: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/19.jpg)
Place for everythingapplication code
configuration & environments
routes(URL structure)
database migrations
static assets(images, js, css)
tests
![Page 20: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/20.jpg)
Request-based MVC
View
ActionView
Controller
ActionController
Model
ActiveRecord
Request
DatabaseResponse
Routing
ActionDispatch
![Page 21: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/21.jpg)
URL GET /people
Routing resources :people #=> people#index
Controller
# app/controllers/people_controller.rbclass PeopleController < ApplicationController def index @people = Person.all endend
Model# app/models/person.rbclass Person < ActiveRecord::Baseend
View app/views/people/index.html.erb
Convention over Configuration
![Page 22: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/22.jpg)
Defaults with ChoicesDefault Alternatives
ORM
View Templates
JavaScript Framework
Database
Test Framework
ActiveRecordDataMapper, MongoMapper, Sequel, Any object with ActiveModel
ERbHAML, XML Builder, Markaby, RedCloth (Textile), BlueCloth (Markdown)
Prototype jQuery
SQLite3MySQL, PostgreSQL, Oracle, more via JRuby + JDBC
Test::Unit RSpec, Cucumber
![Page 23: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/23.jpg)
Why Rails?
http://j.mp/raible-jvm-frameworks© 2010, Raible Designs
Images by Stuck in Customs - http://www.flickr.com/photos/stuckincustoms
© 2010 Raible Designs
COMPARING JVM WEB FRAMEWORKS
Matt Raiblehttp://raibledesigns.com
![Page 24: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/24.jpg)
Why Rails?
Projectmaturity
InformationBooks,
Docs
Developmentspeed
Availableskilled
developers
Consider...
![Page 25: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/25.jpg)
Installing Rails
INSTALL gem install rails
![Page 26: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/26.jpg)
New Application
$ rails new coolapp -m http://jruby.org create create README create Rakefile ...
![Page 27: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/27.jpg)
Dependencies with Bundler
$ cd coolapp
$ bundle installFetching source index for http://rubygems.org/Using rake (0.8.7) Using abstract (1.0.0) ...Using rails (3.0.3) Your bundle is complete!
![Page 28: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/28.jpg)
Generate Scaffolding
$ rails generate scaffold person email:string password:string invoke active_record create db/migrate/20101214020707_create_people.rb create app/models/person.rb invoke test_unit create test/unit/person_test.rb create test/fixtures/people.yml route resources :people ...
![Page 29: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/29.jpg)
Migrate Database
$ rake db:migrate(in /Users/nicksieger/Projects/rails/coolapp)== CreatePeople: migrating ===========================-- create_table(:people) -> 0.0040s -> 0 rows== CreatePeople: migrated (0.0040s) ==================
![Page 30: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/30.jpg)
Start Dev Server
$ rails server=> Booting WEBrick=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000=> Call with -d to detach=> Ctrl-C to shutdown server[2010-12-13 20:11:28] INFO WEBrick 1.3.1[2010-12-13 20:11:28] INFO ruby 1.8.7 (2010-12-10) [java][2010-12-13 20:11:28] INFO WEBrick::HTTPServer#start: pid=21022 port=3000
![Page 31: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/31.jpg)
First Page
![Page 32: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/32.jpg)
Controllerclass PeopleController < ApplicationController # GET /people # GET /people.xml def index @people = Person.all
respond_to do |format| format.html # index.html.erb format.xml { render :xml => @people } end end
def show; end def new; end def edit; end def create; end def update; end def destroy; endend
![Page 33: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/33.jpg)
Model
class Person < ActiveRecord::Baseend
![Page 34: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/34.jpg)
Console
$ rails consoleLoading development environment (Rails 3.0.3)irb(main):001:0> Person.create :email => "[email protected]", ... => #<Person id: 1, email: "[email protected]", ...>
![Page 35: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/35.jpg)
Rails 3 and JRuby
http://weblog.rubyonrails.org/2010/8/29/rails-3-0-it-s-done
![Page 37: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/37.jpg)
JRubyDynamic toolkit of the cloud
![Page 39: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/39.jpg)
JRuby via MavenGroup ID: org.jruby
Artifact IDs: jruby, jruby-complete
![Page 40: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/40.jpg)
JRubydrive java • embed • compile
![Page 41: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/41.jpg)
Drive Java
Ruby
Java
synth = javax.sound.midi.MidiSystem.synthesizersynth.openchannel = synth.channels[0]
import javax.sound.midi.*;
Synthesizer synth = MidiSystem.getSynthesizer();synth.open();final MidiChannel channel = synth.getChannels()[0];
![Page 42: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/42.jpg)
Drive Java
Ruby
Java
frame = javax.swing.JFrame.new "Music Frame"frame.set_size 600, 100frame.layout = java.awt.FlowLayout.new
import java.awt.*;
JFrame frame = new JFrame("Music Frame");frame.setSize(600, 100);frame.setLayout(new java.awt.FlowLayout());
![Page 43: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/43.jpg)
Drive Java
Ruby
Java
KEYS.each do |value, char| button = javax.swing.JButton.new char button.add_action_listener do |e| channel.note_on value, 99 end frame.add buttonend
for (Iterator i = keys.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); final Integer value = (Integer) entry.getKey(); String name = (String) entry.getValue(); JButton button = new JButton(name); button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent e) { channel.noteOn(value, 99); } }); frame.add(button);}
![Page 44: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/44.jpg)
MIDI Swing
![Page 45: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/45.jpg)
Embed
import org.jruby.embed.ScriptingContainer;
public class EmbedJRuby { public static void main(String[] args) { ScriptingContainer container = new ScriptingContainer(); container.runScriptlet("puts 'Hello from Ruby'"); }}
![Page 46: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/46.jpg)
http://wiki.jruby.org/RedBridge
![Page 47: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/47.jpg)
Compile# engine.rbrequire 'java'java_package 'demo'
class Engine java_implements 'java.lang.Runnable'
java_signature 'void run()' def run puts "The #{self.inspect} is running." endend
![Page 48: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/48.jpg)
Compile// Starter.javaimport demo.Engine;
public class Starter { public static void main(String[] args) { Runnable engine = new Engine(); engine.run(); }}
![Page 49: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/49.jpg)
Compile
$ jrubyc --javac engine.rb Starter.java Generating Java class Engine to demo/Engine.javajavac -d . -cp jruby.jar:. demo/Engine.java Starter.java
![Page 50: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/50.jpg)
Compile
// Engine.javapackage demo;
public class Engine implements Runnable { public void run() { ... }}
![Page 51: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/51.jpg)
Compile
$ java -cp jruby.jar:. StarterThe #<Engine:0x59c958af> is running.
![Page 52: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/52.jpg)
JRuby 1.6Release soon!
ruby 1.9.2 • c-ext • perf • dynopt • java
![Page 53: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/53.jpg)
activerecord-jdbc
INSTALL gem install activerecord-jdbc-adapter
ActiveRecord with JDBC databases
![Page 54: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/54.jpg)
Warbler
Railsapp warble app.war
deployto java
appserver
• Create a Java EE .war file from a Rails application• “Looks like Java” to the ops staff
INSTALL gem install warbler
![Page 55: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/55.jpg)
JRuby Deployment
Ruby servers
WEBrick
Trinidad
TorqueBox
WAR files
GlassFish
Tomcat
JBoss
Cloud
EY AppCloud
AppEngine
AWS EB
![Page 56: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/56.jpg)
Enterprise SoftwareEvolving and adapting long-running
projects with legacy codebases
![Page 57: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/57.jpg)
Sagrada Família, Barcelona, Spain
![Page 58: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/58.jpg)
nativityfacade
passionfacade
scaffolded interior
![Page 59: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/59.jpg)
Ryugyuong Hotel,North Korea2005 2010
![Page 60: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/60.jpg)
seismic retrofit
![Page 61: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/61.jpg)
Szkieletor,Kraków, Poland
![Page 62: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/62.jpg)
RailsMVC
ActionDispatchActionDispatchActionDispatch
RailsMVC
ActionController/ActionViewActionController/ActionViewActionController/ActionViewRailsMVC
ActiveModelActiveModelActiveModel
JavaBackend
JavaPOJOs
JDBCDataSource
SOAPinterface
Hybrid Rails/Java App
![Page 63: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/63.jpg)
https://github.com/nicksieger/spring-petclinic
![Page 64: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/64.jpg)
Metaphor Use Ruby, JRuby, and Rails to...
Sagrada Familia
• Build new facade faster• Scaffolding during refactoring
Ryugyong Hotel
• Revive a project with a new face
Seismic retrofit
• Reinforce business rules with a DSL• Harden security
Szkieletor • Find novel uses for abandoned code
![Page 65: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/65.jpg)
![Page 67: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/67.jpg)
Resources
Resources for Getting Started with
Ruby on Rails
Resources for Getting Started with
Ruby on RailsJRuby.org
Resources for Getting Started with
Ruby on Rails
Resources for Getting Started with
Ruby on Rails
JRubyConf 2010 Videos
Rails for Zombies
![Page 68: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/68.jpg)
Nick [email protected]: http://j.mp/sieger-jfokus
![Page 69: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/69.jpg)
Imageshttp://en.wikipedia.org/wiki/File:Sagrada_Familia_01.jpghttp://www.flickr.com/photos/gonzalvo/4257293127/http://www.flickr.com/photos/mgrenner57/263392884/http://www.flickr.com/photos/koocheekoo/38407225/http://www.flickr.com/photos/27649557@N07/5000528445/http://www.flickr.com/photos/gpaumier/446059442/http://www.flickr.com/photos/ilm/12831049/http://en.wikipedia.org/wiki/File:Ryugyong_Hotel_-_May_2005.JPGhttp://en.wikipedia.org/wiki/File:Ryugyong_Hotel_October_2010.jpghttp://en.wikipedia.org/wiki/File:ExteiorShearTruss.jpghttp://en.wikipedia.org/wiki/File:ExtReenfDetail.jpghttp://en.wikipedia.org/wiki/File:Szkieleteor_in_krakow.JPGhttp://www.flickr.com/photos/bazylek/3194294047/
![Page 70: JRuby + Rails€¦ · Metaphor Use Ruby, JRuby, and Rails to... Sagrada Familia • Build new facade faster • Scaffolding during refactoring Ryugyong Hotel • Revive a project](https://reader033.fdocuments.us/reader033/viewer/2022060508/5f23afe4ee9d83198a064166/html5/thumbnails/70.jpg)