SlideShare uma empresa Scribd logo
1 de 42
Baixar para ler offline
JRuby, Ruby, Rails and You
on the Cloud

December 6th, 2010
Who am I?


Hiro Asari
• JRuby Support Engineer at Engine Yard
• hasari@engineyard.com




                                          2
Engine Yard


• Platform as a Service provider
• Ruby on Rails specialists
• http://www.engineyard.com




                                   3
http://thenetworkisthecomputer.com/
                                 4
WHAT IS RUBY ON RAILS?"
AND"
WHY RUBY ON RAILS?


            http://www.flickr.com/photos/88019192@N00/3277925689/


                                                                5
JVM Web Frameworks Surveys


• http://bit.ly/jvm-frameworks-matrix
• http://bit.ly/webmatrixsurveyresults




                                         6
Rails


           ü Is a web application
         framework written in Ruby 


                 http://www.flickr.com/photos/46799485@N00/4386602878


                                                                    7
Ruby quick facts
• Conceived by Yukihiro
  Matsumoto (a.k.a. Matz)
  in 1993
• Object-oriented
  dynamically-typed
  interpreted scripting
  language
• Influenced by Perl,
  Smalltalk, Eiffel and LISP
• External libraries are
  most frequently
  distributed as “gems”


                               8
Rails quick facts
• Conceived by David
  Heinemeier Hansson
  (a.k.a. DHH) in 2004
• Extracted from 37signals’
  “Basecamp” application
• Uses MVC design
  pattern
• Rails 3, released in
  August, 2010, uses
  “Bundler” to manage
  gems.



                              9
Who uses Rails?




                   10
Getting JRuby




http://jruby.org




                    11
NetBeans



http://netbeans.org




                       12
NetBeans (if you have it already)




                                     13
RubyMine



http://jetbrains.com/ruby




                             14
RVM (Ruby Version Manager)


• http://rvm.beginrescueend.com/
• rvm install jruby
• rvm use jruby




                                   15
Rails


         ü Gets you off and running
                    quickly




                                       16
17
jruby -S rails new cloudstock_demo
cd cloudstock_demo
vi Gemfile
jruby -S bundle install
jruby -S bundle exec glassfish




                                     18
$ jruby -S rails new cloudstock_demo -m http://jruby.org
      create
      create README

      create   app
      create   app/controllers/application_controller.rb
      create   app/helpers/application_helper.rb
      create   app/mailers
      create   app/models
      create   app/views/layouts/application.html.erb

      create   public
      create   public/404.html

      create   script/rails
      create   test
      create   test/fixtures

      create   test/test_helper.rb
      create   test/unit

       apply   http://jruby.org
       apply     http://jruby.org/templates/default.rb
        gsub       Gemfile

                                                           19
20
$ jruby script/rails generate scaffold user name:string
calling init (1017e6ac0)
      invoke active_record
      create    db/migrate/20101115150436_create_users.rb
      create    app/models/user.rb
      invoke    test_unit
      create      test/unit/user_test.rb
      create      test/fixtures/users.yml
       route resources :users
      invoke scaffold_controller
      create    app/controllers/users_controller.rb
      invoke    erb
      create      app/views/users
      create      app/views/users/index.html.erb
      create      app/views/users/edit.html.erb
      create      app/views/users/show.html.erb
      create      app/views/users/new.html.erb
      create      app/views/users/_form.html.erb
      invoke    test_unit
      create      test/functional/users_controller_test.rb
      invoke    helper
      create      app/helpers/users_helper.rb
      invoke      test_unit
      create        test/unit/helpers/users_helper_test.rb
      invoke stylesheets
      create    public/stylesheets/scaffold.css



                                                             21
$ cat db/migrate/20101115150436_create_users.rb
class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.string :name

      t.timestamps
    end
  end

  def self.down
    drop_table :users
  end
end


                                                  22
Rails


         ü Is descriptive
                         




                             23
