Ruby Conf Preso

848 views

Published on

Introduction to Waves, a resource-oriented applications framework, originally presented at RubyConf 08.

Published in: Technology, Education
1 Comment
0 Likes
Statistics
Notes
  • Thanks for your reply
    I still cannot download from www.slidersharea.net.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total views
848
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
0
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Ruby Conf Preso

  1. 1. Introducing Waves A Ruby Framework For Resource-Oriented Architecture
  2. 2. dan yoder director.hacking AT&T Interactive dan@zeraweb.com strategic research and development http://twitter.com/dyoder web • mobile • IPTV •  hci We’re so totally hiring. rest / roa • virtualization • mashups  search • map-reduce • grid computing AutoCode • Functor • Filebase • Waves • Pages • Hoshi • DateJS
  3. 3. This Isn’t MVC So Why Do We Use It So Often For Web Apps?
  4. 4. Get Your Head In The Clouds The Cloud Is Increasingly About ROA
  5. 5. But Why?
  6. 6. Web Sites (M) 160 120 Scalability? 80 The Web Has It. 40 0 2005 2006 2007 2008
  7. 7. HTML JSON CSS Open? M I M E Yep. Mostly, anyway. XML RSS RDF
  8. 8. Reuse? Just A Bit. Over 1,000 Public APIs And Counting.
  9. 9. Existing Infrastructure? Firewalls, Edge Caches, Proxy Servers, Etc.
  10. 10. Resource-Oriented Things With URIs. Self-Describing Messages. Uniform Interfaces And Standard Protocols. Linked Hypermedia And Content Negotiation. Well-Known Media Types. Stateless.
  11. 11. Let’s Take A Look At HTTP.
  12. 12. What Is HTTP, Really? A protocol that calls a method on a resource.
  13. 13. Sounds Like Ruby To Me!
  14. 14. class Dog attr_accessor :request def initialize( request ) @request = request end def get “Fido” if request.path == ‘/name’ end end
  15. 15. Sadly, It’s Not That Simple HTTP Requests - er, method signatures, are more than just pretty URIs.
  16. 16. HTTP Requests: Method Signatures? Example: GET get( URI: Content-Type, Params: Query-String ) : Accept
  17. 17. Functor To The Rescue Functor gives us argument pattern matching in Ruby.
  18. 18. A Quick Intro To Functor fib = Functor.new do given( 0 ) { 1 } given( 1 ) { 1 } given( Integer ) do |n| self.call( n - 1 ) + self.call( n - 2 ) end end fib.call( 7 ) # => 21
  19. 19. Functor Methods class Dog attr_accessor :request def initialize( request ) @request = request end functor( :get, “/name” ) { “Fido” } functor( :get, “/breed” ) { “Mutt” } end
  20. 20. Request Functor Functors defined on a Resource class to match a given Request pattern.
  21. 21. Request DSL A DSL Used In Resources To Define Request Functors. Can Match On Any Attribute.
  22. 22. Simple Example class Dog include Waves::Resources::Mixin on( :get, [ ‘name’ ] ) { “Fido” } end
  23. 23. Matching Query & Accept on( :get, [ ‘location’ ], :query => { :lat => /d{4}/, :long => /d{4}/ }, :accept => [ :json, :xml ] )
  24. 24. Waves Request DSL Match and capture components. Named path generators. Match wild-cards and regular expressions. Match accept, scheme, domain, content-type, most any attribute of a request.
  25. 25. But It’s Still Just Ruby pages $ waves console Pages::Resources::Story.instance_methods & %w( get put post delete ) # => [quot;deletequot;, quot;postquot;, quot;putquot;, quot;getquot;]
  26. 26. Resource Delegation Article Delegates Image Request Map Blog Inspects Request Gallery
  27. 27. Some Implications Or: Why Are Resource Classes Better Than Routes?
  28. 28. Resource Classes Inheritance. I can now just inherit from a base class to provide common REST features. Modularity. Request-handling is broken down into logically discrete chunks, just like normal classes. Performance. I don’t have to go through each possible match - just those for the matching resource.
  29. 29. A Word About Architecture Waves Supports Layered Architecture Through Foundations And Layers.
  30. 30. The One File Waves App module HelloWorld include Waves::Foundations::Compact module Resources class Map on( :get, [] ) { quot;Hello #{query.name}quot; } end end end
  31. 31. Resources decouple your application from the HTTP request processing. Application Resource Layers HTTP Foundation Layers mix-in features (like MVC support) to help build your application. A Foundation is a Layer that provides at least the minimal features required for a Waves application.
  32. 32. Layered Architecture module Classic def self.included( app ) require 'autocode' require 'layers/mvc' require 'layers/inflect/english' require 'helpers/extended' require 'layers/renderers/hoshi' app.module_eval do include Waves::Layers::Inflect::English include Waves::Layers::MVC include Waves::Renderers::Hoshi end end end
  33. 33. Some Other Features Inheritable Pure Ruby Configurations. Small Footprint, Pay Only For What You Use. No ORM Requirement, Sequel Support. Rack Compliant. Runs On JRuby. Complete MVC Layer Provided. Just-In-Time Class Creation / Loading. Leverages Existing Ruby Constructs Wherever Possible.
  34. 34. We’re Just Getting Warmed Up Seeking Contributors
  35. 35. Roadmap # TODO: this is a hack ...
  36. 36. Subject To Change Waves 0.8.2 Dec-08 • Waves 0.8.4 Feb-09 • Rack::Cache • Rinda-Based Improved Configurations • Management • Improved HTTP Authentication • Accept handling ORM-Neutral Schema Waves 0.8.3 Jan-09 • Waves 0.8.5 Apr-09 • Just- Hoshi • Cssy • Functor in-time views • Diff-based Memoization • Improved ORM-Neutral Migrations Request DSL • Non-HTTP Schemes
  37. 37. Waves::Vitals Initial 0.7.0 release Feb 08 Release 0.8.1 Available Now! Of course, we’re on git. http://github.com/dyoder/waves Join Us On Google Groups. rubywaves irc:freenode.net#waves And, lest we forget, a Web site. http://rubywaves.com/
  38. 38. Waves: Ruby ROA Shout out: leetspete, kaykay, automatthew, nanorails, copawaves, ab5tract, and many others.
  39. 39. Thanks! Photo credits: All photos from Flickr.com under Creative Commons License. http://www.flickr.com/photos/look4u/279668622/sizes/l/ http://www.flickr.com/photos/redteam/2885482695/ http://www.flickr.com/photos/ethanhein/2738164183/sizes/o/ http://www.flickr.com/photos/neilharvey/343068501/sizes/l/ http://www.flickr.com/photos/baldiri/496892841/sizes/o/ http://www.flickr.com/photos/walkingthedeepfield/2281168070/sizes/l/ http://www.flickr.com/photos/kanaka/1798470406/sizes/l/ http://www.flickr.com/photos/fuseman/262082281/sizes/o/ http://www.flickr.com/photos/xiaming/484440654/sizes/l/ http://www.flickr.com/photos/smithco/118770617/sizes/l/ http://www.flickr.com/photos/brainfarts/97676505/sizes/l/ http://www.flickr.com/photos/xfp/2830064227/sizes/o/

×