class User < ActiveRecord::Base
  validates_length_of :name, :minimum => 5
end




                                             24
Rails


         ü Is tested




                         25
$ find test
test
test/fixtures
test/fixtures/users.yml
test/functional
test/functional/users_controller_test.rb
test/integration
test/performance
test/performance/browsing_test.rb
test/test_helper.rb
test/unit
test/unit/helpers
test/unit/helpers/users_helper_test.rb
test/unit/user_test.rb


                                           26
$ cat test/unit/user_test.rb
require 'test_helper'

class UserTest < ActiveSupport::TestCase
  test "bare user is invalid" do
    u = User.new
    assert !u.valid?
    assert u.errors[:name].any?
  end

  test "user with name shorter than 5 character is invalid" do
    u = User.new(:name => "hi")
    assert !u.valid?
    assert u.errors[:name].any?
  end

  test "user with name with at least 5 character is valid" do
    u = User.new(:name => "hello")
    assert u.valid?
  end
end

                                                                 27
Rails


         ü Is good for agile
              development 




                                28
Rails


         ü Makes you happy
                          




                              29
WHAT ABOUT…




               30
Accessing Java library from Rails


• Generating SVG with Batik
• http://xmlgraphics.apache.org/batik/




                                         31
Example 1: Generating SVG with Batik
   require 'java'
   require 'batik'

   java_import org.apache.batik.svggen.SVGGraphics2D
   java_import org.apache.batik.dom.GenericDOMImplementation

   dom = GenericDOMImplementation.getDOMImplementation
   svg_ns = 'http://www.w3.org/2000/svg'
   doc = dom.createDocument svg_ns, 'svg', nil
   svg_gen = SVGGraphics2D.new( doc )

   svg_gen.set_paint java.awt.Color.send(color)
   svg_gen.fill java.awt.Rectangle.new(10,10,100,100)
   svg_gen.set_paint java.awt.Color.send(text_color)
   svg_gen.draw_string @user.name, 25, 55

   out = java.io.StringWriter.new
   svg_gen.stream(out, true)
   render :inline => out.to_string                                   

                                                               32
Accessing Java library from Rails


• Generating PDF with iText
• http://itextpdf.com/




                                     33
Example 2: Generating PDF with iText
 require 'iText-5.0.5'
 pdf = com.itextpdf.text.Document.new
 para = com.itextpdf.text.Paragraph.new "Hello #{@user.name}"
 file = "#{::Rails.root.to_s}/tmp/pdfs/pdf_demo.pdf”
 out = java.io.FileOutputStream.new file

 com.itextpdf.text.pdf.PdfWriter.get_instance pdf, out
 pdf.open
 pdf.add para
 pdf.close

 render :file => file



              Don’t do this in production code!
                                              


                                                                34
JRuby on Engine Yard AppCloud




                                 35
JRuby on Engine Yard AppCloud — Sign up today!




        http://docs.engineyard.com/beta/home




                                                  36
Testing in more detail


• RSpec http://rspec.info
• Cucumber http://cukes.info
• Celerity http://celerity.rubyforge.org




                                            37
Deployment strategies


•  Glassfish http://glassfish.java.net/ (.WAR)
•  Tomcat http://tomcat.apache.org/ (.WAR)
•  JBoss http://jboss.org/ (.WAR)
•  Jetty http://jetty.codehaus.org/jetty/ (.WAR)
•  Glassfish gem http://rubyforge.org/projects/glassfishgem/ (embedded
   glassfish)
•  Trinidad https://github.com/calavera/trinidad (embedded Tomcat)
•  Torquebox http://torquebox.org/ (embedded JBoss with extras)
•  Google App Engine http://code.google.com/appengine/ (via google-
   appengine gem http://code.google.com/p/appengine-jruby/)
•  Mongrel (outdated)




                                                                        38
Further information


• The Ruby language web site http://ruby-lang.org
• Ruby On Rails web site http://rubyonrails.org
• JRuby web site http://jruby.org
• Engine Yard web site http://engineyard.com
• Using JRuby (Pragmatic Bookshelf)
  http://www.pragprog.com/titles/jruby/using-
  jruby
• Meet Rails 3 (Peep Code)
  https://peepcode.com/products/meet-rails-3-i



                                                    39
Zero to Rails 3


• http://www.engineyard.com/sparkle
• 4-day online training (December 20-23)




                                           40
http://www.flickr.com/photos/10485077@N06/4975546097
                                                  


                                                  41
Thank you!
           



    Contact me
             
hasari@engineyard.com   
  Twitter: @hiro_asari
   Github: BanzaiMan



                            http://www.flickr.com/photos/42033648@N00/372887164
                                                                             

                                                                      42

Mais conteúdo relacionado

Mais procurados

Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpathAlexis Hassler
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Railstielefeld
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBHiro Asari
 
Why Task Queues - ComoRichWeb
Why Task Queues - ComoRichWebWhy Task Queues - ComoRichWeb
Why Task Queues - ComoRichWebBryan Helmig
 
Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientAdam Wiggins
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task QueueDuy Do
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developergicappa
 
Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignLightbend
 
Sinatra Rack And Middleware
Sinatra Rack And MiddlewareSinatra Rack And Middleware
Sinatra Rack And MiddlewareBen Schwarz
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To BatchLuca Mearelli
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...Codemotion
 
Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With PythonLuca Mearelli
 

Mais procurados (20)

Rails Performance
Rails PerformanceRails Performance
Rails Performance
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Rails
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
 
Why Task Queues - ComoRichWeb
Why Task Queues - ComoRichWebWhy Task Queues - ComoRichWeb
Why Task Queues - ComoRichWeb
 
Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClient
 
Sinatra for REST services
Sinatra for REST servicesSinatra for REST services
Sinatra for REST services
 
Debugging on rails
Debugging on railsDebugging on rails
Debugging on rails
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Celery - A Distributed Task Queue
Celery - A Distributed Task QueueCelery - A Distributed Task Queue
Celery - A Distributed Task Queue
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Akka and the Zen of Reactive System Design
Akka and the Zen of Reactive System DesignAkka and the Zen of Reactive System Design
Akka and the Zen of Reactive System Design
 
Sinatra Rack And Middleware
Sinatra Rack And MiddlewareSinatra Rack And Middleware
Sinatra Rack And Middleware
 
To Batch Or Not To Batch
To Batch Or Not To BatchTo Batch Or Not To Batch
To Batch Or Not To Batch
 
Django Celery
Django Celery Django Celery
Django Celery
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With Python
 

Semelhante a JRuby, Ruby, Rails and You on the Cloud

Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Arun Gupta
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGuillaume Laforge
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Nilesh Panchal
 
Rhodes And Phone Gap
Rhodes And Phone GapRhodes And Phone Gap
Rhodes And Phone GapMakoto Inoue
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Matt Raible
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaKeith Bennett
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡Wei Jen Lu
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09Michael Neale
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Enginecatherinewall
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Wen-Tien Chang
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!cloudbring
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...railsconf
 
Crank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBoxCrank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBoxJim Crossley
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemAlex Mikitenko
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.jsChris Cowan
 

Semelhante a JRuby, Ruby, Rails and You on the Cloud (20)

Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
Getting Started with Rails on GlassFish (Hands-on Lab) - Spark IT 2010
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
Ruby on-rails-101-presentation-slides-for-a-five-day-introductory-course-1194...
 
Rhodes And Phone Gap
Rhodes And Phone GapRhodes And Phone Gap
Rhodes And Phone Gap
 
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
Comparing Hot JavaScript Frameworks: AngularJS, Ember.js and React.js - Sprin...
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
把鐵路開進視窗裡
把鐵路開進視窗裡把鐵路開進視窗裡
把鐵路開進視窗裡
 
Jaoo Michael Neale 09
Jaoo Michael Neale 09Jaoo Michael Neale 09
Jaoo Michael Neale 09
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門Ruby on Rails : 簡介與入門
Ruby on Rails : 簡介與入門
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
 
Crank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBoxCrank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBox
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
Intro To Node.js
Intro To Node.jsIntro To Node.js
Intro To Node.js
 
Sprockets
SprocketsSprockets
Sprockets
 

Último

Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 

Último (20)

Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 

JRuby, Ruby, Rails and You on the Cloud

  • 1. JRuby, Ruby, Rails and You on the Cloud December 6th, 2010
  • 2. Who am I? Hiro Asari • JRuby Support Engineer at Engine Yard • hasari@engineyard.com 2
  • 3. Engine Yard • Platform as a Service provider • Ruby on Rails specialists • http://www.engineyard.com 3
  • 5. WHAT IS RUBY ON RAILS?" AND" WHY RUBY ON RAILS? http://www.flickr.com/photos/88019192@N00/3277925689/ 5
  • 6. JVM Web Frameworks Surveys • http://bit.ly/jvm-frameworks-matrix • http://bit.ly/webmatrixsurveyresults 6
  • 7. Rails ü Is a web application framework written in Ruby http://www.flickr.com/photos/46799485@N00/4386602878 7
  • 8. Ruby quick facts • Conceived by Yukihiro Matsumoto (a.k.a. Matz) in 1993 • Object-oriented dynamically-typed interpreted scripting language • Influenced by Perl, Smalltalk, Eiffel and LISP • External libraries are most frequently distributed as “gems” 8
  • 9. Rails quick facts • Conceived by David Heinemeier Hansson (a.k.a. DHH) in 2004 • Extracted from 37signals’ “Basecamp” application • Uses MVC design pattern • Rails 3, released in August, 2010, uses “Bundler” to manage gems. 9
  • 13. NetBeans (if you have it already) 13
  • 15. RVM (Ruby Version Manager) • http://rvm.beginrescueend.com/ • rvm install jruby • rvm use jruby 15
  • 16. Rails ü Gets you off and running quickly 16
  • 17. 17
  • 18. jruby -S rails new cloudstock_demo cd cloudstock_demo vi Gemfile jruby -S bundle install jruby -S bundle exec glassfish 18
  • 19. $ jruby -S rails new cloudstock_demo -m http://jruby.org create create README create app create app/controllers/application_controller.rb create app/helpers/application_helper.rb create app/mailers create app/models create app/views/layouts/application.html.erb create public create public/404.html create script/rails create test create test/fixtures create test/test_helper.rb create test/unit apply http://jruby.org apply http://jruby.org/templates/default.rb gsub Gemfile 19
  • 20. 20
  • 21. $ jruby script/rails generate scaffold user name:string calling init (1017e6ac0) invoke active_record create db/migrate/20101115150436_create_users.rb create app/models/user.rb invoke test_unit create test/unit/user_test.rb create test/fixtures/users.yml route resources :users invoke scaffold_controller create app/controllers/users_controller.rb invoke erb create app/views/users create app/views/users/index.html.erb create app/views/users/edit.html.erb create app/views/users/show.html.erb create app/views/users/new.html.erb create app/views/users/_form.html.erb invoke test_unit create test/functional/users_controller_test.rb invoke helper create app/helpers/users_helper.rb invoke test_unit create test/unit/helpers/users_helper_test.rb invoke stylesheets create public/stylesheets/scaffold.css 21
  • 22. $ cat db/migrate/20101115150436_create_users.rb class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :name t.timestamps end end def self.down drop_table :users end end 22
  • 23. Rails ü Is descriptive 23
  • 24. class User < ActiveRecord::Base validates_length_of :name, :minimum => 5 end 24
  • 25. Rails ü Is tested 25
  • 27. $ cat test/unit/user_test.rb require 'test_helper' class UserTest < ActiveSupport::TestCase test "bare user is invalid" do u = User.new assert !u.valid? assert u.errors[:name].any? end test "user with name shorter than 5 character is invalid" do u = User.new(:name => "hi") assert !u.valid? assert u.errors[:name].any? end test "user with name with at least 5 character is valid" do u = User.new(:name => "hello") assert u.valid? end end 27
  • 28. Rails ü Is good for agile development 28
  • 29. Rails ü Makes you happy 29
  • 31. Accessing Java library from Rails • Generating SVG with Batik • http://xmlgraphics.apache.org/batik/ 31
  • 32. Example 1: Generating SVG with Batik require 'java' require 'batik' java_import org.apache.batik.svggen.SVGGraphics2D java_import org.apache.batik.dom.GenericDOMImplementation dom = GenericDOMImplementation.getDOMImplementation svg_ns = 'http://www.w3.org/2000/svg' doc = dom.createDocument svg_ns, 'svg', nil svg_gen = SVGGraphics2D.new( doc ) svg_gen.set_paint java.awt.Color.send(color) svg_gen.fill java.awt.Rectangle.new(10,10,100,100) svg_gen.set_paint java.awt.Color.send(text_color) svg_gen.draw_string @user.name, 25, 55 out = java.io.StringWriter.new svg_gen.stream(out, true) render :inline => out.to_string 32
  • 33. Accessing Java library from Rails • Generating PDF with iText • http://itextpdf.com/ 33
  • 34. Example 2: Generating PDF with iText require 'iText-5.0.5' pdf = com.itextpdf.text.Document.new para = com.itextpdf.text.Paragraph.new "Hello #{@user.name}" file = "#{::Rails.root.to_s}/tmp/pdfs/pdf_demo.pdf” out = java.io.FileOutputStream.new file com.itextpdf.text.pdf.PdfWriter.get_instance pdf, out pdf.open pdf.add para pdf.close render :file => file Don’t do this in production code! 34
  • 35. JRuby on Engine Yard AppCloud 35
  • 36. JRuby on Engine Yard AppCloud — Sign up today! http://docs.engineyard.com/beta/home 36
  • 37. Testing in more detail • RSpec http://rspec.info • Cucumber http://cukes.info • Celerity http://celerity.rubyforge.org 37
  • 38. Deployment strategies •  Glassfish http://glassfish.java.net/ (.WAR) •  Tomcat http://tomcat.apache.org/ (.WAR) •  JBoss http://jboss.org/ (.WAR) •  Jetty http://jetty.codehaus.org/jetty/ (.WAR) •  Glassfish gem http://rubyforge.org/projects/glassfishgem/ (embedded glassfish) •  Trinidad https://github.com/calavera/trinidad (embedded Tomcat) •  Torquebox http://torquebox.org/ (embedded JBoss with extras) •  Google App Engine http://code.google.com/appengine/ (via google- appengine gem http://code.google.com/p/appengine-jruby/) •  Mongrel (outdated) 38
  • 39. Further information • The Ruby language web site http://ruby-lang.org • Ruby On Rails web site http://rubyonrails.org • JRuby web site http://jruby.org • Engine Yard web site http://engineyard.com • Using JRuby (Pragmatic Bookshelf) http://www.pragprog.com/titles/jruby/using- jruby • Meet Rails 3 (Peep Code) https://peepcode.com/products/meet-rails-3-i 39
  • 40. Zero to Rails 3 • http://www.engineyard.com/sparkle • 4-day online training (December 20-23) 40
  • 42. Thank you! Contact me hasari@engineyard.com Twitter: @hiro_asari Github: BanzaiMan http://www.flickr.com/photos/42033648@N00/372887164 42

Notas do Editor

  1. Once upon a time, there was a company which declared that “The Network Is The Computer”.These days, it is impossible to think of a computing environment without the network.
  2. At Devoxx 2010, Matt Raible surveyed the current status of JVM Web application frameworks.Ruby on Rails (via JRuby) came in #3 of 13 surveyed.Factors considered:Developer ProductivityDeveloper PerceptionLearning CurveProject HealthDeveloper AvailabilityJob TrendsTemplatingComponentsAjaxPlugins or Add-OnsScalabilityTestingi18n and l10nValidationMulti-language Support (Groovy / Scala)Quality of Documentation/TutorialsBooks PublishedREST Support (client and server)Mobile / iPhone SupportDegree of RiskAfollowup survey by another http://sebastien-arbogast.com/2010/11/19/jvm-web-framework-survey-first-results/From a small sample size, Rails came out #1.But really, you need to see for yourself if Rails (or any other Web application framework) works for YOU!
  3. “Convention over configuration”
  4. The original implementation of Ruby (also called CRuby, or MRI—Matz’s Ruby Interpreter) is implemented.A newer implemenation of the language, such as JRuby and Rubinius, can compile Ruby programs into byte code to execute them.
  5. Blog in 15 minutes: http://www.youtube.com/watch?v=Gzj723LkRJY
  6. The list might be outdated.Backpack (37 Signals)Cookpad (Recipe sharing site in Japan)Get Satisfaction (Customer service helper)Github (Social code sharing)Hulu (Online video streaming)Oracle Mix (SNS for Oracle professionals)New York Jets (J. E. T. S. Jets, Jets, Jets)Pragmatic BookshelfGrouponLighthouse (Development issue tracker)ZenDesk (Customer Support ticket tracker)
  7. http://jruby.org/download1.5.6 was released last Friday (Dec. 3, 2010)1.6 coming later this month or early next year
  8. NetBeans
  9. You can install and activate Ruby and Rails plugin if you have NetBeans already. (6.9 and later supports Rails 3.)
  10. RubyMine
  11. “Convention over configuration”In web application development, there are a lot of things that happen over and over.(Setting up MVC, configuring Database connections, laying out directory structures, etc.) Rails aims to make sensible decisions for you, so that you don’t have to make these decisions.You might think it’s constraining at first, but you will soon learn that by allowing you to spend more time thinking about the application itself (rather than “administrivia”) Rails liberates you.
  12. These are the commands used in the previous video.
  13. It creates a lot of directories and files with boilerplate content.Give -d mysql to use MySQL as the database engine.
  14. It creates a lot of directories and files with boilerplate content.
  15. Database schema modification is described in Ruby as well.This migration file was generated by the scaffold generator.
  16. Rails can be described as a DSL for web application development.
  17. It is clear what this piece of code does.
  18. Testing is a part of Ruby and Rails culture.
  19. Scaffold generator that we ran earlier also created a few files for tests as well.
  20. You *could* add test code such as this.You won’t have to test “validates_length_of” in this way, since it is a part of Rails, and, as such, it is very well tested and understood.
  21. Here, “agile” means short feedback cycles
  22. The bottom line is that Rails makes you happy.
  23. JRuby is an implementation of the Ruby language on the JVM. It can interoperate with the vast collection of existing Java libraries.http://vimeo.com/16270284 http://trackernet.org
  24. *DEMO 1*
  25. This example generates a simple SVG graphics with Batik library. http://xmlgraphics.apache.org/batik/
  26. *DEMO 2*
  27. This example generates a PDF file through iText. http://itextpdf.com/This is for illustration purposes only. It is not very secure, not is it very scalable.
  28. If you’re interested, sign up to be notified.
  29. What we did not cover today
  30. What we did not cover today:WAR files are created through warbler gem. http://kenai.com/projects/warbler/pages/HomeTorquebox’s (http://torquebox.org) extras include:ActiveMQ and built-in job scheduling supporthttp://jruby-appengine.blogspot.com/
  31. Engine Yard is offering an online training course of Rails 3 later this month.
  32. Go grab a piece of Cloud.